mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
Merge branch '3.3.x'
This commit is contained in:
commit
6fe2012bf8
4 changed files with 71 additions and 2 deletions
|
@ -9,6 +9,7 @@ services:
|
|||
arguments:
|
||||
- '@template'
|
||||
- '@language'
|
||||
- '@user'
|
||||
- '%debug.exceptions%'
|
||||
tags:
|
||||
- { name: kernel.event_subscriber }
|
||||
|
|
|
@ -44,6 +44,13 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
|||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* User object
|
||||
*
|
||||
* @var \phpbb\user
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/** @var \phpbb\request\type_cast_helper */
|
||||
protected $type_caster;
|
||||
|
||||
|
@ -52,13 +59,15 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
|||
*
|
||||
* @param \phpbb\template\template $template Template object
|
||||
* @param \phpbb\language\language $language Language object
|
||||
* @param \phpbb\user $user User object
|
||||
* @param bool $debug Set to true to show full exception messages
|
||||
*/
|
||||
public function __construct(\phpbb\template\template $template, \phpbb\language\language $language, $debug = false)
|
||||
public function __construct(\phpbb\template\template $template, \phpbb\language\language $language, \phpbb\user $user, $debug = false)
|
||||
{
|
||||
$this->debug = $debug || defined('DEBUG');
|
||||
$this->template = $template;
|
||||
$this->language = $language;
|
||||
$this->user = $user;
|
||||
$this->type_caster = new \phpbb\request\type_cast_helper();
|
||||
}
|
||||
|
||||
|
@ -81,6 +90,9 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
|||
}
|
||||
else if (!$this->debug && $exception instanceof NotFoundHttpException)
|
||||
{
|
||||
// Do not update user session page if it does not exist
|
||||
$this->user->update_session_page = false;
|
||||
|
||||
$message = $this->language->lang('PAGE_NOT_FOUND');
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,9 @@ class exception_listener extends phpbb_test_case
|
|||
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$lang = new \phpbb\language\language($lang_loader);
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
|
||||
$exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $lang);
|
||||
$exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $lang, $user);
|
||||
|
||||
$event = new \Symfony\Component\HttpKernel\Event\ExceptionEvent($this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
$exception_listener->on_kernel_exception($event);
|
||||
|
|
55
tests/functional/session_page_update_test.php
Normal file
55
tests/functional/session_page_update_test.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
|
||||
class phpbb_functional_session_page_update_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected function test_session_page_update()
|
||||
{
|
||||
$this->login();
|
||||
$db = $this->get_db();
|
||||
|
||||
if (!function_exists('utf_clean_string'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
|
||||
}
|
||||
if (!function_exists('user_get_id_name'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
|
||||
}
|
||||
|
||||
$user_ids = [];
|
||||
$username = [$this->get_logged_in_user()];
|
||||
user_get_id_name($user_ids, $username);
|
||||
$user_id = (int) $user_ids[0];
|
||||
|
||||
// Request index page
|
||||
self::request('GET', 'index.php');
|
||||
$this->assertEquals(200, self::$client->getResponse()->getStatus());
|
||||
|
||||
$sql = 'SELECT session_page FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = ' . $user_id . ' ORDER BY session_time DESC';
|
||||
$db->sql_query_limit($sql, 1);
|
||||
$this->assertEquals('index.php', $db->sql_fetchfield('session_page'));
|
||||
|
||||
// Request non-existent url
|
||||
self::request('GET', 'nonexistent.jpg');
|
||||
$this->assertEquals(404, self::$client->getResponse()->getStatus());
|
||||
|
||||
$db->sql_query_limit($sql, 1);
|
||||
// User page should not be updated to non-existent one
|
||||
$this->assertEquals('index.php', $db->sql_fetchfield('session_page'));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue