diff options
author | Andreas Fischer <bantu@phpbb.com> | 2014-05-14 23:12:11 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2014-05-14 23:12:11 +0200 |
commit | dacece711b24ac0b8828b6b5d7776ab6ae7b5333 (patch) | |
tree | 6acca849bceeee2fdedf5ae50868bfeaf8fccc02 /phpBB | |
parent | 1b8bcef2d14dee3127dcb4c5b7282c866f25f1f2 (diff) | |
parent | 7af785f903c4d939b05b291a7beef37c33d3b825 (diff) | |
download | forums-dacece711b24ac0b8828b6b5d7776ab6ae7b5333.tar forums-dacece711b24ac0b8828b6b5d7776ab6ae7b5333.tar.gz forums-dacece711b24ac0b8828b6b5d7776ab6ae7b5333.tar.bz2 forums-dacece711b24ac0b8828b6b5d7776ab6ae7b5333.tar.xz forums-dacece711b24ac0b8828b6b5d7776ab6ae7b5333.zip |
Merge pull request #2456 from Nicofuma/ticket/12435
[ticket/12435] purge_notifications() fails for unused notifications
* Nicofuma/ticket/12435:
[ticket/12435] Update the comment
[ticket/12435] purge_notifications() fails for unused notifications
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/phpbb/notification/manager.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 09d9677ccd..2f7d846d75 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -760,17 +760,30 @@ class manager */ public function purge_notifications($notification_type_name) { - $notification_type_id = $this->get_notification_type_id($notification_type_name); + // If a notification is never used, its type will not be added to the database + // nor its id cached. If this method is called by an extension during the + // purge step, and that extension never used its notifications, + // get_notification_type_id() will throw an exception. However, + // because no notification type was added to the database, + // there is nothing to delete, so we can silently drop the exception. + try + { + $notification_type_id = $this->get_notification_type_id($notification_type_name); - $sql = 'DELETE FROM ' . $this->notifications_table . ' - WHERE notification_type_id = ' . (int) $notification_type_id; - $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->notifications_table . ' + WHERE notification_type_id = ' . (int) $notification_type_id; + $this->db->sql_query($sql); - $sql = 'DELETE FROM ' . $this->notification_types_table . ' - WHERE notification_type_id = ' . (int) $notification_type_id; - $this->db->sql_query($sql); + $sql = 'DELETE FROM ' . $this->notification_types_table . ' + WHERE notification_type_id = ' . (int) $notification_type_id; + $this->db->sql_query($sql); - $this->cache->destroy('notification_type_ids'); + $this->cache->destroy('notification_type_ids'); + } + catch (\phpbb\notification\exception $e) + { + // Continue + } } /** |