From 50896305fa9b5b0db733ae4a401c9bd0a85cabe9 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 13 Nov 2013 23:57:39 -0800 Subject: [PATCH 1/2] [ticket/12008] The read_notification_last_gc config setting should be dynamic. PHPBB3-12008 --- phpBB/install/schemas/schema_data.sql | 2 +- .../data/v310/notifications_cron_p2.php | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 794def40dc..095415b175 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -232,7 +232,6 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('print_pm', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('queue_interval', '60'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ranks_path', 'images/ranks'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('read_notification_expire_days', '30'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('read_notification_last_gc', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('read_notification_gc', '86400'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('referer_validation', '1'); @@ -288,6 +287,7 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('num_us INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('plupload_last_gc', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('rand_seed', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('rand_seed_last_update', '0', 1); +INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('read_notification_last_gc', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_date', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('record_online_users', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('search_indexing_state', '', 1); diff --git a/phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php b/phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php new file mode 100644 index 0000000000..050e679cc0 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/notifications_cron_p2.php @@ -0,0 +1,27 @@ + Date: Wed, 13 Nov 2013 23:58:21 -0800 Subject: [PATCH 2/2] [ticket/12008] Update the run time value for the prune notifications cron task PHPBB3-12008 --- phpBB/config/services.yml | 1 + phpBB/phpbb/notification/manager.php | 9 ++++++++- tests/notification/base.php | 1 + tests/notification/submit_post_base.php | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 4280f90375..84143a2362 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -244,6 +244,7 @@ services: - @notification.method_collection - @service_container - @user_loader + - @config - @dbal.conn - @cache - @user diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index d77a936413..2e8652771b 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -27,6 +27,9 @@ class manager /** @var \phpbb\user_loader */ protected $user_loader; + /** @var \phpbb\config\config */ + protected $config; + /** @var \phpbb\db\driver\driver */ protected $db; @@ -58,6 +61,7 @@ class manager * @param array $notification_methods * @param ContainerBuilder $phpbb_container * @param \phpbb\user_loader $user_loader + * @param \phpbb\config\config $config * @param \phpbb\db\driver\driver $db * @param \phpbb\user $user * @param string $phpbb_root_path @@ -67,13 +71,14 @@ class manager * @param string $user_notifications_table * @return \phpbb\notification\manager */ - public function __construct($notification_types, $notification_methods, $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\db\driver\driver $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) + public function __construct($notification_types, $notification_methods, $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) { $this->notification_types = $notification_types; $this->notification_methods = $notification_methods; $this->phpbb_container = $phpbb_container; $this->user_loader = $user_loader; + $this->config = $config; $this->db = $db; $this->cache = $cache; $this->user = $user; @@ -797,6 +802,8 @@ class manager WHERE notification_time < ' . (int) $timestamp . (($only_read) ? ' AND notification_read = 1' : ''); $this->db->sql_query($sql); + + $this->config->set('read_notification_last_gc', time(), false); } /** diff --git a/tests/notification/base.php b/tests/notification/base.php index 549545f01b..f6333866c3 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -70,6 +70,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case array(), $this->container, $this->user_loader, + $this->config, $this->db, $this->cache, $this->user, diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 8597c626a4..a9ed59686a 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -118,7 +118,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case // Notification Manager $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), - $phpbb_container, $user_loader, $db, $cache, $user, + $phpbb_container, $user_loader, $config, $db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); $phpbb_container->set('notification_manager', $phpbb_notifications);