phpBB: Thread watches email notification setting is not imported correctly

Kirby

Well-known member
Affected version
1.5.2
XFI\Import\Importer\PhpBB::stepThreads
PHP:
$subs = $this->sourceDb->fetchPairs("
    SELECT user_id, notify_status
    FROM topics_watch
    WHERE topic_id = {$oldThreadId}
");

This code assumes that field notify_status is set to 1 if the user wants to receive notifications via email.

But this is not the case as phpBB doesn't allow to specify email notification preference per thread - the field indicates if a notification has been sent (but the user hasn't read the thread since).

Changing the SQL to
PHP:
$subs = $this->sourceDb->fetchPairs("
    SELECT topics_watch.user_id, IF(ISNULL(user_notifications_topic.notify), user_notifications_default.notify, user_notifications_topic.notify) AS notify
    FROM topics_watch AS topics_watch
    LEFT JOIN user_notifications AS user_notifications_default ON (user_notifications_default.user_id = topics_watch.user_id AND user_notifications_default.item_id = 0 AND user_notifications_default.item_type = 'notification.type.post' AND user_notifications_default.method = 'notification.method.email')
    LEFT JOIN user_notifications AS user_notifications_topic ON (user_notifications_topic.user_id = topics_watch.user_id AND user_notifications_topic.item_id = topics_watch.topic_id AND user_notifications_topic.item_type = 'notification.type.post' AND user_notifications_topic.method = 'notification.method.email')
    WHERE topic_id = {$oldThreadId}
");
seems to fix this.
 
Back
Top Bottom