Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ public function viewonline_ideas($event)
try
{
$route = $this->router->match($session_path);
$in_ideas_pages = strpos($route['_route'], 'phpbb_ideas_') === 0;
$in_ideas_pages = isset($route['_route']) && strpos($route['_route'], 'phpbb_ideas_') === 0;
}
catch (\Symfony\Component\Routing\Exception\ExceptionInterface $e)
catch (\RuntimeException $e)
{
// Not a routed Ideas page.
}
Expand Down
22 changes: 21 additions & 1 deletion tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ protected function setUp(): void
$route_collection->add('phpbb_ideas_post_controller', new \Symfony\Component\Routing\Route('/ideas/post'));
$matcher = new \Symfony\Component\Routing\Matcher\UrlMatcher($route_collection, new \Symfony\Component\Routing\RequestContext());
$this->router->method('match')
->willReturnCallback(array($matcher, 'match'));
->willReturnCallback(function ($path) use ($matcher) {
if ($path === '/runtime-error')
{
throw new \RuntimeException('Unable to match route.');
}

return $matcher->match($path);
});
$this->template = $this->getMockBuilder('\phpbb\template\template')
->getMock();
$this->user = new \phpbb\user($this->lang, '\phpbb\datetime');
Expand Down Expand Up @@ -429,6 +436,19 @@ public function viewonline_data()
'phpbb_ideas_index_controller#a:0:{}',
'VIEWING_IDEAS',
),
// test a non-routing runtime exception is treated as an unmatched page
array(
array(
1 => 'index',
),
array(
'session_page' => 'index.' . $phpEx . '/runtime-error'
),
'$location_url',
'$location',
'$location_url',
'$location',
),
// test when viewing an idea topic (any topic in forum id 2)
array(
array(
Expand Down