Merge pull request #6087 from rxu/ticket/16649

[ticket/16649] Upgrade to Symfony 5
This commit is contained in:
Marc Alexander 2021-02-25 19:55:03 +01:00 committed by GitHub
commit fade5e08f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
89 changed files with 2949 additions and 1217 deletions

View file

@ -156,4 +156,4 @@ if (@is_file($phpbb_root_path . $config['exts_composer_vendor_dir'] . '/autoload
* @event core.common * @event core.common
* @since 3.1.0-a1 * @since 3.1.0-a1
*/ */
$phpbb_dispatcher->dispatch('core.common'); $phpbb_dispatcher->trigger_event('core.common');

View file

@ -41,32 +41,33 @@
"marc1706/fast-image-size": "^1.1", "marc1706/fast-image-size": "^1.1",
"patchwork/utf8": "^1.1", "patchwork/utf8": "^1.1",
"s9e/text-formatter": "^2.0", "s9e/text-formatter": "^2.0",
"symfony/config": "~3.4", "symfony/config": "~5.2",
"symfony/console": "~3.4", "symfony/console": "~5.2",
"symfony/debug": "~3.4", "symfony/debug": "~4.4",
"symfony/dependency-injection": "~3.4", "symfony/dependency-injection": "~5.2",
"symfony/event-dispatcher": "~3.4", "symfony/event-dispatcher": "~5.2",
"symfony/filesystem": "~3.4", "symfony/filesystem": "~5.2",
"symfony/finder": "~3.4", "symfony/finder": "~5.2",
"symfony/http-foundation": "~3.4", "symfony/http-foundation": "~5.2",
"symfony/http-kernel": "~3.4", "symfony/http-kernel": "~5.2",
"symfony/process": "^3.4", "symfony/mime": "~5.2",
"symfony/proxy-manager-bridge": "~3.4", "symfony/process": "^5.2",
"symfony/routing": "~3.4", "symfony/proxy-manager-bridge": "~5.2",
"symfony/twig-bridge": "~3.4", "symfony/routing": "~5.2",
"symfony/yaml": "~3.4", "symfony/twig-bridge": "~5.2",
"symfony/yaml": "~5.2",
"twig/twig": "^1.0 || ^2.0" "twig/twig": "^1.0 || ^2.0"
}, },
"require-dev": { "require-dev": {
"fabpot/goutte": "~3.2", "fabpot/goutte": "~3.2",
"laravel/homestead": "~7.0", "laravel/homestead": "~10.17",
"misantron/dbunit": "~5.0",
"phing/phing": "~2.4", "phing/phing": "~2.4",
"phpunit/dbunit": "~4.0", "phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "~3.4", "squizlabs/php_codesniffer": "~3.4",
"symfony/browser-kit": "~3.4", "symfony/browser-kit": "~5.2",
"symfony/css-selector": "~3.4", "symfony/css-selector": "~5.2",
"symfony/dom-crawler": "~3.4" "symfony/dom-crawler": "~5.2"
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {

3406
phpBB/composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,12 +7,12 @@ services:
- { name: service_collection, tag: mimetype.guessers } - { name: service_collection, tag: mimetype.guessers }
mimetype.fileinfo_mimetype_guesser: mimetype.fileinfo_mimetype_guesser:
class: Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser class: Symfony\Component\Mime\FileinfoMimeTypeGuesser
tags: tags:
- { name: mimetype.guessers } - { name: mimetype.guessers }
mimetype.filebinary_mimetype_guesser: mimetype.filebinary_mimetype_guesser:
class: Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser class: Symfony\Component\Mime\FileBinaryMimeTypeGuesser
tags: tags:
- { name: mimetype.guessers } - { name: mimetype.guessers }

View file

@ -147,7 +147,7 @@
<li>Oracle</li> <li>Oracle</li>
</ul> </ul>
</li> </li>
<li><strong>PHP 7.1.3+</strong> up to and including <strong>PHP 7.4</strong> with support for the database you intend to use.</li> <li><strong>PHP 7.3.0+</strong> with support for the database you intend to use.</li>
<li>The following PHP modules are required: <li>The following PHP modules are required:
<ul> <ul>
<li>json</li> <li>json</li>

View file

@ -484,7 +484,7 @@ class acp_main
* @event core.acp_main_notice * @event core.acp_main_notice
* @since 3.1.0-RC3 * @since 3.1.0-RC3
*/ */
$phpbb_dispatcher->dispatch('core.acp_main_notice'); $phpbb_dispatcher->trigger_event('core.acp_main_notice');
// Get forum statistics // Get forum statistics
$total_posts = $config['num_posts']; $total_posts = $config['num_posts'];

View file

@ -84,7 +84,7 @@ class acp_storage
* @event core.acp_storage_load * @event core.acp_storage_load
* @since 3.3.0-a1 * @since 3.3.0-a1
*/ */
$phpbb_dispatcher->dispatch('core.acp_storage_load'); $phpbb_dispatcher->trigger_event('core.acp_storage_load');
$this->overview($id, $mode); $this->overview($id, $mode);
} }

View file

@ -4189,7 +4189,7 @@ function garbage_collection()
* @event core.garbage_collection * @event core.garbage_collection
* @since 3.1.0-a1 * @since 3.1.0-a1
*/ */
$phpbb_dispatcher->dispatch('core.garbage_collection'); $phpbb_dispatcher->trigger_event('core.garbage_collection');
} }
// Unload cache, must be done before the DB connection if closed // Unload cache, must be done before the DB connection if closed

View file

@ -1152,7 +1152,7 @@ function display_custom_bbcodes()
* @event core.display_custom_bbcodes * @event core.display_custom_bbcodes
* @since 3.1.0-a1 * @since 3.1.0-a1
*/ */
$phpbb_dispatcher->dispatch('core.display_custom_bbcodes'); $phpbb_dispatcher->trigger_event('core.display_custom_bbcodes');
} }
/** /**

View file

@ -23,11 +23,11 @@ $level = E_ALL & ~E_NOTICE & ~E_DEPRECATED;
error_reporting($level); error_reporting($level);
/** /**
* Minimum Requirement: PHP 7.1.3 * Minimum Requirement: PHP 7.3.0
*/ */
if (version_compare(PHP_VERSION, '7.1.3', '<')) if (version_compare(PHP_VERSION, '7.3.0', '<'))
{ {
die('You are running an unsupported PHP version. Please upgrade to PHP 7.1.3 or higher before trying to install or update to phpBB 3.3'); die('You are running an unsupported PHP version. Please upgrade to PHP 7.3.0 or higher before trying to install or update to phpBB 4.0');
} }
// In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems // In PHP 5.3.0 the error level has been raised to E_WARNING which causes problems

View file

@ -262,7 +262,7 @@ class ucp_main
* @event core.ucp_main_subscribed_post_data * @event core.ucp_main_subscribed_post_data
* @since 3.1.10-RC1 * @since 3.1.10-RC1
*/ */
$phpbb_dispatcher->dispatch('core.ucp_main_subscribed_post_data'); $phpbb_dispatcher->trigger_event('core.ucp_main_subscribed_post_data');
if ($unwatch) if ($unwatch)
{ {

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\cache; namespace phpbb\console\command\cache;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
@ -72,7 +73,7 @@ class purge extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return void * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -87,5 +88,7 @@ class purge extends \phpbb\console\command\command
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$io->success($this->user->lang('PURGE_CACHE_SUCCESS')); $io->success($this->user->lang('PURGE_CACHE_SUCCESS'));
return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\config; namespace phpbb\console\command\config;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -20,8 +21,8 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class delete extends command class delete extends command
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function configure() protected function configure()
{ {
$this $this
@ -36,16 +37,16 @@ class delete extends command
} }
/** /**
* Executes the command config:delete. * Executes the command config:delete.
* *
* Removes a configuration option * Removes a configuration option
* *
* @param InputInterface $input An InputInterface instance * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return void * @return int
* @see \phpbb\config\config::delete() * @see \phpbb\config\config::delete()
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -57,10 +58,13 @@ class delete extends command
$this->config->delete($key); $this->config->delete($key);
$io->success($this->user->lang('CLI_CONFIG_DELETE_SUCCESS', $key)); $io->success($this->user->lang('CLI_CONFIG_DELETE_SUCCESS', $key));
return symfony_command::SUCCESS;
} }
else else
{ {
$io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key)); $io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key));
return symfony_command::FAILURE;
} }
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\config; namespace phpbb\console\command\config;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -50,7 +51,7 @@ class get extends command
* @param InputInterface $input An InputInterface instance * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return void * @return int
* @see \phpbb\config\config::offsetGet() * @see \phpbb\config\config::offsetGet()
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
@ -62,14 +63,17 @@ class get extends command
if (isset($this->config[$key]) && $input->getOption('no-newline')) if (isset($this->config[$key]) && $input->getOption('no-newline'))
{ {
$output->write($this->config[$key]); $output->write($this->config[$key]);
return symfony_command::SUCCESS;
} }
else if (isset($this->config[$key])) else if (isset($this->config[$key]))
{ {
$output->writeln($this->config[$key]); $output->writeln($this->config[$key]);
return symfony_command::SUCCESS;
} }
else else
{ {
$io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key)); $io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key));
return symfony_command::FAILURE;
} }
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\config; namespace phpbb\console\command\config;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -55,7 +56,7 @@ class increment extends command
* @param InputInterface $input An InputInterface instance * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return void * @return int
* @see \phpbb\config\config::increment() * @see \phpbb\config\config::increment()
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
@ -69,5 +70,7 @@ class increment extends command
$this->config->increment($key, $increment, $use_cache); $this->config->increment($key, $increment, $use_cache);
$io->success($this->user->lang('CLI_CONFIG_INCREMENT_SUCCESS', $key)); $io->success($this->user->lang('CLI_CONFIG_INCREMENT_SUCCESS', $key));
return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\config; namespace phpbb\console\command\config;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -55,7 +56,7 @@ class set extends command
* @param InputInterface $input An InputInterface instance * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return void * @return int
* @see \phpbb\config\config::set() * @see \phpbb\config\config::set()
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
@ -69,5 +70,7 @@ class set extends command
$this->config->set($key, $value, $use_cache); $this->config->set($key, $value, $use_cache);
$io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key)); $io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key));
return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\config; namespace phpbb\console\command\config;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -76,12 +77,12 @@ class set_atomic extends command
if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache)) if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache))
{ {
$io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key)); $io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key));
return 0; return symfony_command::SUCCESS;
} }
else else
{ {
$io->error($this->user->lang('CLI_CONFIG_SET_FAILURE', $key)); $io->error($this->user->lang('CLI_CONFIG_SET_FAILURE', $key));
return 1; return symfony_command::FAILURE;
} }
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\cron; namespace phpbb\console\command\cron;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
@ -52,7 +53,7 @@ class cron_list extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return void * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -63,7 +64,7 @@ class cron_list extends \phpbb\console\command\command
if (empty($tasks)) if (empty($tasks))
{ {
$io->error($this->user->lang('CRON_NO_TASKS')); $io->error($this->user->lang('CRON_NO_TASKS'));
return; return symfony_command::FAILURE;
} }
$ready_tasks = $not_ready_tasks = array(); $ready_tasks = $not_ready_tasks = array();
@ -90,5 +91,7 @@ class cron_list extends \phpbb\console\command\command
$io->title($this->user->lang('TASKS_NOT_READY')); $io->title($this->user->lang('TASKS_NOT_READY'));
$io->listing($not_ready_tasks); $io->listing($not_ready_tasks);
} }
return symfony_command::SUCCESS;
} }
} }

View file

@ -14,6 +14,7 @@
namespace phpbb\console\command\cron; namespace phpbb\console\command\cron;
use phpbb\exception\runtime_exception; use phpbb\exception\runtime_exception;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -90,7 +91,8 @@ class run extends \phpbb\console\command\command
} }
$this->lock_db->release(); $this->lock_db->release();
return $exit_status;
return !$exit_status ? symfony_command::SUCCESS : symfony_command::FAILURE;
} }
else else
{ {

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\db; namespace phpbb\console\command\db;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -19,6 +20,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class list_command extends \phpbb\console\command\db\migration_command class list_command extends \phpbb\console\command\db\migration_command
{ {
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -33,6 +37,16 @@ class list_command extends \phpbb\console\command\db\migration_command
; ;
} }
/**
* Executes the command db:list.
*
* Lists all installed and available migrations
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -77,5 +91,7 @@ class list_command extends \phpbb\console\command\db\migration_command
$io->text($this->user->lang('CLI_MIGRATIONS_EMPTY')); $io->text($this->user->lang('CLI_MIGRATIONS_EMPTY'));
$io->newLine(); $io->newLine();
} }
return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\db; namespace phpbb\console\command\db;
use Symfony\Component\Console\Command\Command as symfony_command;
use phpbb\db\output_handler\log_wrapper_migrator_output_handler; use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -41,6 +42,9 @@ class migrate extends \phpbb\console\command\db\migration_command
$this->language->add_lang(array('common', 'install', 'migrator')); $this->language->add_lang(array('common', 'install', 'migrator'));
} }
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -49,6 +53,16 @@ class migrate extends \phpbb\console\command\db\migration_command
; ;
} }
/**
* Executes the command db:migrate.
*
* Updates the database by applying migrations
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -71,7 +85,7 @@ class migrate extends \phpbb\console\command\db\migration_command
{ {
$io->error($e->getLocalisedMessage($this->user)); $io->error($e->getLocalisedMessage($this->user));
$this->finalise_update(); $this->finalise_update();
return 1; return symfony_command::FAILURE;
} }
} }
@ -82,5 +96,6 @@ class migrate extends \phpbb\console\command\db\migration_command
$this->finalise_update(); $this->finalise_update();
$io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL')); $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\db; namespace phpbb\console\command\db;
use Symfony\Component\Console\Command\Command as symfony_command;
use phpbb\db\output_handler\log_wrapper_migrator_output_handler; use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -20,6 +21,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class revert extends \phpbb\console\command\db\migrate class revert extends \phpbb\console\command\db\migrate
{ {
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -33,6 +37,16 @@ class revert extends \phpbb\console\command\db\migrate
; ;
} }
/**
* Executes the command db:revert.
*
* Reverts a migration
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -46,12 +60,12 @@ class revert extends \phpbb\console\command\db\migrate
if (!in_array($name, $this->load_migrations())) if (!in_array($name, $this->load_migrations()))
{ {
$io->error($this->language->lang('MIGRATION_NOT_VALID', $name)); $io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
return 1; return symfony_command::FAILURE;
} }
else if ($this->migrator->migration_state($name) === false) else if ($this->migrator->migration_state($name) === false)
{ {
$io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name)); $io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
return 1; return symfony_command::FAILURE;
} }
try try
@ -65,10 +79,11 @@ class revert extends \phpbb\console\command\db\migrate
{ {
$io->error($e->getLocalisedMessage($this->user)); $io->error($e->getLocalisedMessage($this->user));
$this->finalise_update(); $this->finalise_update();
return 1; return symfony_command::FAILURE;
} }
$this->finalise_update(); $this->finalise_update();
$io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL')); $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\dev; namespace phpbb\console\command\dev;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -26,6 +27,9 @@ class migration_tips extends \phpbb\console\command\command
parent::__construct($user); parent::__construct($user);
} }
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -34,6 +38,16 @@ class migration_tips extends \phpbb\console\command\command
; ;
} }
/**
* Executes the command dev:migration-tips.
*
* Finds migrations that are not depended upon
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$migrations = $this->extension_manager->get_finder() $migrations = $this->extension_manager->get_finder()
@ -60,5 +74,7 @@ class migration_tips extends \phpbb\console\command\command
$output->writeln("\t\t\t'{$migration}',"); $output->writeln("\t\t\t'{$migration}',");
} }
$output->writeln("\t\t];"); $output->writeln("\t\t];");
return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\extension; namespace phpbb\console\command\extension;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -19,6 +20,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class disable extends command class disable extends command
{ {
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -32,6 +36,16 @@ class disable extends command
; ;
} }
/**
* Executes the command extension:disable.
*
* Disables the specified extension
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -50,14 +64,14 @@ class disable extends command
if ($this->manager->is_enabled($name)) if ($this->manager->is_enabled($name))
{ {
$io->error($this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name)); $io->error($this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name));
return 1; return symfony_command::FAILURE;
} }
else else
{ {
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name)); $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name));
$this->check_apcu_cache($io); $this->check_apcu_cache($io);
$io->success($this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name)); $io->success($this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name));
return 0; return symfony_command::SUCCESS;
} }
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\extension; namespace phpbb\console\command\extension;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -19,6 +20,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class enable extends command class enable extends command
{ {
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -32,6 +36,16 @@ class enable extends command
; ;
} }
/**
* Executes the command extension:enable.
*
* Enables the specified extension
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -41,7 +55,7 @@ class enable extends command
if (!$this->manager->is_available($name)) if (!$this->manager->is_available($name))
{ {
$io->error($this->user->lang('CLI_EXTENSION_NOT_EXIST', $name)); $io->error($this->user->lang('CLI_EXTENSION_NOT_EXIST', $name));
return 1; return symfony_command::FAILURE;
} }
$extension = $this->manager->get_extension($name); $extension = $this->manager->get_extension($name);
@ -51,13 +65,13 @@ class enable extends command
$message = !empty($enableable) ? $enableable : $this->user->lang('CLI_EXTENSION_NOT_ENABLEABLE', $name); $message = !empty($enableable) ? $enableable : $this->user->lang('CLI_EXTENSION_NOT_ENABLEABLE', $name);
$message = is_array($message) ? implode(PHP_EOL, $message) : $message; $message = is_array($message) ? implode(PHP_EOL, $message) : $message;
$io->error($message); $io->error($message);
return 1; return symfony_command::FAILURE;
} }
if ($this->manager->is_enabled($name)) if ($this->manager->is_enabled($name))
{ {
$io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name)); $io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name));
return 1; return symfony_command::FAILURE;
} }
$this->manager->enable($name); $this->manager->enable($name);
@ -68,12 +82,12 @@ class enable extends command
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name)); $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name));
$this->check_apcu_cache($io); $this->check_apcu_cache($io);
$io->success($this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name)); $io->success($this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name));
return 0; return symfony_command::SUCCESS;
} }
else else
{ {
$io->error($this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name)); $io->error($this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name));
return 1; return symfony_command::FAILURE;
} }
} }
} }

View file

@ -16,6 +16,7 @@ namespace phpbb\console\command\extension;
use phpbb\composer\extension_manager; use phpbb\composer\extension_manager;
use phpbb\composer\io\console_io; use phpbb\composer\io\console_io;
use phpbb\language\language; use phpbb\language\language;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -72,7 +73,7 @@ class install extends \phpbb\console\command\command
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return integer * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -83,7 +84,7 @@ class install extends \phpbb\console\command\command
if (!$this->manager->check_requirements()) if (!$this->manager->check_requirements())
{ {
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE')); $io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
return 1; return symfony_command::FAILURE;
} }
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language); $composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
@ -98,6 +99,6 @@ class install extends \phpbb\console\command\command
$io->success($this->language->lang('EXTENSIONS_INSTALLED')); $io->success($this->language->lang('EXTENSIONS_INSTALLED'));
return 0; return symfony_command::SUCCESS;
} }
} }

View file

@ -14,6 +14,7 @@
namespace phpbb\console\command\extension; namespace phpbb\console\command\extension;
use phpbb\composer\manager_interface; use phpbb\composer\manager_interface;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
@ -52,7 +53,7 @@ class list_available extends \phpbb\console\command\command
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return integer * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -68,6 +69,6 @@ class list_available extends \phpbb\console\command\command
$io->listing($extensions); $io->listing($extensions);
return 0; return symfony_command::SUCCESS;
} }
} }

View file

@ -17,6 +17,7 @@ use phpbb\composer\exception\managed_with_error_exception;
use phpbb\composer\io\console_io; use phpbb\composer\io\console_io;
use phpbb\composer\manager_interface; use phpbb\composer\manager_interface;
use phpbb\language\language; use phpbb\language\language;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -66,7 +67,7 @@ class manage extends \phpbb\console\command\command
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return integer * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -75,7 +76,7 @@ class manage extends \phpbb\console\command\command
if (!$this->manager->check_requirements()) if (!$this->manager->check_requirements())
{ {
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE')); $io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
return 1; return symfony_command::FAILURE;
} }
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language); $composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
@ -89,11 +90,11 @@ class manage extends \phpbb\console\command\command
catch (managed_with_error_exception $e) catch (managed_with_error_exception $e)
{ {
$io->warning($this->language->lang_array($e->getMessage(), $e->get_parameters())); $io->warning($this->language->lang_array($e->getMessage(), $e->get_parameters()));
return 1; return symfony_command::FAILURE;
} }
$io->success($this->language->lang('EXTENSION_MANAGED_SUCCESS', $extension)); $io->success($this->language->lang('EXTENSION_MANAGED_SUCCESS', $extension));
return 0; return symfony_command::SUCCESS;
} }
} }

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\extension; namespace phpbb\console\command\extension;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -19,6 +20,9 @@ use Symfony\Component\Console\Style\SymfonyStyle;
class purge extends command class purge extends command
{ {
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -32,6 +36,16 @@ class purge extends command
; ;
} }
/**
* Executes the command extension:purge.
*
* Purges the specified extension
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -43,14 +57,14 @@ class purge extends command
if ($this->manager->is_enabled($name)) if ($this->manager->is_enabled($name))
{ {
$io->error($this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name)); $io->error($this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name));
return 1; return symfony_command::FAILURE;
} }
else else
{ {
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_PURGE', time(), array($name)); $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_PURGE', time(), array($name));
$this->check_apcu_cache($io); $this->check_apcu_cache($io);
$io->success($this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name)); $io->success($this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name));
return 0; return symfony_command::SUCCESS;
} }
} }
} }

View file

@ -16,6 +16,7 @@ namespace phpbb\console\command\extension;
use phpbb\composer\extension_manager; use phpbb\composer\extension_manager;
use phpbb\composer\io\console_io; use phpbb\composer\io\console_io;
use phpbb\language\language; use phpbb\language\language;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -83,7 +84,7 @@ class remove extends \phpbb\console\command\command
if (!$this->manager->check_requirements()) if (!$this->manager->check_requirements())
{ {
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE')); $io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
return 1; return symfony_command::FAILURE;
} }
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language); $composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
@ -98,6 +99,6 @@ class remove extends \phpbb\console\command\command
$io->success($this->language->lang('EXTENSIONS_REMOVED')); $io->success($this->language->lang('EXTENSIONS_REMOVED'));
return 0; return symfony_command::SUCCESS;
} }
} }

View file

@ -12,12 +12,16 @@
*/ */
namespace phpbb\console\command\extension; namespace phpbb\console\command\extension;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
class show extends command class show extends command
{ {
/**
* {@inheritdoc}
*/
protected function configure() protected function configure()
{ {
$this $this
@ -26,6 +30,16 @@ class show extends command
; ;
} }
/**
* Executes the command extension:show.
*
* Lists all extensions in the database and on the filesystem
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
@ -36,7 +50,7 @@ class show extends command
if (empty($all)) if (empty($all))
{ {
$io->note($this->user->lang('CLI_EXTENSION_NOT_FOUND')); $io->note($this->user->lang('CLI_EXTENSION_NOT_FOUND'));
return 3; return symfony_command::FAILURE;
} }
$enabled = array_keys($this->manager->all_enabled()); $enabled = array_keys($this->manager->all_enabled());
@ -50,5 +64,7 @@ class show extends command
$purged = array_diff($all, $enabled, $disabled); $purged = array_diff($all, $enabled, $disabled);
$io->section($this->user->lang('CLI_EXTENSIONS_AVAILABLE')); $io->section($this->user->lang('CLI_EXTENSIONS_AVAILABLE'));
$io->listing($purged); $io->listing($purged);
return symfony_command::SUCCESS;
} }
} }

View file

@ -16,6 +16,7 @@ namespace phpbb\console\command\extension;
use phpbb\composer\io\console_io; use phpbb\composer\io\console_io;
use phpbb\composer\manager_interface; use phpbb\composer\manager_interface;
use phpbb\language\language; use phpbb\language\language;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@ -75,7 +76,7 @@ class update extends \phpbb\console\command\command
if (!$this->manager->check_requirements()) if (!$this->manager->check_requirements())
{ {
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE')); $io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
return 1; return symfony_command::FAILURE;
} }
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language); $composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
@ -85,6 +86,6 @@ class update extends \phpbb\console\command\command
$io->success($this->language->lang('EXTENSIONS_UPDATED')); $io->success($this->language->lang('EXTENSIONS_UPDATED'));
return 0; return symfony_command::SUCCESS;
} }
} }

View file

@ -13,6 +13,7 @@
namespace phpbb\console\command\fixup; namespace phpbb\console\command\fixup;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
@ -64,7 +65,7 @@ class fix_left_right_ids extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance * @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance * @param OutputInterface $output An OutputInterface instance
* *
* @return void * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -87,6 +88,7 @@ class fix_left_right_ids extends \phpbb\console\command\command
$this->cache->purge(); $this->cache->purge();
$io->success($this->user->lang('CLI_FIXUP_FIX_LEFT_RIGHT_IDS_SUCCESS')); $io->success($this->user->lang('CLI_FIXUP_FIX_LEFT_RIGHT_IDS_SUCCESS'));
return symfony_command::SUCCESS;
} }
/** /**

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\fixup; namespace phpbb\console\command\fixup;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\ProgressBar;
@ -114,5 +115,6 @@ class update_hashes extends \phpbb\console\command\command
$progress_bar->finish(); $progress_bar->finish();
$output->writeln('<info>' . $this->user->lang('CLI_FIXUP_UPDATE_HASH_BCRYPT_SUCCESS') . '</info>'); $output->writeln('<info>' . $this->user->lang('CLI_FIXUP_UPDATE_HASH_BCRYPT_SUCCESS') . '</info>');
return symfony_command::SUCCESS;
} }
} }

View file

@ -13,6 +13,7 @@
namespace phpbb\console\command\reparser; namespace phpbb\console\command\reparser;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
@ -59,7 +60,7 @@ class list_all extends \phpbb\console\command\command
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return integer * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -67,6 +68,6 @@ class list_all extends \phpbb\console\command\command
$io->section($this->user->lang('CLI_DESCRIPTION_REPARSER_AVAILABLE')); $io->section($this->user->lang('CLI_DESCRIPTION_REPARSER_AVAILABLE'));
$io->listing($this->reparser_names); $io->listing($this->reparser_names);
return 0; return symfony_command::SUCCESS;
} }
} }

View file

@ -14,6 +14,7 @@
namespace phpbb\console\command\reparser; namespace phpbb\console\command\reparser;
use phpbb\exception\runtime_exception; use phpbb\exception\runtime_exception;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -126,7 +127,7 @@ class reparse extends \phpbb\console\command\command
* *
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @return integer * @return int
*/ */
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
@ -157,7 +158,7 @@ class reparse extends \phpbb\console\command\command
$this->reparse_lock->release(); $this->reparse_lock->release();
return 0; return symfony_command::SUCCESS;
} }
/** /**

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\thumbnail; namespace phpbb\console\command\thumbnail;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
@ -90,7 +91,7 @@ class delete extends \phpbb\console\command\command
if ($nb_missing_thumbnails === 0) if ($nb_missing_thumbnails === 0)
{ {
$io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE')); $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE'));
return 0; return symfony_command::SUCCESS;
} }
$sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype $sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype
@ -105,7 +106,7 @@ class delete extends \phpbb\console\command\command
$progress->start(); $progress->start();
$thumbnail_deleted = array(); $thumbnail_deleted = array();
$return = 0; $return = symfony_command::SUCCESS;
while ($row = $this->db->sql_fetchrow($result)) while ($row = $this->db->sql_fetchrow($result))
{ {
$thumbnail_path = $this->phpbb_root_path . $this->config['upload_path'] . '/thumb_' . $row['physical_filename']; $thumbnail_path = $this->phpbb_root_path . $this->config['upload_path'] . '/thumb_' . $row['physical_filename'];
@ -124,7 +125,7 @@ class delete extends \phpbb\console\command\command
} }
else else
{ {
$return = 1; $return = symfony_command::FAILURE;
$progress->setMessage('<error>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</error>'); $progress->setMessage('<error>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</error>');
} }

View file

@ -13,6 +13,7 @@
namespace phpbb\console\command\thumbnail; namespace phpbb\console\command\thumbnail;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
@ -107,7 +108,7 @@ class generate extends \phpbb\console\command\command
if ($nb_missing_thumbnails === 0) if ($nb_missing_thumbnails === 0)
{ {
$io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE')); $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE'));
return 0; return symfony_command::SUCCESS;
} }
$extensions = $this->cache->obtain_attach_extensions(true); $extensions = $this->cache->obtain_attach_extensions(true);
@ -168,7 +169,7 @@ class generate extends \phpbb\console\command\command
$io->newLine(2); $io->newLine(2);
$io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE')); $io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE'));
return 0; return symfony_command::SUCCESS;
} }
/** /**

View file

@ -12,6 +12,7 @@
*/ */
namespace phpbb\console\command\thumbnail; namespace phpbb\console\command\thumbnail;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -57,7 +58,7 @@ class recreate extends \phpbb\console\command\command
$input_delete = new ArrayInput($parameters); $input_delete = new ArrayInput($parameters);
$return = $this->getApplication()->run($input_delete, $output); $return = $this->getApplication()->run($input_delete, $output);
if ($return === 0) if ($return === symfony_command::SUCCESS)
{ {
$parameters['command'] = 'thumbnail:generate'; $parameters['command'] = 'thumbnail:generate';

View file

@ -17,6 +17,7 @@ use phpbb\config\config;
use phpbb\exception\exception_interface; use phpbb\exception\exception_interface;
use phpbb\language\language; use phpbb\language\language;
use phpbb\user; use phpbb\user;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -98,7 +99,7 @@ class check extends \phpbb\console\command\command
if (!($stability == 'stable') && !($stability == 'unstable')) if (!($stability == 'stable') && !($stability == 'unstable'))
{ {
$io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability)); $io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability));
return 3; return symfony_command::FAILURE;
} }
} }
@ -155,7 +156,7 @@ class check extends \phpbb\console\command\command
$this->display_versions($io, $updates_available); $this->display_versions($io, $updates_available);
} }
return 1; return symfony_command::FAILURE;
} }
else else
{ {
@ -164,14 +165,14 @@ class check extends \phpbb\console\command\command
$io->success($this->language->lang('UPDATE_NOT_NEEDED')); $io->success($this->language->lang('UPDATE_NOT_NEEDED'));
} }
return 0; return symfony_command::SUCCESS;
} }
} }
catch (\RuntimeException $e) catch (\RuntimeException $e)
{ {
$io->error($this->language->lang('EXTENSION_NOT_INSTALLED', $ext_name)); $io->error($this->language->lang('EXTENSION_NOT_INSTALLED', $ext_name));
return 1; return symfony_command::FAILURE;
} }
} }
@ -207,7 +208,7 @@ class check extends \phpbb\console\command\command
$this->display_versions($io, $updates_available); $this->display_versions($io, $updates_available);
} }
return 1; return symfony_command::FAILURE;
} }
else else
{ {
@ -216,7 +217,7 @@ class check extends \phpbb\console\command\command
$io->success($this->language->lang('UPDATE_NOT_NEEDED')); $io->success($this->language->lang('UPDATE_NOT_NEEDED'));
} }
return 0; return symfony_command::SUCCESS;
} }
} }
@ -292,7 +293,7 @@ class check extends \phpbb\console\command\command
$this->language->lang('LATEST_VERSION'), $this->language->lang('LATEST_VERSION'),
], $rows); ], $rows);
return 0; return symfony_command::SUCCESS;
} }
/** /**

View file

@ -20,6 +20,7 @@ use phpbb\log\log_interface;
use phpbb\notification\manager; use phpbb\notification\manager;
use phpbb\user; use phpbb\user;
use phpbb\user_loader; use phpbb\user_loader;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -137,19 +138,19 @@ class activate extends command
if ($user_row['user_id'] == ANONYMOUS) if ($user_row['user_id'] == ANONYMOUS)
{ {
$io->error($this->language->lang('NO_USER')); $io->error($this->language->lang('NO_USER'));
return 1; return symfony_command::FAILURE;
} }
// Check if the user is already active (or inactive) // Check if the user is already active (or inactive)
if ($mode == 'activate' && $user_row['user_type'] != USER_INACTIVE) if ($mode == 'activate' && $user_row['user_type'] != USER_INACTIVE)
{ {
$io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE')); $io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE'));
return 1; return symfony_command::FAILURE;
} }
else if ($mode == 'deactivate' && $user_row['user_type'] == USER_INACTIVE) else if ($mode == 'deactivate' && $user_row['user_type'] == USER_INACTIVE)
{ {
$io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE')); $io->error($this->language->lang('CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE'));
return 1; return symfony_command::FAILURE;
} }
// Activate the user account // Activate the user account
@ -177,7 +178,7 @@ class activate extends command
$io->success($this->language->lang($msg)); $io->success($this->language->lang($msg));
return 0; return symfony_command::SUCCESS;
} }
/** /**

View file

@ -20,6 +20,7 @@ use phpbb\exception\runtime_exception;
use phpbb\language\language; use phpbb\language\language;
use phpbb\passwords\manager; use phpbb\passwords\manager;
use phpbb\user; use phpbb\user;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -142,7 +143,7 @@ class add extends command
catch (runtime_exception $e) catch (runtime_exception $e)
{ {
$io->error($e->getMessage()); $io->error($e->getMessage());
return 1; return symfony_command::FAILURE;
} }
$user_row = array( $user_row = array(
@ -161,7 +162,7 @@ class add extends command
if (!$user_id) if (!$user_id)
{ {
$io->error($this->language->lang('AUTH_NO_PROFILE_CREATED')); $io->error($this->language->lang('AUTH_NO_PROFILE_CREATED'));
return 1; return symfony_command::FAILURE;
} }
if ($input->getOption('send-email') && $this->config['email_enable']) if ($input->getOption('send-email') && $this->config['email_enable'])
@ -171,7 +172,7 @@ class add extends command
$io->success($this->language->lang('CLI_USER_ADD_SUCCESS', $this->data['username'])); $io->success($this->language->lang('CLI_USER_ADD_SUCCESS', $this->data['username']));
return 0; return symfony_command::SUCCESS;
} }
/** /**

View file

@ -18,6 +18,7 @@ use phpbb\language\language;
use phpbb\log\log_interface; use phpbb\log\log_interface;
use phpbb\user; use phpbb\user;
use phpbb\user_loader; use phpbb\user_loader;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
@ -122,7 +123,7 @@ class delete extends command
if ($user_row['user_id'] == ANONYMOUS) if ($user_row['user_id'] == ANONYMOUS)
{ {
$io->error($this->language->lang('NO_USER')); $io->error($this->language->lang('NO_USER'));
return 1; return symfony_command::FAILURE;
} }
if (!function_exists('user_delete')) if (!function_exists('user_delete'))
@ -137,7 +138,7 @@ class delete extends command
$io->success($this->language->lang('USER_DELETED')); $io->success($this->language->lang('USER_DELETED'));
} }
return 0; return symfony_command::SUCCESS;
} }
/** /**

View file

@ -17,6 +17,7 @@ use phpbb\console\command\command;
use phpbb\db\driver\driver_interface; use phpbb\db\driver\driver_interface;
use phpbb\language\language; use phpbb\language\language;
use phpbb\user; use phpbb\user;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -98,7 +99,7 @@ class reclean extends command
$io->newLine(2); $io->newLine(2);
$io->success($this->language->lang('CLI_USER_RECLEAN_DONE', $this->processed)); $io->success($this->language->lang('CLI_USER_RECLEAN_DONE', $this->processed));
return 0; return symfony_command::SUCCESS;
} }
/** /**

View file

@ -18,7 +18,7 @@ use phpbb\lock\db;
use phpbb\request\request_interface; use phpbb\request\request_interface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\Event\TerminateEvent;
/** /**
* Event listener that executes cron tasks, after the response was served * Event listener that executes cron tasks, after the response was served
@ -57,9 +57,9 @@ class cron_runner_listener implements EventSubscriberInterface
/** /**
* Runs the cron job after the response was sent * Runs the cron job after the response was sent
* *
* @param PostResponseEvent $event The event * @param TerminateEvent $event The event
*/ */
public function on_kernel_terminate(PostResponseEvent $event) public function on_kernel_terminate(TerminateEvent $event)
{ {
$request = $event->getRequest(); $request = $event->getRequest();
$controller_name = $request->get('_route'); $controller_name = $request->get('_route');

View file

@ -201,6 +201,9 @@ class container_builder
// Easy collections through tags // Easy collections through tags
$this->container->addCompilerPass(new pass\collection_pass()); $this->container->addCompilerPass(new pass\collection_pass());
// Mark all services public
$this->container->addCompilerPass(new pass\markpublic_pass());
// Event listeners "phpBB style" // Event listeners "phpBB style"
$this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener')); $this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener'));

View file

@ -26,8 +26,8 @@ class container_configuration implements ConfigurationInterface
*/ */
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder(); $treeBuilder = new TreeBuilder('core');
$rootNode = $treeBuilder->root('core'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->children() ->children()
->booleanNode('require_dev_dependencies')->defaultValue(false)->end() ->booleanNode('require_dev_dependencies')->defaultValue(false)->end()

View file

@ -0,0 +1,58 @@
<?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.
*
*/
namespace phpbb\di\pass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Marks all services public
*/
class markpublic_pass implements CompilerPassInterface
{
/**
* Modify the container before it is passed to the rest of the code
* Mark services as public by default unless they were explicitly marked as private
*
* @param ContainerBuilder $container ContainerBuilder object
* @return void
*/
public function process(ContainerBuilder $container)
{
$service_definitions = $container->getDefinitions();
foreach ($service_definitions as $definition)
{
$changes = $definition->getChanges();
/* Check if service definition contains explicit 'public' key (changed default state)
* If it does and the service is private, then service was explicitly marked as private
* Don't mark it as public then
*/
$definition_override_public = isset($changes['public']) && $changes['public'];
if (!$definition_override_public && $definition->isPrivate())
{
$definition->setPublic(true);
}
}
foreach ($container->getAliases() as $alias)
{
// Only mark alias as public if original service is public too
if ($service_definitions[(string) $alias]->isPublic() && $alias->isPrivate())
{
$alias->setPublic(true);
}
}
}
}

View file

@ -13,7 +13,7 @@
namespace phpbb\event; namespace phpbb\event;
use Symfony\Component\EventDispatcher\Event; use Symfony\Contracts\EventDispatcher\Event;
class data extends Event implements \ArrayAccess class data extends Event implements \ArrayAccess
{ {

View file

@ -14,7 +14,6 @@
namespace phpbb\event; namespace phpbb\event;
use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
/** /**
* Extension of the Symfony EventDispatcher * Extension of the Symfony EventDispatcher
@ -43,26 +42,24 @@ class dispatcher extends EventDispatcher implements dispatcher_interface
public function trigger_event($eventName, $data = []) public function trigger_event($eventName, $data = [])
{ {
$event = new \phpbb\event\data($data); $event = new \phpbb\event\data($data);
$this->dispatch($eventName, $event); foreach ((array) $eventName as $name)
{
$this->dispatch($event, $name);
}
return $event->get_data_filtered(array_keys($data)); return $event->get_data_filtered(array_keys($data));
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function dispatch($eventName, Event $event = null) public function dispatch(object $event, string $eventName = null) : object
{ {
if ($this->disabled) if ($this->disabled)
{ {
return $event; return $event;
} }
foreach ((array) $eventName as $name) return parent::dispatch($event, $eventName);
{
$event = parent::dispatch($name, $event);
}
return $event;
} }
/** /**

View file

@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
class kernel_exception_subscriber implements EventSubscriberInterface class kernel_exception_subscriber implements EventSubscriberInterface
@ -65,12 +65,12 @@ class kernel_exception_subscriber implements EventSubscriberInterface
/** /**
* This listener is run when the KernelEvents::EXCEPTION event is triggered * This listener is run when the KernelEvents::EXCEPTION event is triggered
* *
* @param GetResponseForExceptionEvent $event * @param ExceptionEvent $event
* @return null * @return null
*/ */
public function on_kernel_exception(GetResponseForExceptionEvent $event) public function on_kernel_exception(ExceptionEvent $event)
{ {
$exception = $event->getException(); $exception = $event->getThrowable();
$message = $exception->getMessage(); $message = $exception->getMessage();
$this->type_caster->set_var($message, $message, 'string', true, false); $this->type_caster->set_var($message, $message, 'string', true, false);

View file

@ -15,7 +15,7 @@ namespace phpbb\event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\PostResponseEvent; use Symfony\Component\HttpKernel\Event\TerminateEvent;
class kernel_terminate_subscriber implements EventSubscriberInterface class kernel_terminate_subscriber implements EventSubscriberInterface
{ {
@ -24,10 +24,10 @@ class kernel_terminate_subscriber implements EventSubscriberInterface
* This comes after a Response has been sent to the server; this is * This comes after a Response has been sent to the server; this is
* primarily cleanup stuff. * primarily cleanup stuff.
* *
* @param PostResponseEvent $event * @param TerminateEvent $event
* @return void * @return void
*/ */
public function on_kernel_terminate(PostResponseEvent $event) public function on_kernel_terminate(TerminateEvent $event)
{ {
garbage_collection(); garbage_collection();

View file

@ -203,16 +203,20 @@ class php_exporter
{ {
$event_line = false; $event_line = false;
$found_trigger_event = strpos($this->file_lines[$i], 'dispatcher->trigger_event('); $found_trigger_event = strpos($this->file_lines[$i], 'dispatcher->trigger_event(');
$found_use_vars = strpos($this->file_lines[$i], ', compact($vars)');
$arguments = array(); $arguments = array();
if ($found_trigger_event !== false) if ($found_trigger_event !== false)
{ {
$event_line = $i; $event_line = $i;
$this->set_current_event($this->get_event_name($event_line, false), $event_line); $this->set_current_event($this->get_event_name($event_line, false), $event_line);
// Find variables of the event if ($found_use_vars)
$arguments = $this->get_vars_from_array(); {
$doc_vars = $this->get_vars_from_docblock(); // Find variables of the event
$this->validate_vars_docblock_array($arguments, $doc_vars); $arguments = $this->get_vars_from_array();
$doc_vars = $this->get_vars_from_docblock();
$this->validate_vars_docblock_array($arguments, $doc_vars);
}
} }
else else
{ {
@ -346,10 +350,10 @@ class php_exporter
} }
else else
{ {
$regex = '#extract\(\$[a-z](?:[a-z0-9_]|->)*'; $regex = '#(?:extract\()?\$[a-z](?:[a-z0-9_]|->)*';
$regex .= '->trigger_event\((\[)?'; $regex .= '->trigger_event\((\[)?';
$regex .= '\'' . $this->preg_match_event_name() . '(?(1)\', \'(?2))+\''; $regex .= '\'' . $this->preg_match_event_name() . '(?(1)\', \'(?2))+\'';
$regex .= '(?(1)\]), compact\(\$vars\)\)\);#'; $regex .= '(?(1)\])(?:, compact\(\$vars\)\))?\);#';
} }
$match = array(); $match = array();

View file

@ -212,6 +212,18 @@ class helper
*/ */
public static function make_path_relative($end_path, $start_path) public static function make_path_relative($end_path, $start_path)
{ {
// Ensure paths are absolute as passing relative paths to the
// Symsony's Filesystem::makePathRelative() method is removed since Symfony 4.0
if (!self::is_absolute_path($end_path))
{
$end_path = self::phpbb_own_realpath($end_path);
}
if (!self::is_absolute_path($start_path))
{
$start_path = self::phpbb_own_realpath($start_path);
}
return self::get_symfony_filesystem()->makePathRelative($end_path, $start_path); return self::get_symfony_filesystem()->makePathRelative($end_path, $start_path);
} }

View file

@ -20,7 +20,7 @@ use phpbb\template\template;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
/** /**
@ -60,11 +60,11 @@ class kernel_exception_subscriber implements EventSubscriberInterface
/** /**
* This listener is run when the KernelEvents::EXCEPTION event is triggered * This listener is run when the KernelEvents::EXCEPTION event is triggered
* *
* @param GetResponseForExceptionEvent $event * @param ExceptionEvent $event
*/ */
public function on_kernel_exception(GetResponseForExceptionEvent $event) public function on_kernel_exception(ExceptionEvent $event)
{ {
$exception = $event->getException(); $exception = $event->getThrowable();
$message = $exception->getMessage(); $message = $exception->getMessage();
if ($exception instanceof exception_interface) if ($exception instanceof exception_interface)

View file

@ -161,7 +161,7 @@ class container_factory
// Setting request is required for the compatibility globals as those are generated from // Setting request is required for the compatibility globals as those are generated from
// this container // this container
if (!$this->container->isFrozen()) if (!$this->container->isCompiled())
{ {
$this->container->register('request')->setSynthetic(true); $this->container->register('request')->setSynthetic(true);
$this->container->register('language')->setSynthetic(true); $this->container->register('language')->setSynthetic(true);

View file

@ -26,8 +26,8 @@ class installer_configuration implements ConfigurationInterface
*/ */
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder(); $treeBuilder = new TreeBuilder('installer');
$rootNode = $treeBuilder->root('installer'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->children() ->children()
->arrayNode('admin') ->arrayNode('admin')

View file

@ -26,8 +26,8 @@ class updater_configuration implements ConfigurationInterface
*/ */
public function getConfigTreeBuilder() public function getConfigTreeBuilder()
{ {
$treeBuilder = new TreeBuilder(); $treeBuilder = new TreeBuilder('updater');
$rootNode = $treeBuilder->root('updater'); $rootNode = $treeBuilder->getRootNode();
$rootNode $rootNode
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children() ->children()

View file

@ -49,6 +49,7 @@ class guesser
{ {
$is_supported = (method_exists($guesser, 'is_supported')) ? 'is_supported' : ''; $is_supported = (method_exists($guesser, 'is_supported')) ? 'is_supported' : '';
$is_supported = (method_exists($guesser, 'isSupported')) ? 'isSupported' : $is_supported; $is_supported = (method_exists($guesser, 'isSupported')) ? 'isSupported' : $is_supported;
$is_supported = (method_exists($guesser, 'isGuesserSupported')) ? 'isGuesserSupported' : $is_supported;
if (empty($is_supported)) if (empty($is_supported))
{ {
@ -117,9 +118,13 @@ class guesser
$mimetype = 'application/octet-stream'; $mimetype = 'application/octet-stream';
$args = (array) func_get_args();
foreach ($this->guessers as $guesser) foreach ($this->guessers as $guesser)
{ {
$mimetype_guess = $guesser->guess($file, $file_name); $guess = (method_exists($guesser, 'guess')) ? 'guess' : '';
$guess = (method_exists($guesser, 'guessMimeType')) ? 'guessMimeType' : $guess;
$mimetype_guess = $guesser->$guess(...$args);
$mimetype = $this->choose_mime_type($mimetype, $mimetype_guess); $mimetype = $this->choose_mime_type($mimetype, $mimetype_guess);
} }

View file

@ -20,9 +20,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException; use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper; use Symfony\Component\Routing\Generator\Dumper\CompiledUrlGeneratorDumper;
use Symfony\Component\Routing\Generator\CompiledUrlGenerator;
use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper;
use Symfony\Component\Routing\Matcher\CompiledUrlMatcher;
use Symfony\Component\Routing\Matcher\UrlMatcher; use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollection;
@ -217,19 +219,12 @@ class router implements RouterInterface
$cache = new ConfigCache("{$this->cache_dir}url_matcher.{$this->php_ext}", $this->debug_url_matcher); $cache = new ConfigCache("{$this->cache_dir}url_matcher.{$this->php_ext}", $this->debug_url_matcher);
if (!$cache->isFresh()) if (!$cache->isFresh())
{ {
$dumper = new PhpMatcherDumper($this->get_routes()); $dumper = new CompiledUrlMatcherDumper($this->get_routes());
$cache->write($dumper->dump(), $this->get_routes()->getResources());
$options = array(
'class' => 'phpbb_url_matcher',
'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
);
$cache->write($dumper->dump($options), $this->get_routes()->getResources());
} }
require_once($cache->getPath()); $compiled_routes = require_once($cache->getPath());
$this->matcher = new CompiledUrlMatcher($compiled_routes, $this->context);
$this->matcher = new \phpbb_url_matcher($this->context);
} }
catch (IOException $e) catch (IOException $e)
{ {
@ -272,19 +267,12 @@ class router implements RouterInterface
$cache = new ConfigCache("{$this->cache_dir}url_generator.{$this->php_ext}", $this->debug_url_generator); $cache = new ConfigCache("{$this->cache_dir}url_generator.{$this->php_ext}", $this->debug_url_generator);
if (!$cache->isFresh()) if (!$cache->isFresh())
{ {
$dumper = new PhpGeneratorDumper($this->get_routes()); $dumper = new CompiledUrlGeneratorDumper($this->get_routes());
$cache->write($dumper->dump(), $this->get_routes()->getResources());
$options = array(
'class' => 'phpbb_url_generator',
'base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
);
$cache->write($dumper->dump($options), $this->get_routes()->getResources());
} }
require_once($cache->getPath()); $compiled_routes = require_once($cache->getPath());
$this->generator = new CompiledUrlGenerator($compiled_routes, $this->context);
$this->generator = new \phpbb_url_generator($this->context);
} }
catch (IOException $e) catch (IOException $e)
{ {

View file

@ -1054,7 +1054,7 @@ class session
* @event core.session_gc_after * @event core.session_gc_after
* @since 3.1.6-RC1 * @since 3.1.6-RC1
*/ */
$phpbb_dispatcher->dispatch('core.session_gc_after'); $phpbb_dispatcher->trigger_event('core.session_gc_after');
return; return;
} }

View file

@ -13,7 +13,9 @@
namespace phpbb\template\twig\extension; namespace phpbb\template\twig\extension;
class avatar extends \Twig_Extension use Twig\Extension\AbstractExtension;
class avatar extends AbstractExtension
{ {
/** /**
* Get the name of this extension * Get the name of this extension

View file

@ -13,7 +13,9 @@
namespace phpbb\template\twig\extension; namespace phpbb\template\twig\extension;
class config extends \Twig_Extension use Twig\Extension\AbstractExtension;
class config extends AbstractExtension
{ {
/** @var \phpbb\config\config */ /** @var \phpbb\config\config */
protected $config; protected $config;

View file

@ -14,8 +14,9 @@
namespace phpbb\template\twig\extension; namespace phpbb\template\twig\extension;
use phpbb\template\twig\environment; use phpbb\template\twig\environment;
use Twig\Extension\AbstractExtension;
class icon extends \Twig\Extension\AbstractExtension class icon extends AbstractExtension
{ {
/** @var \phpbb\user */ /** @var \phpbb\user */
protected $user; protected $user;

View file

@ -13,10 +13,14 @@
namespace phpbb\template\twig\extension; namespace phpbb\template\twig\extension;
use Symfony\Bridge\Twig\Extension\RoutingExtension;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Extension\AbstractExtension;
use Twig\Node\Expression\ArrayExpression;
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Node;
use Twig\TwigFunction;
class routing extends RoutingExtension class routing extends AbstractExtension
{ {
/** @var \phpbb\controller\helper */ /** @var \phpbb\controller\helper */
protected $helper; protected $helper;
@ -31,6 +35,17 @@ class routing extends RoutingExtension
$this->helper = $helper; $this->helper = $helper;
} }
/**
* {@inheritdoc}
*/
public function getFunctions(): array
{
return [
new TwigFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
new TwigFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]),
];
}
public function getPath($name, $parameters = array(), $relative = false) public function getPath($name, $parameters = array(), $relative = false)
{ {
return $this->helper->route($name, $parameters, true, false, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH); return $this->helper->route($name, $parameters, true, false, $relative ? UrlGeneratorInterface::RELATIVE_PATH : UrlGeneratorInterface::ABSOLUTE_PATH);
@ -40,4 +55,47 @@ class routing extends RoutingExtension
{ {
return $this->helper->route($name, $parameters, true, false, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL); return $this->helper->route($name, $parameters, true, false, $schemeRelative ? UrlGeneratorInterface::NETWORK_PATH : UrlGeneratorInterface::ABSOLUTE_URL);
} }
/**
* Borrowed from the Symfony Twig bridge routing extension
*
* @author Fabien Potencier <fabien@symfony.com>
*
* Determines at compile time whether the generated URL will be safe and thus
* saving the unneeded automatic escaping for performance reasons.
*
* The URL generation process percent encodes non-alphanumeric characters. So there is no risk
* that malicious/invalid characters are part of the URL. The only character within an URL that
* must be escaped in html is the ampersand ("&") which separates query params. So we cannot mark
* the URL generation as always safe, but only when we are sure there won't be multiple query
* params. This is the case when there are none or only one constant parameter given.
* E.g. we know beforehand this will be safe:
* - path('route')
* - path('route', {'param': 'value'})
* But the following may not:
* - path('route', var)
* - path('route', {'param': ['val1', 'val2'] }) // a sub-array
* - path('route', {'param1': 'value1', 'param2': 'value2'})
* If param1 and param2 reference placeholder in the route, it would still be safe. But we don't know.
*
* @param Node $argsNode The arguments of the path/url function
*
* @return array An array with the contexts the URL is safe
*/
public function isUrlGenerationSafe(Node $argsNode): array
{
// support named arguments
$paramsNode = $argsNode->hasNode('parameters') ? $argsNode->getNode('parameters') : (
$argsNode->hasNode(1) ? $argsNode->getNode(1) : null
);
if (null === $paramsNode || $paramsNode instanceof ArrayExpression && \count($paramsNode) <= 2 &&
(!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression)
)
{
return ['html'];
}
return [];
}
} }

View file

@ -13,7 +13,9 @@
namespace phpbb\template\twig\extension; namespace phpbb\template\twig\extension;
class username extends \Twig_Extension use Twig\Extension\AbstractExtension;
class username extends AbstractExtension
{ {
/** /**
* Get the name of this extension * Get the name of this extension

View file

@ -342,7 +342,7 @@ class user extends \phpbb\session
* @event core.user_setup_after * @event core.user_setup_after
* @since 3.1.6-RC1 * @since 3.1.6-RC1
*/ */
$phpbb_dispatcher->dispatch('core.user_setup_after'); $phpbb_dispatcher->trigger_event('core.user_setup_after');
// If this function got called from the error handler we are finished here. // If this function got called from the error handler we are finished here.
if (defined('IN_ERROR_HANDLER')) if (defined('IN_ERROR_HANDLER'))

View file

@ -93,8 +93,8 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$guessers = array( $guessers = array(
new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\Mime\FileinfoMimeTypeGuesser(),
new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), new \Symfony\Component\Mime\FileBinaryMimeTypeGuesser(),
new \phpbb\mimetype\content_guesser(), new \phpbb\mimetype\content_guesser(),
new \phpbb\mimetype\extension_guesser(), new \phpbb\mimetype\extension_guesser(),
); );

View file

@ -28,6 +28,8 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
protected function setUp(): void protected function setUp(): void
{ {
global $phpbb_root_path, $phpEx;
$this->cache_dir = dirname(__FILE__) . '/tmp/cache/'; $this->cache_dir = dirname(__FILE__) . '/tmp/cache/';
if (file_exists($this->cache_dir)) if (file_exists($this->cache_dir))
@ -43,7 +45,8 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
$this->db = $this->createMock('\phpbb\db\driver\driver_interface'); $this->db = $this->createMock('\phpbb\db\driver\driver_interface');
$this->config = new \phpbb\config\config(array('assets_version' => 1)); $this->config = new \phpbb\config\config(array('assets_version' => 1));
$this->user = $this->createMock('\phpbb\user'); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
} }
public function test_purge() public function test_purge()

View file

@ -50,7 +50,8 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
)); ));
$this->db = $this->db = $this->new_dbal(); $this->db = $this->db = $this->new_dbal();
$this->user = $this->createMock('\phpbb\user'); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
$this->phpbb_root_path = $phpbb_root_path; $this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx; $this->phpEx = $phpEx;

View file

@ -106,7 +106,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
$this->assertEquals(2, $this->get_user_id('Admin')); $this->assertEquals(2, $this->get_user_id('Admin'));
$this->question->setInputStream($this->getInputStream("bar\npassword\npassword\nbar@test.com\n")); $command_tester->setInputs(['bar', 'password', 'password', 'bar@test.com']);
$command_tester->execute(array( $command_tester->execute(array(
'command' => $this->command_name, 'command' => $this->command_name,

View file

@ -117,13 +117,4 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
$user_id = $row ? $row['user_id'] : null; $user_id = $row ? $row['user_id'] : null;
return $user_id; return $user_id;
} }
public function getInputStream($input)
{
$stream = fopen('php://memory', 'r+', false);
fputs($stream, $input);
rewind($stream);
return $stream;
}
} }

View file

@ -52,7 +52,7 @@ namespace
$this->assertTrue($container->hasParameter('core')); $this->assertTrue($container->hasParameter('core'));
// Checks compile_container // Checks compile_container
$this->assertTrue($container->isFrozen()); $this->assertTrue($container->isCompiled());
// Checks inject_config // Checks inject_config
$this->assertTrue($container->hasParameter('core.table_prefix')); $this->assertTrue($container->hasParameter('core.table_prefix'));
@ -74,7 +74,7 @@ namespace
// Checks the construction of a dumped container // Checks the construction of a dumped container
$container = $this->builder->get_container(); $container = $this->builder->get_container();
$this->assertInstanceOf('phpbb_cache_container', $container); $this->assertInstanceOf('phpbb_cache_container', $container);
$this->assertTrue($container->isFrozen()); $this->assertTrue($container->isCompiled());
} }
public function test_tables_mapping() public function test_tables_mapping()
@ -102,7 +102,7 @@ namespace
$container = $this->builder->get_container(); $container = $this->builder->get_container();
$this->assertNotInstanceOf('phpbb_cache_container', $container); $this->assertNotInstanceOf('phpbb_cache_container', $container);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
$this->assertTrue($container->isFrozen()); $this->assertTrue($container->isCompiled());
} }
public function test_without_extensions() public function test_without_extensions()
@ -127,7 +127,7 @@ namespace
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
// Checks compile_container // Checks compile_container
$this->assertFalse($container->isFrozen()); $this->assertFalse($container->isCompiled());
} }
public function test_with_config_path() public function test_with_config_path()

View file

@ -84,7 +84,7 @@ class exception_listener extends phpbb_test_case
$exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $lang); $exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $lang);
$event = new \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent($this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, $exception); $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); $exception_listener->on_kernel_exception($event);
$response = $event->getResponse(); $response = $event->getResponse();

View file

@ -58,7 +58,7 @@ class phpbb_functional_controllers_compatibility_test extends phpbb_functional_t
$location = substr($location, 0, -1); $location = substr($location, 0, -1);
} }
$this->assertEquals(301, self::$client->getResponse()->getStatus()); $this->assertEquals(301, self::$client->getResponse()->getStatusCode());
$this->assertStringEndsWith($to, $location); $this->assertStringEndsWith($to, $location);
} }
} }

View file

@ -107,7 +107,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$this->phpbb_extension_manager->enable('foo/bar'); $this->phpbb_extension_manager->enable('foo/bar');
$crawler = self::request('GET', 'app.php/foo/baz', array(), false); $crawler = self::request('GET', 'app.php/foo/baz', array(), false);
$this->assert_response_html(500); $this->assert_response_html(500);
$this->assertStringContainsString('Missing value for argument #1: test in class foo\bar\controller\controller:baz', $crawler->filter('body')->text()); $this->assertStringContainsString('Controller "foo\bar\controller\controller::baz()" requires that you provide a value for the "$test" argument', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar'); $this->phpbb_extension_manager->purge('foo/bar');
} }

View file

@ -51,14 +51,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
self::$init_values['topic_base_items'] = (int) $values['config[feed_limit_topic]']; self::$init_values['topic_base_items'] = (int) $values['config[feed_limit_topic]'];
// Enable all feeds // Enable all feeds
$values['config[feed_enable]'] = true; $values['config[feed_enable]'] = 1;
$values['config[feed_forum]'] = true; $values['config[feed_forum]'] = 1;
$values['config[feed_item_statistics]'] = true; $values['config[feed_item_statistics]'] = 1;
$values['config[feed_overall]'] = true; $values['config[feed_overall]'] = 1;
$values['config[feed_overall_forums]'] = true; $values['config[feed_overall_forums]'] = 1;
$values['config[feed_topic]'] = true; $values['config[feed_topic]'] = 1;
$values['config[feed_topics_active]'] = true; $values['config[feed_topics_active]'] = 1;
$values['config[feed_topics_new]'] = true; $values['config[feed_topics_new]'] = 1;
$form->setValues($values); $form->setValues($values);
@ -68,7 +68,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
// Disable showing unapproved posts to users // Disable showing unapproved posts to users
$crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=features"); $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=features");
$form = $crawler->selectButton('Submit')->form(); $form = $crawler->selectButton('Submit')->form();
$form->setValues(['config[display_unapproved_posts]' => false]); $form->setValues(['config[display_unapproved_posts]' => 0]);
$crawler = self::submit($form); $crawler = self::submit($form);
self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text()); self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text());

View file

@ -70,7 +70,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
public function test_quote() public function test_quote()
{ {
$text = 'Test post </textarea>"\' &&amp;amp;'; $text = 'Test post </textarea>"\' &&amp;amp;';
$expected = "(\\[quote=admin[^\\]]*\\]\n" . preg_quote($text) . "\n\\[/quote\\])"; $expected = "(\[quote=admin[^\]]*\]\s?" . preg_quote($text) . "\s?\[\/quote\])";
$this->login(); $this->login();
$topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic');
@ -123,7 +123,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$this->set_quote_depth($quote_depth); $this->set_quote_depth($quote_depth);
$crawler = self::request('GET', $quote_url); $crawler = self::request('GET', $quote_url);
$this->assertRegexp( $this->assertRegexp(
"(\\[quote=admin[^\\]]*\\]\n?" . preg_quote($expected_text) . "\n?\\[/quote\\])", "(\[quote=admin[^\]]*\]\s?" . preg_quote($expected_text) . "\s?\[\/quote\])",
$crawler->filter('textarea#message')->text() $crawler->filter('textarea#message')->text()
); );
} }

View file

@ -85,7 +85,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
public function test_quote_pm() public function test_quote_pm()
{ {
$text = 'This is a test private message sent by the testing framework.'; $text = 'This is a test private message sent by the testing framework.';
$expected = "(\\[quote=admin msg_id=\\d+ time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])"; $expected = "(\[quote=admin msg_id=[\d]+ time=[\d]+ user_id=2\]\s?" . $text . "\s?\[\/quote\])";
$this->login(); $this->login();
$message_id = $this->create_private_message('Test', $text, array(2)); $message_id = $this->create_private_message('Test', $text, array(2));
@ -98,13 +98,13 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
public function test_quote_forward() public function test_quote_forward()
{ {
$text = 'This is a test private message sent by the testing framework.'; $text = 'This is a test private message sent by the testing framework.';
$expected = "[quote=admin]\n" . $text . "\n[/quote]"; $expected = "(\[quote=admin\]\s?" . $text . "\s?\[\/quote\])";
$this->login(); $this->login();
$message_id = $this->create_private_message('Test', $text, array(2)); $message_id = $this->create_private_message('Test', $text, array(2));
$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid); $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid);
$this->assertStringContainsString($expected, $crawler->filter('textarea#message')->text()); $this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
} }
} }

View file

@ -32,14 +32,14 @@ class guesser_test extends \phpbb_test_case
global $phpbb_root_path; global $phpbb_root_path;
$guessers = array( $guessers = array(
new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\Mime\FileinfoMimeTypeGuesser(),
new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), new \Symfony\Component\Mime\FileBinaryMimeTypeGuesser(),
new \phpbb\mimetype\extension_guesser, new \phpbb\mimetype\extension_guesser,
new \phpbb\mimetype\content_guesser, new \phpbb\mimetype\content_guesser,
); );
// Check if any guesser except the extension_guesser is available // Check if any guesser except the extension_guesser is available
$this->fileinfo_supported = $guessers[0]->isSupported() | $guessers[1]->isSupported() | $guessers[3]->is_supported(); $this->fileinfo_supported = $guessers[0]->isGuesserSupported() | $guessers[1]->isGuesserSupported() | $guessers[3]->is_supported();
// Also create a guesser that emulates not having fileinfo available // Also create a guesser that emulates not having fileinfo available
$this->guesser_no_fileinfo = new \phpbb\mimetype\guesser(array($guessers[2])); $this->guesser_no_fileinfo = new \phpbb\mimetype\guesser(array($guessers[2]));
@ -175,7 +175,11 @@ class guesser_test extends \phpbb_test_case
// Cover possible LogicExceptions // Cover possible LogicExceptions
foreach ($guessers as $cur_guesser) foreach ($guessers as $cur_guesser)
{ {
$supported += $cur_guesser->is_supported(); $is_supported = (method_exists($cur_guesser, 'is_supported')) ? 'is_supported' : '';
$is_supported = (method_exists($cur_guesser, 'isSupported')) ? 'isSupported' : $is_supported;
$is_supported = (method_exists($cur_guesser, 'isGuesserSupported')) ? 'isGuesserSupported' : $is_supported;
$supported += $cur_guesser->$is_supported();
} }
if (!$supported) if (!$supported)
@ -194,9 +198,9 @@ class guesser_test extends \phpbb_test_case
public function test_sort_priority() public function test_sort_priority()
{ {
$guessers = array( $guessers = array(
'FileinfoMimeTypeGuesser' => new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser, 'FileinfoMimeTypeGuesser' => new \Symfony\Component\Mime\FileinfoMimeTypeGuesser,
'extension_guesser' => new \phpbb\mimetype\extension_guesser, 'extension_guesser' => new \phpbb\mimetype\extension_guesser,
'FileBinaryMimeTypeGuesser' => new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser, 'FileBinaryMimeTypeGuesser' => new \Symfony\Component\Mime\FileBinaryMimeTypeGuesser,
'content_guesser' => new \phpbb\mimetype\content_guesser, 'content_guesser' => new \phpbb\mimetype\content_guesser,
); );
$guessers['content_guesser']->set_priority(5); $guessers['content_guesser']->set_priority(5);

View file

@ -195,7 +195,7 @@ class phpbb_mock_container_builder implements ContainerInterface
{ {
} }
public function isFrozen() public function isCompiled()
{ {
return false; return false;
} }

View file

@ -125,6 +125,9 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
); );
$phpbb_container->set('notification_manager', $this->notifications); $phpbb_container->set('notification_manager', $this->notifications);
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
$phpbb_container->compile(); $phpbb_container->compile();
$this->notifications->setDependencies($this->auth, $this->config); $this->notifications->setDependencies($this->auth, $this->config);

View file

@ -129,6 +129,9 @@ class notification_method_email_test extends phpbb_tests_notification_base
); );
$phpbb_container->set('notification_manager', $this->notifications); $phpbb_container->set('notification_manager', $this->notifications);
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
$phpbb_container->compile(); $phpbb_container->compile();
$this->notifications->setDependencies($this->auth, $this->config); $this->notifications->setDependencies($this->auth, $this->config);

View file

@ -137,6 +137,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types'); $phpbb_container->setParameter('tables.notification_types', 'phpbb_notification_types');
$phpbb_container->setParameter('tables.notification_emails', 'phpbb_notification_emails'); $phpbb_container->setParameter('tables.notification_emails', 'phpbb_notification_emails');
$phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
$phpbb_container->addCompilerPass(new phpbb\di\pass\markpublic_pass());
$phpbb_container->compile(); $phpbb_container->compile();
// Notification Types // Notification Types

View file

@ -1017,12 +1017,12 @@ class phpbb_functional_test_case extends phpbb_test_case
*/ */
static public function assert_response_status_code($status_code = 200) static public function assert_response_status_code($status_code = 200)
{ {
if ($status_code != self::$client->getResponse()->getStatus() && if ($status_code != self::$client->getResponse()->getStatusCode() &&
preg_match('/^5[0-9]{2}/', self::$client->getResponse()->getStatus())) preg_match('/^5[0-9]{2}/', self::$client->getResponse()->getStatusCode()))
{ {
self::fail("Encountered unexpected server error:\n" . self::$client->getResponse()->getContent()); self::fail("Encountered unexpected server error:\n" . self::$client->getResponse()->getContent());
} }
self::assertEquals($status_code, self::$client->getResponse()->getStatus(), 'HTTP status code does not match'); self::assertEquals($status_code, self::$client->getResponse()->getStatusCode(), 'HTTP status code does not match');
} }
public function assert_filter($crawler, $expr, $msg = null) public function assert_filter($crawler, $expr, $msg = null)

View file

@ -455,7 +455,7 @@ class phpbb_test_case_helpers
$cache_key_renderer = $prefix . '_renderer'; $cache_key_renderer = $prefix . '_renderer';
$container->set('cache.driver', $cache); $container->set('cache.driver', $cache);
if (!$container->isFrozen()) if (!$container->isCompiled())
{ {
$container->setParameter('cache.dir', $cache_dir); $container->setParameter('cache.dir', $cache_dir);
} }

View file

@ -66,8 +66,8 @@ class phpbb_filespec_test extends phpbb_test_case
} }
$guessers = array( $guessers = array(
new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\Mime\FileinfoMimeTypeGuesser(),
new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), new \Symfony\Component\Mime\FileBinaryMimeTypeGuesser(),
new \phpbb\mimetype\content_guesser(), new \phpbb\mimetype\content_guesser(),
new \phpbb\mimetype\extension_guesser(), new \phpbb\mimetype\extension_guesser(),
); );

View file

@ -59,8 +59,8 @@ class phpbb_fileupload_test extends phpbb_test_case
$this->filesystem = new \phpbb\filesystem\filesystem(); $this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$guessers = array( $guessers = array(
new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\Mime\FileinfoMimeTypeGuesser(),
new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), new \Symfony\Component\Mime\FileBinaryMimeTypeGuesser(),
new \phpbb\mimetype\content_guesser(), new \phpbb\mimetype\content_guesser(),
new \phpbb\mimetype\extension_guesser(), new \phpbb\mimetype\extension_guesser(),
); );

View file

@ -24,6 +24,9 @@ sites:
databases: databases:
- phpbb - phpbb
features:
- mariadb: true
# blackfire: # blackfire:
# - id: foo # - id: foo
# token: bar # token: bar