while ($user->fetch()) {
common_log(LOG_INFO, 'Updating inbox for user ' . $user->id);
+ $user->query('BEGIN');
$inbox = new Notice_inbox();
$result = $inbox->query('INSERT LOW_PRIORITY IGNORE INTO notice_inbox (user_id, notice_id, created) ' .
'SELECT ' . $user->id . ', notice.id, notice.created ' .
'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
'WHERE subscription.subscriber = ' . $user->id . ' ' .
'AND notice.created >= subscription.created');
- if (!$result) {
+ if (is_null($result) || $result === false) {
common_log_db_error($inbox, 'INSERT', __FILE__);
+ continue;
+ }
+ $orig = clone($user);
+ $user->inboxed = 1;
+ $result = $user->update($orig);
+ if (!$result) {
+ common_log_db_error($user, 'UPDATE', __FILE__);
+ continue;
}
+ $user->query('COMMIT');
$inbox->free();
unset($inbox);
}