Wipe unconfirmed subscriber data during import [MAILPOET-760]
This commit is contained in:
@@ -838,6 +838,7 @@ class Subscriber extends Model {
|
|||||||
'UPDATE `' . self::$_table . '` ' .
|
'UPDATE `' . self::$_table . '` ' .
|
||||||
'SET ' . implode(', ', $sql('statement')) . ' '.
|
'SET ' . implode(', ', $sql('statement')) . ' '.
|
||||||
(($updated_at) ? ', updated_at = "' . $updated_at . '" ' : '') .
|
(($updated_at) ? ', updated_at = "' . $updated_at . '" ' : '') .
|
||||||
|
', unconfirmed_data = NULL ' .
|
||||||
'WHERE email IN ' .
|
'WHERE email IN ' .
|
||||||
'(' . rtrim(str_repeat('?,', count($subscribers)), ',') . ')',
|
'(' . rtrim(str_repeat('?,', count($subscribers)), ',') . ')',
|
||||||
array_merge(
|
array_merge(
|
||||||
|
@@ -463,9 +463,19 @@ class SubscriberTest extends MailPoetTest {
|
|||||||
expect($subscriber->unconfirmed_data)->equals(json_encode($data2));
|
expect($subscriber->unconfirmed_data)->equals(json_encode($data2));
|
||||||
|
|
||||||
// Unconfirmed data should be wiped after any direct update
|
// Unconfirmed data should be wiped after any direct update
|
||||||
// during confirmation, manual admin editing, import etc.
|
// during confirmation, manual admin editing
|
||||||
$subscriber = Subscriber::createOrUpdate($data2);
|
$subscriber = Subscriber::createOrUpdate($data2);
|
||||||
|
expect($subscriber->unconfirmed_data)->isEmpty();
|
||||||
|
// during import
|
||||||
|
$subscriber->unconfirmed_data = json_encode($data2);
|
||||||
|
$subscriber->save();
|
||||||
|
expect($subscriber->isDirty('unconfirmed_data'))->false();
|
||||||
|
expect($subscriber->unconfirmed_data)->notEmpty();
|
||||||
|
Subscriber::updateMultiple(
|
||||||
|
array_keys($data2),
|
||||||
|
array(array_values($data2))
|
||||||
|
);
|
||||||
|
$subscriber = Subscriber::where('email', $data2['email'])->findOne();
|
||||||
expect($subscriber->unconfirmed_data)->isEmpty();
|
expect($subscriber->unconfirmed_data)->isEmpty();
|
||||||
|
|
||||||
Setting::setValue('signup_confirmation.enabled', $original_setting_value);
|
Setting::setValue('signup_confirmation.enabled', $original_setting_value);
|
||||||
|
Reference in New Issue
Block a user