1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 00:37:42 +02:00

[ticket/17535] Address code review comments

PHPBB-17535
This commit is contained in:
rxu
2025-07-28 22:51:14 +07:00
parent 788e408ceb
commit 7056bcba91
6 changed files with 30 additions and 42 deletions

View File

@@ -31,32 +31,32 @@ abstract class base implements \phpbb\cache\driver\driver_interface
try try
{ {
$iterator = new \DirectoryIterator($this->cache_dir); $iterator = new \DirectoryIterator($this->cache_dir);
foreach ($iterator as $fileInfo)
{
if ($fileInfo->isDot())
{
continue;
}
$filename = $fileInfo->getFilename();
if ($fileInfo->isDir())
{
$this->remove_dir($fileInfo->getPathname());
}
else if (strpos($filename, 'container_') === 0 ||
strpos($filename, 'autoload_') === 0 ||
strpos($filename, 'url_matcher') === 0 ||
strpos($filename, 'url_generator') === 0 ||
strpos($filename, 'sql_') === 0 ||
strpos($filename, 'data_') === 0)
{
$this->remove_file($fileInfo->getPathname());
}
}
} }
catch (\Exception $e) catch (\Exception $e)
{ {
return; // Do not return, to purge vars cached in memory
}
foreach ($iterator as $fileInfo)
{
if ($fileInfo->isDot())
{
continue;
}
$filename = $fileInfo->getFilename();
if ($fileInfo->isDir())
{
$this->remove_dir($fileInfo->getPathname());
}
else if (strpos($filename, 'container_') === 0 ||
strpos($filename, 'autoload_') === 0 ||
strpos($filename, 'url_matcher') === 0 ||
strpos($filename, 'url_generator') === 0 ||
strpos($filename, 'sql_') === 0 ||
strpos($filename, 'data_') === 0)
{
$this->remove_file($fileInfo->getPathname());
}
} }
unset($this->vars); unset($this->vars);

View File

@@ -50,18 +50,7 @@ abstract class memory extends \phpbb\cache\driver\base
*/ */
function purge() function purge()
{ {
unset($this->vars); parent::purge();
unset($this->sql_rowset);
unset($this->sql_row_pointer);
if (function_exists('opcache_reset'))
{
@opcache_reset();
}
$this->vars = [];
$this->sql_rowset = [];
$this->sql_row_pointer = [];
$this->is_modified = true; $this->is_modified = true;

View File

@@ -74,10 +74,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
->will($this->returnValue(true)); ->will($this->returnValue(true));
$this->request->expects($this->exactly(2)) $this->request->expects($this->exactly(2))
->method('server') ->method('server')
->willReturnCallback(fn(string $arg) => match(true) { ->willReturnMap([
$arg === 'PHP_AUTH_USER' => 'foobar', ['PHP_AUTH_USER', 'foobar'],
$arg === 'PHP_AUTH_PW' => 'example', ['PHP_AUTH_PW', 'example']
}); ]);
$expected = array( $expected = array(
'status' => LOGIN_SUCCESS, 'status' => LOGIN_SUCCESS,

View File

@@ -35,7 +35,7 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case
if ($db->get_sql_layer() === 'mysqli') if ($db->get_sql_layer() === 'mysqli')
{ {
$this->setExpectedTriggerError(E_WARNING); $this->setExpectedTriggerError(E_WARNING);
} }
else if ($db->get_sql_layer() !== 'sqlite3') else if ($db->get_sql_layer() !== 'sqlite3')
{ {

View File

@@ -255,7 +255,6 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$form = $crawler->selectButton('Submit')->form(); $form = $crawler->selectButton('Submit')->form();
$form['minimum_stability']->select('dev'); $form['minimum_stability']->select('dev');
$form['enable_packagist']->select('1');
$form['repositories'] = 'https://satis.phpbb.com/'; $form['repositories'] = 'https://satis.phpbb.com/';
$crawler = self::submit($form); $crawler = self::submit($form);
$this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text()); $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text());

View File

@@ -61,7 +61,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case
$user->style = array('style_id' => 1); $user->style = array('style_id' => 1);
$user->expects($this->any()) $user->expects($this->any())
-> method('__get')->with('lang')->willReturn([ ->method('__get')->with('lang')->willReturn([
'NO_POLL_TITLE' => 'You have to enter a poll title.', 'NO_POLL_TITLE' => 'You have to enter a poll title.',
'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.', 'POLL_TITLE_TOO_LONG' => 'The poll title must contain fewer than 100 characters.',
'POLL_TITLE_COMP_TOO_LONG' => 'The parsed size of your poll title is too large, consider removing BBCodes or smilies.', 'POLL_TITLE_COMP_TOO_LONG' => 'The parsed size of your poll title is too large, consider removing BBCodes or smilies.',