diff options
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/cron/task/core/prune_shadow_topics.php | 10 | ||||
-rw-r--r-- | phpBB/phpbb/notification/manager.php | 29 |
2 files changed, 29 insertions, 10 deletions
diff --git a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php index b30e665a87..aa600e9abe 100644 --- a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php +++ b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php @@ -25,6 +25,7 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t protected $config; protected $db; protected $log; + protected $user; /** * If $forum_data is given, it is assumed to contain necessary information @@ -44,14 +45,16 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t * @param \phpbb\config\config $config The config * @param \phpbb\db\driver\driver $db The db connection * @param \phpbb\log\log $log The phpBB log system + * @param \phpbb\user $user The phpBB user object */ - public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\log\log $log) + public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\log\log $log, \phpbb\user $user) { $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->config = $config; $this->db = $db; $this->log = $log; + $this->user = $user; } /** @@ -183,7 +186,10 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t WHERE forum_id = $forum_id"; $this->db->sql_query($sql); - $this->log->add('admin', 'LOG_PRUNE_SHADOW', $row['forum_name']); + $user_id = (empty($this->user->data)) ? ANONYMOUS : $this->user->data['user_id']; + $user_ip = (empty($this->user->ip)) ? '' : $this->user->ip; + + $this->log->add('admin', $user_id, $user_ip, 'LOG_PRUNE_SHADOW', false, array($row['forum_name'])); } return; 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 + } } /** |