View Issue Details

IDProjectCategoryView StatusLast Update
0019403phpList 3 applicationSubscriber Importpublic01-10-18 10:34
Reporterduncanc 
PrioritynormalSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
Product Version3.3.3 
Target Version3.3.5Fixed in Version3.4.0 
Summary0019403: Use of mysql "replace into"
DescriptionThe mysql "replace into" statement is used in several places as a convenient way to handle inserting a record or updating when a record for the the key field already exists.

The "replace into" statement actually deletes the current record and adds a new record. If the table has an autoincrement field or a field that defaults to the current timestamp, then the new record will be different to the original record even when no other field has changed. In many cases that should be ok but it causes a problem for the Autoresponder plugin when used on the listuser table by the import pages.

If you import an existing subscriber, say on the simpleimport page, then the user record remains the same but the record in listuser for the list/user combination has new values for the entered and modified fields.
The Autoresponder plugin uses the modified field on listuser as part of the criteria to decide whether to send the campaign to that subscriber. If the modified field is changed in this way then a campaign may be sent to the subscriber when it shouldn't.
That problem was reported in the user forum, https://discuss.phplist.org/t/autoresponder-sending-to-old-subscribers/4383/5

An alternative to "replace into" is to use "insert ignore" for the cases when we want to insert when the record does not already exist and make no change when the record does exist. These cases include inserting into the listuser tableby the import pages and the copy and move commands on the list membership page.
TagsNo tags attached.

Activities

duncanc

12-09-18 15:43

developer   ~0061088

See Pull Request https://github.com/phpList/phplist3/pull/402