From 62a261930073837d10993fae81202517bc04e122 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Mar 2016 18:01:31 +0100 Subject: [ticket/14483] Do not send headers by default on access via controller PHPBB3-14483 --- phpBB/phpbb/controller/helper.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php index 79378c2434..08a63639b9 100644 --- a/phpBB/phpbb/controller/helper.php +++ b/phpBB/phpbb/controller/helper.php @@ -102,12 +102,13 @@ class helper * @param bool $display_online_list Do we display online users list * @param int $item_id Restrict online users to item id * @param string $item Restrict online users to a certain session item, e.g. forum for session_forum_id + * @param bool $send_headers Whether headers should be sent by page_header(). Defaults to false for controllers. * * @return Response object containing rendered page */ - public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum') + public function render($template_file, $page_title = '', $status_code = 200, $display_online_list = false, $item_id = 0, $item = 'forum', $send_headers = false) { - page_header($page_title, $display_online_list, $item_id, $item); + page_header($page_title, $display_online_list, $item_id, $item, $send_headers); $this->template->set_filenames(array( 'body' => $template_file, @@ -115,7 +116,9 @@ class helper page_footer(true, false, false); - return new Response($this->template->assign_display('body'), $status_code); + $headers = !empty($this->user->data['is_bot']) ? array('X-PHPBB-IS-BOT' => 'yes') : array(); + + return new Response($this->template->assign_display('body'), $status_code, $headers); } /** -- cgit v1.2.1 From 9fcd0b116b4a5340f8743df53235e1c639204989 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 8 Mar 2016 12:15:21 +0100 Subject: [ticket/14519] Skip query if all unread notifications are retrieved PHPBB3-14519 --- phpBB/phpbb/notification/manager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index db92170dd8..b1b096d41d 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -186,6 +186,7 @@ class manager if (!$options['count_total'] || $total_count) { $rowset = array(); + $selected_unread_count = 0; // Get the main notifications $sql = 'SELECT n.*, nt.notification_type_name @@ -200,11 +201,12 @@ class manager while ($row = $this->db->sql_fetchrow($result)) { $rowset[$row['notification_id']] = $row; + $selected_unread_count += (int) !$row['notification_read']; } $this->db->sql_freeresult($result); // Get all unread notifications - if ($unread_count && $options['all_unread'] && !empty($rowset)) + if ($selected_unread_count < $unread_count && $options['all_unread'] && !empty($rowset)) { $sql = 'SELECT n.*, nt.notification_type_name FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt -- cgit v1.2.1 From 10004c4032a86364c834574a670032d2676b87cb Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 8 Mar 2016 12:36:29 +0100 Subject: [ticket/14132] Use transaction for adding notifications to type table This will prevent a race condition that might occur by two posts being submitted at the same time with the notification type IDs not being cached. PHPBB3-14132 --- phpBB/phpbb/notification/manager.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index db92170dd8..233d65eebe 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -923,6 +923,8 @@ class manager { $notification_type_ids = $this->cache->get('notification_type_ids'); + $this->db->sql_transaction('begin'); + if ($notification_type_ids === false) { $notification_type_ids = array(); @@ -957,6 +959,8 @@ class manager $this->cache->put('notification_type_ids', $notification_type_ids); } + $this->db->sql_transaction('commit'); + return $notification_type_ids[$notification_type_name]; } -- cgit v1.2.1