roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.88k stars 1.64k forks source link

Don't empty contact email/names on empty/malformed vCard #7132

Closed bes-internal closed 3 years ago

bes-internal commented 4 years ago

After upgrade I found that all contacts with an empty email field. I filled in the fields back from the backup and restarting them again deleted them.

The problem appeared near upgrade 1.3.8 -> 1.3.9 Сhecking for 2fa6dd7 (lastes 1.4)

Actual DDL:

CREATE TABLE `contacts` (
  `contact_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
  `del` tinyint(1) NOT NULL DEFAULT '0',
  `name` varchar(128) NOT NULL DEFAULT '',
  `email` text NOT NULL,
  `firstname` varchar(128) NOT NULL DEFAULT '',
  `surname` varchar(128) NOT NULL DEFAULT '',
  `vcard` longtext,
  `words` text,
  `user_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`contact_id`) USING BTREE,
  KEY `user_contacts_index` (`user_id`,`del`) USING BTREE,
  CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1617 DEFAULT CHARSET=utf8;
alecpl commented 4 years ago

This script is supposed to be run when upgrading from version < 0.6.

Anyway, I don't see how that might have happened. I'm unable to reproduce. Do you have any logs from the upgrade?

bes-internal commented 4 years ago

I used manual upgrade and run script referring to this line (branch 1.4) https://github.com/roundcube/roundcubemail/blob/51b8137170bc66a5e68b36710b0f05386d6c6f50/UPGRADING#L78

debug

I changed program/include/rcmail_utils.php to this:

Screenshot_2

Then i tried to find this row in output (this is roundcube db with actual data, table contacts [contacts_id ... userid]):

Screenshot_1

and got empty data for this contacts.contact_id (and all other too)

Screenshot_3

alecpl commented 4 years ago

One mistake on my side, the script is required for < 0.6, but optional for newer versions.

Works for me with 1.4.2. The script (modified the same way with echo) displays proper data and many runs of the same script print the same, do not remove any data.

What PHP version? What database? Is this the result of the script execution on a non-malformed database (from backup)? Script run on already malformed data will not help much. Does the version of the script from 1.4.2 also cause the same issue? Could you provide full record from database (SELECT * FROM contacts WHERE contact_id = 77)?

bes-internal commented 4 years ago

php-7.3.13 mysql-5.7.27 contacts migrate from another db by script (respect users, contactgroups, contactgroupmembers). If the base is broken after the transfer, then how to find out exactly what is on the contact_id=77? There must be entries in the contactgroups/contactgroupmembers tables for contact_id=77? Besides this, no problems were found in the roundcube with contacts.

SELECT * FROM contacts WHERE contact_id = 77: Screenshot_1

alecpl commented 4 years ago

Does it help if you remove content of the vcard column?

bes-internal commented 4 years ago

Excellent, vcards were updated and email dont empty. I can’t say for sure when the vcards were damaged.

alecpl commented 3 years ago

Fixed.