Merge branch '3.3.x'

This commit is contained in:
Marc Alexander 2024-01-01 21:35:55 +01:00
commit 39cad1d235
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
3 changed files with 27 additions and 2 deletions

View file

@ -1663,7 +1663,7 @@ class session
} }
// Do not update the session page for ajax requests, so the view online still works as intended // Do not update the session page for ajax requests, so the view online still works as intended
$page_changed = $this->update_session_page && (!isset($this->data['session_page']) || $this->data['session_page'] != $this->page['page']) && !$request->is_ajax(); $page_changed = $this->update_session_page && (!isset($this->data['session_page']) || $this->data['session_page'] != $this->page['page'] || $this->data['session_forum_id'] != $this->page['forum']) && !$request->is_ajax();
// Only update session DB a minute or so after last update or if page changes // Only update session DB a minute or so after last update or if page changes
if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed) if ($this->time_now - (isset($this->data['session_time']) ? $this->data['session_time'] : 0) > 60 || $page_changed)

View file

@ -104,8 +104,17 @@ switch ($mode)
trigger_error('NO_POST'); trigger_error('NO_POST');
} }
// Need to update session forum_id to valid value for proper viewonline information
if (!$forum_id)
{
$user->page['forum'] = (int) $topic_forum['forum_id'];
$user->update_session_page = true;
$user->update_session_infos();
}
$topic_id = (int) $topic_forum['topic_id']; $topic_id = (int) $topic_forum['topic_id'];
$forum_id = (int) $topic_forum['forum_id']; $forum_id = (int) $topic_forum['forum_id'];
break; break;
} }

View file

@ -81,6 +81,22 @@ class phpbb_functional_viewonline_test extends phpbb_functional_test_case
$this->assertStringContainsString('viewonline-test-user1', $crawler->text()); $this->assertStringContainsString('viewonline-test-user1', $crawler->text());
$this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text()); $this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text());
// Log in as test user
self::$client->restart();
$this->login('viewonline-test-user1');
$test_post_data = $this->create_post(2, 1, 'Viewonline test post #1', 'Viewonline test post message');
$crawler = self::request('GET', 'posting.php?mode=edit&p=' . $test_post_data['post_id'] . '&sid=' . $this->sid);
$this->assertContainsLang('EDIT_POST', $crawler->text());
// Log in as another user
self::$client->restart();
$this->login();
// PHP goes faster than DBMS, make sure session data got written to the database
sleep(1);
$crawler = self::request('GET', 'viewonline.php?sid=' . $this->sid);
// Make sure posting message page is in the list
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
$this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text());
// Log in as test user // Log in as test user
self::$client->restart(); self::$client->restart();
$this->login('viewonline-test-user1'); $this->login('viewonline-test-user1');