Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ticket/16417] Fix CLI database migration for phpBB 3.0.x #5926

Merged
merged 1 commit into from Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpBB/bin/phpbbcli.php
Expand Up @@ -84,7 +84,7 @@
$user->data['user_id'] = ANONYMOUS;
$user->ip = '127.0.0.1';

$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $language);
$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $language, $config);
$application->setDispatcher($phpbb_container->get('dispatcher'));
$application->register_container_commands($phpbb_container->get('console.command_collection'));
$application->run($input);
5 changes: 4 additions & 1 deletion phpBB/install/phpbbcli.php
Expand Up @@ -42,11 +42,14 @@
/** @var \phpbb\filesystem\filesystem $phpbb_filesystem */
$phpbb_filesystem = $phpbb_installer_container->get('filesystem');

/** @var \phpbb\config\config $config */
$config = $phpbb_installer_container->get('config');

/** @var \phpbb\language\language $language */
$language = $phpbb_installer_container->get('language');
$language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting', 'cli'));

$application = new \phpbb\console\application('phpBB Installer', PHPBB_VERSION, $language);
$application = new \phpbb\console\application('phpBB Installer', PHPBB_VERSION, $language, $config);
$application->setDispatcher($phpbb_installer_container->get('dispatcher'));
$application->register_container_commands($phpbb_installer_container->get('console.installer.command_collection'));
$application->run($input);
23 changes: 19 additions & 4 deletions phpBB/phpbb/console/application.php
Expand Up @@ -27,18 +27,25 @@ class application extends \Symfony\Component\Console\Application
protected $in_shell = false;

/**
* @var \phpbb\language\language User object
* @var \phpbb\config\config Config object
*/
protected $config;

/**
* @var \phpbb\language\language Language object
*/
protected $language;

/**
* @param string $name The name of the application
* @param string $version The version of the application
* @param \phpbb\language\language $language The user which runs the application (used for translation)
* @param \phpbb\config\config $config Config object
*/
public function __construct($name, $version, \phpbb\language\language $language)
public function __construct($name, $version, \phpbb\language\language $language, \phpbb\config\config $config)
{
$this->language = $language;
$this->config = $config;

parent::__construct($name, $version);
}
Expand Down Expand Up @@ -97,9 +104,17 @@ public function getHelp()
*/
public function register_container_commands(\phpbb\di\service_collection $command_collection)
{
foreach ($command_collection as $service_command)
$commands_list = array_keys($command_collection->getArrayCopy());
foreach ($commands_list as $service_command)
{
$this->add($service_command);
// config_text DB table does not exist in phpBB prior to 3.1
// Hence skip cron tasks as they include reparser cron as it uses config_text table
if (phpbb_version_compare($this->config['version'], '3.1.0', '<') && strpos($service_command, 'cron') !== false)
{
continue;
}
$this->add($command_collection[$service_command]);

}
}

Expand Down