1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-10-12 23:44:32 +02:00

Merge branch 'master' into ticket/17541

This commit is contained in:
Matt Friedman
2025-09-18 12:28:40 -07:00
50 changed files with 797 additions and 704 deletions

View File

@@ -23,6 +23,18 @@
<group>slow</group>
</exclude>
</groups>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">../phpBB/</directory>
<directory suffix=".php">../tests/</directory>
</include>
<exclude>
<directory suffix=".php">../phpBB/vendor/</directory>
<directory suffix=".php">../phpBB/cache/</directory>
<directory suffix=".php">../phpBB/develop/</directory>
<directory suffix=".php">../phpBB/store/</directory>
</exclude>
</source>
<php>
<server name="PHPBB_TEST_DBMS" value="mysqli"/>
<server name="PHPBB_TEST_DBHOST" value="0.0.0.0"/>

View File

@@ -23,6 +23,18 @@
<group>slow</group>
</exclude>
</groups>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">../phpBB/</directory>
<directory suffix=".php">../tests/</directory>
</include>
<exclude>
<directory suffix=".php">../phpBB/vendor/</directory>
<directory suffix=".php">../phpBB/cache/</directory>
<directory suffix=".php">../phpBB/develop/</directory>
<directory suffix=".php">../phpBB/store/</directory>
</exclude>
</source>
<php>
<server name="PHPBB_TEST_DBMS" value="phpbb\db\driver\mssqlnative"/>
<server name="PHPBB_TEST_DBHOST" value="127.0.0.1"/>

View File

@@ -23,6 +23,18 @@
<group>slow</group>
</exclude>
</groups>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">../phpBB/</directory>
<directory suffix=".php">../tests/</directory>
</include>
<exclude>
<directory suffix=".php">../phpBB/vendor/</directory>
<directory suffix=".php">../phpBB/cache/</directory>
<directory suffix=".php">../phpBB/develop/</directory>
<directory suffix=".php">../phpBB/store/</directory>
</exclude>
</source>
<php>
<server name="PHPBB_TEST_DBMS" value="phpbb\db\driver\mysqli"/>
<server name="PHPBB_TEST_DBHOST" value="0.0.0.0"/>

View File

@@ -23,6 +23,18 @@
<group>slow</group>
</exclude>
</groups>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">../phpBB/</directory>
<directory suffix=".php">../tests/</directory>
</include>
<exclude>
<directory suffix=".php">../phpBB/vendor/</directory>
<directory suffix=".php">../phpBB/cache/</directory>
<directory suffix=".php">../phpBB/develop/</directory>
<directory suffix=".php">../phpBB/store/</directory>
</exclude>
</source>
<php>
<server name="PHPBB_TEST_DBMS" value="phpbb\db\driver\postgres"/>
<server name="PHPBB_TEST_DBHOST" value="localhost"/>

View File

@@ -23,6 +23,18 @@
<group>slow</group>
</exclude>
</groups>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">../phpBB/</directory>
<directory suffix=".php">../tests/</directory>
</include>
<exclude>
<directory suffix=".php">../phpBB/vendor/</directory>
<directory suffix=".php">../phpBB/cache/</directory>
<directory suffix=".php">../phpBB/develop/</directory>
<directory suffix=".php">../phpBB/store/</directory>
</exclude>
</source>
<php>
<server name="PHPBB_TEST_DBMS" value="phpbb\db\driver\postgres"/>
<server name="PHPBB_TEST_DBHOST" value="localhost"/>

View File

@@ -23,6 +23,18 @@
<group>slow</group>
</exclude>
</groups>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">../phpBB/</directory>
<directory suffix=".php">../tests/</directory>
</include>
<exclude>
<directory suffix=".php">../phpBB/vendor/</directory>
<directory suffix=".php">../phpBB/cache/</directory>
<directory suffix=".php">../phpBB/develop/</directory>
<directory suffix=".php">../phpBB/store/</directory>
</exclude>
</source>
<php>
<server name="PHPBB_TEST_REDIS_HOST" value="0.0.0.0"/>
<server name="PHPBB_TEST_MEMCACHED_HOST" value="localhost"/>

View File

@@ -145,6 +145,10 @@ jobs:
db: "mysql:8.0"
- php: '8.4'
db: "mariadb:10.3"
- php: '8.5'
db: "mysql:8.0"
- php: '8.5'
db: "mariadb:10.3"
name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}
@@ -286,6 +290,8 @@ jobs:
db: "postgres:9.5"
- php: '8.4'
db: "postgres:9.5"
- php: '8.5'
db: "postgres:9.5"
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
@@ -495,11 +501,11 @@ jobs:
# Test with IIS & PostgreSQL on Windows
windows-tests:
runs-on: windows-latest
runs-on: windows-2025
strategy:
matrix:
type: ['unit', 'functional']
php: ['8.1', '8.2', '8.3']
php: ['8.4']
db: ['postgres']
name: Windows - ${{ matrix.type }} - PHP ${{ matrix.php }} - ${{ matrix.db }}
@@ -516,7 +522,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, intl, gd, exif, iconv, pgsql, pdo_pgsql, sodium
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, intl, gd, exif, iconv, pgsql, pdo_pgsql, sodium, bz2, fileinfo
ini-values: upload_tmp_dir=${{ runner.temp }}, sys_temp_dir=${{ runner.temp }}
coverage: none

Binary file not shown.

View File

@@ -34,7 +34,7 @@
"bantu/ini-get-wrapper": "~1.0",
"carlos-mg89/oauth": "^0.8.15",
"composer/composer": "^2.0",
"composer/installers": "^1.9",
"composer/installers": "^2.3",
"composer/package-versions-deprecated": "^1.11",
"doctrine/dbal": "^3.9",
"google/recaptcha": "~1.1",

1200
phpBB/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -763,8 +763,6 @@ function create_thumbnail($source, $destination, $mimetype)
imagewebp($new_image, $destination);
break;
}
imagedestroy($new_image);
}
else
{

View File

@@ -325,7 +325,7 @@ class recaptcha_v3 extends captcha_abstract
$token = $request->variable('recaptcha_token', '', true);
$action = $request->variable('recaptcha_action', '', true);
$action = in_array($action, self::$actions) ? $action : reset(self::$actions);
$threshold = (double) $config["recaptcha_v3_threshold_{$action}"] ?? 0.5;
$threshold = (float) $config["recaptcha_v3_threshold_{$action}"] ?? 0.5;
// No token was provided, discard spam submissions
if (empty($token))

View File

@@ -150,7 +150,18 @@ class connection_parameter_factory
if ($params['driver'] === 'pdo_mysql' && extension_loaded('pdo_mysql'))
{
$params[\PDO::MYSQL_ATTR_FOUND_ROWS] = true;
// Constant PDO::MYSQL_ATTR_FOUND_ROWS is deprecated since 8.5, use Pdo\Mysql::ATTR_FOUND_ROWS instead
if (class_exists('\Pdo\Mysql'))
{
/**
* @psalm-suppress UndefinedClass
*/
$params[\Pdo\Mysql::ATTR_FOUND_ROWS] = true;
}
else
{
$params[\PDO::MYSQL_ATTR_FOUND_ROWS] = true;
}
}
return $params;

View File

@@ -72,7 +72,7 @@ class rename_duplicated_index_names extends migration
}
return [
'rename_index' => self::$rename_index,
'rename_index' => self::$rename_index ?? [],
];
}

View File

@@ -386,7 +386,7 @@ class post extends \phpbb\notification\type\base
// Topics can be "read" before they are public (while awaiting approval).
// Make sure that if the user has read the topic, it's marked as read in the notification
if ($this->inherit_read_status && isset($pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time)
if ($this->inherit_read_status && isset($this->user_id, $pre_create_data[$this->user_id]) && $pre_create_data[$this->user_id] >= $this->notification_time)
{
$this->notification_read = true;
}

View File

@@ -1577,7 +1577,7 @@ class fulltext_native extends base implements search_backend_interface
// Remove common words
if ($this->config['num_posts'] >= 100 && $this->config['fulltext_native_common_thres'])
{
$common_threshold = ((double) $this->config['fulltext_native_common_thres']) / 100.0;
$common_threshold = ((float) $this->config['fulltext_native_common_thres']) / 100.0;
// First, get the IDs of common words
$sql = 'SELECT word_id, word_text
FROM ' . $this->search_wordlist_table . '
@@ -2034,14 +2034,14 @@ class fulltext_native extends base implements search_backend_interface
</dl>
<dl>
<dt><label for="fulltext_native_common_thres">' . $this->language->lang('COMMON_WORD_THRESHOLD') . $this->language->lang('COLON') . '</label><br /><span>' . $this->language->lang('COMMON_WORD_THRESHOLD_EXPLAIN') . '</span></dt>
<dd><input id="fulltext_native_common_thres" type="text" name="config[fulltext_native_common_thres]" value="' . (double) $this->config['fulltext_native_common_thres'] . '" /> %</dd>
<dd><input id="fulltext_native_common_thres" type="text" name="config[fulltext_native_common_thres]" value="' . (float) $this->config['fulltext_native_common_thres'] . '" /> %</dd>
</dl>
';
// These are fields required in the config table
return array(
'tpl' => $tpl,
'config' => array('fulltext_native_load_upd' => 'bool', 'fulltext_native_min_chars' => 'integer:0:255', 'fulltext_native_max_chars' => 'integer:0:255', 'fulltext_native_common_thres' => 'double:0:100')
'config' => array('fulltext_native_load_upd' => 'bool', 'fulltext_native_min_chars' => 'integer:0:255', 'fulltext_native_max_chars' => 'integer:0:255', 'fulltext_native_common_thres' => 'float:0:100')
);
}
}

View File

@@ -1715,7 +1715,7 @@ class session
{
global $db;
if (isset($this->data['session_time'], $this->data['user_id']))
if (isset($this->data['session_time'], $this->data['user_id']) && !$this->is_push_notification_request())
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_lastvisit = ' . (int) $this->data['session_time'] . ',
@@ -1734,7 +1734,7 @@ class session
{
global $db;
if (isset($this->time_now, $this->data['user_id']))
if (isset($this->time_now, $this->data['user_id']) && !$this->is_push_notification_request())
{
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_last_active = ' . $this->time_now . '
@@ -1742,4 +1742,16 @@ class session
$db->sql_query($sql);
}
}
/**
* Determine if the request is an Ajax request from the web push service worker
*
* @return bool True if the request is an Ajax request and the page URL contains '/push/notification', otherwise false
*/
protected function is_push_notification_request(): bool
{
global $request;
return $request->is_ajax() && str_contains($this->page['page'], '/push/notification');
}
}

View File

@@ -26,10 +26,16 @@
<group>slow</group>
</exclude>
</groups>
<source>
<source restrictDeprecations="true">
<include>
<directory suffix=".php">./phpBB/includes/</directory>
<directory suffix=".php">./phpBB/phpbb/</directory>
<directory suffix=".php">./phpBB/</directory>
<directory suffix=".php">./tests/</directory>
</include>
<exclude>
<directory suffix=".php">./phpBB/vendor/</directory>
<directory suffix=".php">./phpBB/cache/</directory>
<directory suffix=".php">./phpBB/develop/</directory>
<directory suffix=".php">./phpBB/store/</directory>
</exclude>
</source>
</phpunit>

View File

@@ -166,13 +166,11 @@ class phpbb_avatar_driver_gravatar_test extends \phpbb_database_test_case
->willReturn([]);
$requestInputReflection = new \ReflectionProperty($request, 'input');
$requestInputReflection->setAccessible(true);
$request_data[request_interface::GET] = $request_data[request_interface::GET] ?? [];
$request_data[request_interface::POST] = $request_data[request_interface::POST] ?? [];
$request_data[request_interface::REQUEST] = $request_data[request_interface::GET] + $request_data[request_interface::POST];
$requestInputReflection->setValue($request, $request_data);
$requestTypeCastHelperReflection = new \ReflectionProperty($request, 'type_cast_helper');
$requestTypeCastHelperReflection->setAccessible(true);
$requestTypeCastHelperReflection->setValue($request, new \phpbb\request\type_cast_helper());
$this->gravatar->prepare_form($request, $this->template, $this->user, $row, $error);

View File

@@ -411,7 +411,6 @@ class ban_manager_test extends \phpbb_session_test_case
$ban_type_ip_reflection = new \ReflectionClass($ban_type_ip);
$get_excluded_reflection = $ban_type_ip_reflection->getMethod('get_excluded');
$get_excluded_reflection->setAccessible(true);
$this->assertFalse($get_excluded_reflection->invoke($ban_type_ip));
}

View File

@@ -68,7 +68,6 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
$filename = "{$this->cache_dir}unreadable.$phpEx";
@chmod($filename, 0000);
$readReflection = new \ReflectionMethod($this->cache_file, '_read');
$readReflection->setAccessible(true);
$this->assertFalse($readReflection->invoke($this->cache_file, 'unreadable'));
@chmod($filename, 0600);
$this->assertNotFalse($readReflection->invoke($this->cache_file, 'unreadable'));
@@ -79,11 +78,9 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
global $phpEx;
$reflectionCacheVars = new \ReflectionProperty($this->cache_file, 'vars');
$reflectionCacheVars->setAccessible(true);
$reflectionCacheVars->setValue($this->cache_file, ['foo' => 'bar']);
$reflectionCacheVarExpires = new \ReflectionProperty($this->cache_file, 'var_expires');
$reflectionCacheVarExpires->setAccessible(true);
$reflectionCacheVarExpires->setValue($this->cache_file, ['foo' => time() + 86400]);
// Create file in invalid format
@@ -95,7 +92,6 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
file_put_contents($filename, $cache_data);
$readReflection = new \ReflectionMethod($this->cache_file, '_read');
$readReflection->setAccessible(true);
$this->assertFalse($readReflection->invoke($this->cache_file, 'data_global'));
}
@@ -104,11 +100,9 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
global $phpEx;
$reflectionCacheVars = new \ReflectionProperty($this->cache_file, 'vars');
$reflectionCacheVars->setAccessible(true);
$reflectionCacheVars->setValue($this->cache_file, ['foo' => 'bar']);
$reflectionCacheVarExpires = new \ReflectionProperty($this->cache_file, 'var_expires');
$reflectionCacheVarExpires->setAccessible(true);
$reflectionCacheVarExpires->setValue($this->cache_file, ['foo' => time() + 86400]);
// Create file in invalid format
@@ -120,7 +114,6 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
file_put_contents($filename, $cache_data);
$readReflection = new \ReflectionMethod($this->cache_file, '_read');
$readReflection->setAccessible(true);
$this->assertFalse($readReflection->invoke($this->cache_file, 'data_global'));
}
@@ -129,11 +122,9 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
global $phpEx;
$reflectionCacheVars = new \ReflectionProperty($this->cache_file, 'vars');
$reflectionCacheVars->setAccessible(true);
$reflectionCacheVars->setValue($this->cache_file, ['foo' => 'bar']);
$reflectionCacheVarExpires = new \ReflectionProperty($this->cache_file, 'var_expires');
$reflectionCacheVarExpires->setAccessible(true);
$reflectionCacheVarExpires->setValue($this->cache_file, ['foo' => time() + 86400]);
// Create file in invalid format
@@ -145,18 +136,15 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
file_put_contents($filename, $cache_data);
$readReflection = new \ReflectionMethod($this->cache_file, '_read');
$readReflection->setAccessible(true);
$this->assertFalse($readReflection->invoke($this->cache_file, 'data_global'));
}
public function test_read_data_global_expired()
{
$reflectionCacheVars = new \ReflectionProperty($this->cache_file, 'vars');
$reflectionCacheVars->setAccessible(true);
$reflectionCacheVars->setValue($this->cache_file, ['foo' => 'bar']);
$reflectionCacheVarExpires = new \ReflectionProperty($this->cache_file, 'var_expires');
$reflectionCacheVarExpires->setAccessible(true);
$reflectionCacheVarExpires->setValue($this->cache_file, ['foo' => time() - 86400]);
// Create file in invalid format
@@ -167,7 +155,6 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
$reflectionCacheVarExpires->setValue($this->cache_file, []);
$readReflection = new \ReflectionMethod($this->cache_file, '_read');
$readReflection->setAccessible(true);
$this->assertTrue($readReflection->invoke($this->cache_file, 'data_global'));
// Check data, should be empty
@@ -177,12 +164,10 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
public function test_read_data_global()
{
$reflectionCacheVars = new \ReflectionProperty($this->cache_file, 'vars');
$reflectionCacheVars->setAccessible(true);
$expectedVars = ['foo' => 'bar'];
$reflectionCacheVars->setValue($this->cache_file, $expectedVars);
$reflectionCacheVarExpires = new \ReflectionProperty($this->cache_file, 'var_expires');
$reflectionCacheVarExpires->setAccessible(true);
$expectedVarExpires = ['foo' => time() + 86400];
$reflectionCacheVarExpires->setValue($this->cache_file, $expectedVarExpires);
@@ -196,7 +181,6 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
$this->assertEquals([], $reflectionCacheVarExpires->getValue($this->cache_file));
$readReflection = new \ReflectionMethod($this->cache_file, '_read');
$readReflection->setAccessible(true);
$this->assertTrue($readReflection->invoke($this->cache_file, 'data_global'));
// Check data, should be empty

View File

@@ -244,7 +244,6 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
{
$this->turnstile->set_name('custom_service');
$service_name_property = new \ReflectionProperty($this->turnstile, 'service_name');
$service_name_property->setAccessible(true);
$this->assertEquals('custom_service', $service_name_property->getValue($this->turnstile));
}
@@ -275,7 +274,6 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
// Use reflection to inject the mocked client into the turnstile class
$reflection = new \ReflectionClass($this->turnstile);
$client_property = $reflection->getProperty('client');
$client_property->setAccessible(true);
$client_property->setValue($this->turnstile, $client_mock);
// Validate that the CAPTCHA was solved successfully
@@ -301,7 +299,6 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
// Use reflection to inject the mocked client into the turnstile class
$reflection = new \ReflectionClass($this->turnstile);
$client_property = $reflection->getProperty('client');
$client_property->setAccessible(true);
$client_property->setValue($this->turnstile, $client_mock);
// Validatation fails due to guzzle exception
@@ -333,9 +330,7 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
{
$turnstile_reflection = new \ReflectionClass($this->turnstile);
$get_client_method = $turnstile_reflection->getMethod('get_client');
$get_client_method->setAccessible(true);
$client_property = $turnstile_reflection->getProperty('client');
$client_property->setAccessible(true);
$this->assertFalse($client_property->isInitialized($this->turnstile));
$client = $get_client_method->invoke($this->turnstile);
@@ -363,7 +358,6 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
// Use reflection to inject the mocked client into the turnstile class
$reflection = new \ReflectionClass($this->turnstile);
$client_property = $reflection->getProperty('client');
$client_property->setAccessible(true);
$client_property->setValue($this->turnstile, $client_mock);
// Validate that the CAPTCHA was not solved
@@ -374,7 +368,6 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
{
// Mock is_solved to return false
$is_solved_property = new \ReflectionProperty($this->turnstile, 'solved');
$is_solved_property->setAccessible(true);
$is_solved_property->setValue($this->turnstile, false);
// Mock the template assignments

View File

@@ -97,11 +97,21 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
{
parent::tearDown();
unlink($this->phpbb_root_path . 'files/test_png_1');
unlink($this->phpbb_root_path . 'files/test_png_2');
unlink($this->phpbb_root_path . 'files/test_txt');
unlink($this->phpbb_root_path . 'files/thumb_test_png_1');
unlink($this->phpbb_root_path . 'files/thumb_test_png_2');
$delete_files = [
$this->phpbb_root_path . 'files/test_png_1',
$this->phpbb_root_path . 'files/test_png_2',
$this->phpbb_root_path . 'files/test_txt',
$this->phpbb_root_path . 'files/thumb_test_png_1',
$this->phpbb_root_path . 'files/thumb_test_png_2'
];
foreach ($delete_files as $file)
{
if (file_exists($file))
{
unlink($file);
}
}
}
public function test_thumbnails()

View File

@@ -32,11 +32,9 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
$reflection_class = new ReflectionClass('\phpbb\language\language');
// Set default language files loaded flag to true
$common_language_files_loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
$common_language_files_loaded_flag->setAccessible(true);
$common_language_files_loaded_flag->setValue($this->lang, true);
// Set up test language data
$lang_array = $reflection_class->getProperty('lang');
$lang_array->setAccessible(true);
$lang_array->setValue($this->lang, [
'datetime' => [
'TODAY' => 'Today',

View File

@@ -509,7 +509,6 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
if ($this->tools instanceof \phpbb\db\tools\mssql)
{
$max_length_method = new ReflectionMethod('\phpbb\db\tools\mssql', 'get_max_index_name_length');
$max_length_method->setAccessible(true);
$max_index_length = $max_length_method->invoke($this->tools);
}

View File

@@ -146,7 +146,6 @@ class phpbb_email_parsing_test extends phpbb_test_case
$reflection = new ReflectionObject($this->email);
$this->reflection_template_property = $reflection->getProperty('template');
$this->reflection_template_property->setAccessible(true);
}
public static function email_parsing_data()

View File

@@ -27,7 +27,6 @@ class phpbb_extension_extension_base_test extends phpbb_test_case
$reflection_class = new ReflectionClass('\phpbb\extension\base');
self::$reflection_method_get_migration_file_list = $reflection_class->getMethod('get_migration_file_list');
self::$reflection_method_get_migration_file_list->setAccessible(true);
}
protected function setUp(): void

View File

@@ -146,7 +146,6 @@ class phpbb_files_types_local_test extends phpbb_test_case
'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(),
)));
$filespec_local = new ReflectionProperty($filespec, 'local');
$filespec_local->setAccessible(true);
$filespec_local->setValue($filespec, true);
$this->container->set('files.filespec', $filespec);
$this->factory = new \phpbb\files\factory($this->container);

View File

@@ -76,7 +76,6 @@ class phpbb_files_upload_test extends phpbb_test_case
{
$upload = new \phpbb\files\upload($this->factory, $this->language, $this->php_ini, $this->request);
$disallowed_content = new ReflectionProperty($upload, 'disallowed_content');
$disallowed_content->setAccessible(true);
$upload->set_disallowed_content(array('foo'));
$this->assertEquals(array('foo'), $disallowed_content->getValue($upload));

View File

@@ -22,7 +22,6 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
parent::setUpBeforeClass();
self::$filesystem_helper_phpbb_own_realpath = new ReflectionMethod('\phpbb\filesystem\helper', 'phpbb_own_realpath');
self::$filesystem_helper_phpbb_own_realpath->setAccessible(true);
}
protected function setUp(): void

View File

@@ -24,7 +24,6 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case
$reflection_class = new ReflectionClass('\phpbb\filesystem\filesystem');
self::$filesystem_own_realpath = $reflection_class->getMethod('phpbb_own_realpath');
self::$filesystem_own_realpath->setAccessible(true);
}
protected function setUp(): void

View File

@@ -300,41 +300,33 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&start=' . $i * 20 . '&mode=catalog&sid=' . $this->sid);
}
$extension_filter($crawler, 'Scroll Page', $scrollpage_install_link);
$extension_filter($crawler, 'Scroll To Top', $scrolltotop_install_link);
$extension_filter($crawler, 'VigLink', $viglink_install_link);
}
if (!isset($scrolltotop_install_link) || !isset($scrollpage_install_link))
if (!isset($viglink_install_link))
{
$this->fail('Failed acquiring install links for test extensions');
}
// Attempt to install vse/scrollpage extension
$crawler = self::$client->click($scrollpage_install_link);
// Attempt to install phpbb/viglink extension
$crawler = self::$client->click($viglink_install_link);
$this->assertContainsLang('EXTENSIONS_INSTALLED', $crawler->filter('.successbox > p')->text());
// Assert there's console log output
$this->assertStringContainsString('Locking vse/scrollpage', $crawler->filter('.console-output > pre')->text());
// Attempt to install vse/scrolltotop extension
$crawler = self::$client->click($scrolltotop_install_link);
$this->assertContainsLang('EXTENSIONS_INSTALLED', $crawler->filter('.successbox > p')->text());
// Assert there's console log output
$this->assertStringContainsString('Locking vse/scrolltotop', $crawler->filter('.console-output > pre')->text());
$this->assertStringContainsString('Locking phpbb/viglink', $crawler->filter('.console-output > pre')->text());
// Ensure installed extension appears in available extensions list
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertStringContainsString('Scroll To Top', $crawler->filter('strong[title="vse/scrolltotop"]')->text());
$this->assertStringContainsString('Scroll Page', $crawler->filter('strong[title="vse/scrollpage"]')->text());
$this->assertStringContainsString('VigLink', $crawler->filter('strong[title="phpbb/viglink"]')->text());
}
public function test_extensions_catalog_updating_extension()
{
// Enable 'Scroll Page' extension installed earlier
// Enable 'VigLink' extension installed earlier
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$extension_enable_link = $crawler->filter('tr')->reduce(
function ($node, $i)
{
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
return (bool) (strpos($node->text(), 'VigLink') !== false);
}
)->selectLink($this->lang('EXTENSION_ENABLE'))->link();
$crawler = self::$client->click($extension_enable_link);
@@ -342,22 +334,22 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text());
// Update 'Scroll Page' enabled extension
// Update 'VigLink' enabled extension
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$scrollpage_update_link = $crawler->filter('tr')->reduce(
$viglink_update_link = $crawler->filter('tr')->reduce(
function ($node, $i)
{
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
return (bool) (strpos($node->text(), 'VigLink') !== false);
}
)->selectLink($this->lang('EXTENSION_UPDATE'))->link();
$crawler = self::$client->click($scrollpage_update_link);
$crawler = self::$client->click($viglink_update_link);
$this->assertContainsLang('EXTENSIONS_UPDATED', $crawler->filter('.successbox > p')->text());
// Assert there's console log output
$this->assertStringContainsString('Updating packages', $crawler->filter('.console-output > pre')->text());
// Ensure installed extension still appears in available extensions list
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertStringContainsString('Scroll Page', $crawler->filter('strong[title="vse/scrollpage"]')->text());
$this->assertStringContainsString('VigLink', $crawler->filter('strong[title="phpbb/viglink"]')->text());
}
public function test_extensions_catalog_removing_extension()
@@ -365,36 +357,22 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
// Check if both enabled and disabled extensions have 'Remove' action available
$scrollpage_remove_link = $crawler->filter('tr')->reduce(
$viglink_remove_link = $crawler->filter('tr')->reduce(
function ($node, $i)
{
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
}
)->selectLink($this->lang('EXTENSION_REMOVE'))->link();
$scrolltotop_remove_link = $crawler->filter('tr')->reduce(
function ($node, $i)
{
return (bool) (strpos($node->text(), 'Scroll To Top') !== false);
return (bool) (strpos($node->text(), 'VigLink') !== false);
}
)->selectLink($this->lang('EXTENSION_REMOVE'))->link();
// Test extensions removal
// Remove 'Scroll Page' enabled extension
$crawler = self::$client->click($scrollpage_remove_link);
// Remove 'VigLink' enabled extension
$crawler = self::$client->click($viglink_remove_link);
$this->assertContainsLang('EXTENSIONS_REMOVED', $crawler->filter('.successbox > p')->text());
// Assert there's console log output
$this->assertStringContainsString('Removing vse/scrollpage', $crawler->filter('.console-output > pre')->text());
// Remove 'Scroll To Top' disabled extension
$crawler = self::$client->click($scrolltotop_remove_link);
$this->assertContainsLang('EXTENSIONS_REMOVED', $crawler->filter('.successbox > p')->text());
// Assert there's console log output
$this->assertStringContainsString('Removing vse/scrolltotop', $crawler->filter('.console-output > pre')->text());
$this->assertStringContainsString('Removing phpbb/viglink', $crawler->filter('.console-output > pre')->text());
// Ensure removed extensions do not appear in available extensions list
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertStringNotContainsString('Scroll Page', $this->get_content());
$this->assertStringNotContainsString('Scroll To Top', $this->get_content());
self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertStringNotContainsString('VigLink', $this->get_content());
}
}

View File

@@ -40,7 +40,7 @@
<value>2</value>
<value>897a897b797c8789997d7979879</value>
<value>auth.provider.oauth.service.google</value>
<value>{"accessToken":"ya29.YPHwCWVkrvwu1kgbYKiDNYaQ451ZuHy9OEQAGVME8if-WBzR-v7a9ftxbx41kaL)5VLEXB-6qJEvri","endOfLife":1429959670,"extraParams":{"token_type":"Bearer","id_token":"eyJhbGciOiJSUzI1NiIsImupZCI6IjE0YuRjNzc2MDQwYjUyNDZmNTI5OWFkZDVlMmQ1NWNOPTdjMDdlZTAifQ.eyJpc3MiOiJhY2NvdW90cy5nb78nbGUuY29tIiwic3ViIjoiMTExMDMwNwerNjM4MTM5NTQwMTM1IiwiYXpwIjoiOTk3MzUwMTY0NzE0LWhwOXJrYjZpcjM4MW80YjV1NjRpaGtmM29zMnRvbWxhLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZW1haWwiOiJtYXJjLmFsZXhhbmRlci4zN0BnbWFpbC5jb20iLCJhdF9oYXNoIjoiWHk2b1JabnVZUWRfRTZDeDV0RkItdyIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdWQiOiI5OTczNTAxNjQ3MTQtaHA5cmtiNmlyMzgxbzRiNXU2NGloa2Yzb3MydG9tbGEuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJpYXQiOjE0Mjk5NTYwNzEsImV4cCI6MTQyOTk1OTY3MX0.C5gfSzjqwlRRvVMuTP6jfWIuEHMXn55oYHsSA3eh97n2BZL0TZHhUm4K206Fgucd6ufAphan4l0J7y6tMAHLZPr-kk6KDINxWnPG-up99reblGutay0lRYjMCcrhJAOql8EI1bi84GyliZFYHL67pE0ZtSf-CMb1CeH18TFe-Fk"},"refreshToken":null,"token_class":"OAuth\\\\OAuth2\\\\Token\\\\StdOAuth2Token"}</value>
<value>{"accessToken":"ya29.YPHwCWVkrvwu1kgbYKiDNYaQ451ZuHy9OEQAGVME8if-WBzR-v7a9ftxbx41kaL)5VLEXB-6qJEvri","endOfLife":1429959670,"extraParams":{"token_type":"Bearer","id_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30"},"refreshToken":null,"token_class":"OAuth\\\\OAuth2\\\\Token\\\\StdOAuth2Token"}</value>
</row>
</table>
</dataset>

View File

@@ -87,12 +87,10 @@ class phpbb_group_helper_test_case extends phpbb_test_case
// Set default language files loaded flag to true
$loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
$loaded_flag->setAccessible(true);
$loaded_flag->setValue($lang, true);
// Set up test language data
$lang_array = $reflection_class->getProperty('lang');
$lang_array->setAccessible(true);
$lang_array->setValue($lang, $this->get_test_language_data_set());
// Set up event dispatcher

View File

@@ -30,12 +30,10 @@ class phpbb_language_test extends phpbb_test_case
// Set default language files loaded flag to true
$loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
$loaded_flag->setAccessible(true);
$loaded_flag->setValue($this->lang, true);
// Set up test language data
$lang_array = $reflection_class->getProperty('lang');
$lang_array->setAccessible(true);
$lang_array->setValue($this->lang, $this->get_test_data_set());
}

View File

@@ -52,12 +52,12 @@ class lint_test extends phpbb_test_case
$this->assertEquals(0, $status, "PHP lint failed for $path:\n$output");
}
public function lint_data()
public static function lint_data(): array
{
return $this->check(__DIR__ . '/..');
return self::check(__DIR__ . '/..');
}
protected function check($root)
protected static function check($root): array
{
$files = array();
$dh = opendir($root);
@@ -92,7 +92,7 @@ class lint_test extends phpbb_test_case
__DIR__ . '/../node_modules',
)))
{
$files = array_merge($files, $this->check($path));
$files = array_merge($files, self::check($path));
}
else if (substr($filename, strlen($filename)-4) == '.php')
{

View File

@@ -191,7 +191,6 @@ class phpbb_messenger_queue_test extends phpbb_test_case
$filesystem->method('phpbb_chmod')
->will($this->throwException(new filesystem_exception('Chmod failed')));
$filesystem_reflection = new \ReflectionProperty(queue::class, 'filesystem');
$filesystem_reflection->setAccessible(true);
$filesystem_reflection->setValue($this->messenger_queue, $filesystem);
// Process the queue
@@ -312,7 +311,6 @@ class phpbb_messenger_queue_test extends phpbb_test_case
$filesystem->method('phpbb_chmod')
->will($this->throwException(new filesystem_exception('Chmod failed')));
$filesystem_reflection = new \ReflectionProperty(queue::class, 'filesystem');
$filesystem_reflection->setAccessible(true);
$filesystem_reflection->setValue($this->messenger_queue, $filesystem);
$this->messenger_queue->save();

View File

@@ -137,7 +137,6 @@ class get_callable_from_step_test extends phpbb_database_test_case
{
$class = new ReflectionClass($this->migrator);
$method = $class->getMethod('get_callable_from_step');
$method->setAccessible(true);
return $method->invokeArgs($this->migrator, array($step));
}
}

View File

@@ -22,8 +22,15 @@ class phpbb_mock_event_dispatcher extends \phpbb\event\dispatcher
{
}
public function trigger_event($eventName, $data = array())
public function trigger_event($eventName, $data = array()): array
{
return array();
$data = (array) $data;
if ($eventName === 'core.exit_handler')
{
$data['exit_handler_override'] = true;
}
return $data;
}
}

View File

@@ -126,7 +126,6 @@ class notification_method_email_test extends phpbb_tests_notification_base
$class = new ReflectionClass($notification_method_email);
$empty_queue_method = $class->getMethod('empty_queue');
$empty_queue_method->setAccessible(true);
$this->notification_method_email->method('notify_using_messenger')
->will($this->returnCallback(function () use ($notification_method_email, $empty_queue_method) {

View File

@@ -680,7 +680,6 @@ class notification_method_webpush_test extends phpbb_tests_notification_base
public function test_set_endpoint_padding($endpoint, $expected_padding): void
{
$web_push_reflection = new \ReflectionMethod($this->notification_method_webpush, 'set_endpoint_padding');
$web_push_reflection->setAccessible(true);
$auth = [
'VAPID' => [

View File

@@ -187,7 +187,7 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
public function is_set_callback($field_id, $lang_id, $field_value)
{
return isset($this->options[$field_value]);
return isset($field_value, $this->options[$field_value]);
}
public function get($field_id, $lang_id, $field_value)

View File

@@ -225,7 +225,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
public function is_set_callback($field_id, $lang_id, $field_value)
{
return isset($this->dropdown_options[$field_value]);
return isset($field_value, $this->dropdown_options[$field_value]);
}
public function get($field_id, $lang_id, $field_value)

View File

@@ -84,7 +84,6 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
$class = new ReflectionClass('\phpbb\avatar\manager');
$enabled_drivers = $class->getProperty('enabled_drivers');
$enabled_drivers->setAccessible(true);
$enabled_drivers->setValue($class, false);
$avatar_helper = new phpbb\avatar\helper(
$config,

View File

@@ -35,7 +35,6 @@ class phpbb_template_template_test_case extends phpbb_test_case
$reflection = new ReflectionClass('\phpbb\language\language');
self::$language_reflection_lang = $reflection->getProperty('lang');
self::$language_reflection_lang->setAccessible(true);
}
protected function display($handle)

View File

@@ -128,7 +128,6 @@ class twig_test extends \phpbb_test_case
// Get loader instance
$template_reflection = new \ReflectionObject($this->template);
$loader_reflection = $template_reflection->getProperty('loader');
$loader_reflection->setAccessible(true);
/** @var \phpbb\template\twig\loader $loader */
$loader = $loader_reflection->getValue($this->template);

View File

@@ -74,7 +74,6 @@ class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_base
// Call reparse_record via reflection
$reparser = $this->get_reparser();
$reparser_reflection = new \ReflectionMethod($reparser, 'reparse_record');
$reparser_reflection->setAccessible(true);
$reparser_reflection->invoke($reparser, $record);
// Retrieve reparsed post text and compare with expectec

View File

@@ -27,7 +27,6 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t
$reflection_reparser = new ReflectionClass(get_class($reparser));
$table_property = $reflection_reparser->getProperty('table');
$table_property->setAccessible(true);
$sql = 'SELECT ' . $columns['id'] . ' AS id, ' . $columns['text'] . ' AS text
FROM ' . $table_property->getValue($reparser) . '

View File

@@ -422,7 +422,6 @@ class test_ucp_controller_webpush_test extends phpbb_database_test_case
$this->expectExceptionMessage('FORM_INVALID');
$check_subscribe_reflection = new ReflectionMethod($this->controller, 'check_subscribe_requests');
$check_subscribe_reflection->setAccessible(true);
$check_subscribe_reflection->invoke($this->controller);
}
@@ -436,7 +435,6 @@ class test_ucp_controller_webpush_test extends phpbb_database_test_case
$this->expectExceptionMessage('NO_AUTH_OPERATION');
$check_subscribe_reflection = new ReflectionMethod($this->controller, 'check_subscribe_requests');
$check_subscribe_reflection->setAccessible(true);
$check_subscribe_reflection->invoke($this->controller);
}

View File

@@ -83,7 +83,6 @@ class phpbb_filespec_test extends phpbb_test_case
private function set_reflection_property($class, $property_name, $value)
{
$property = new ReflectionProperty($class, $property_name);
$property->setAccessible(true);
$property->setValue($class, $value);
}
@@ -538,7 +537,6 @@ class phpbb_filespec_test extends phpbb_test_case
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, new \bantu\IniGetWrapper\IniGetWrapper, new \FastImageSize\FastImageSize(), $this->phpbb_root_path, null);
$reflection_filespec = new ReflectionClass($filespec);
$plupload_property = $reflection_filespec->getProperty('plupload');
$plupload_property->setAccessible(true);
$plupload_mock = $this->getMockBuilder('\phpbb\plupload\plupload')
->disableOriginalConstructor()
->getMock();