mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/11150] Disable if directories not writable
PHPBB3-11150
This commit is contained in:
committed by
Tristan Darricau
parent
0a809fb90e
commit
cc0a762866
@@ -60,12 +60,14 @@ class extension_manager extends manager
|
||||
* @param filesystem $filesystem Filesystem object
|
||||
* @param string $package_type Composer type of managed packages
|
||||
* @param string $exception_prefix Exception prefix to use
|
||||
* @param string $root_path phpBB root path
|
||||
* @param config $config Config object
|
||||
*/
|
||||
public function __construct(installer $installer, driver_interface $cache, ext_manager $extension_manager, filesystem $filesystem, $package_type, $exception_prefix, config $config = null)
|
||||
public function __construct(installer $installer, driver_interface $cache, ext_manager $extension_manager, filesystem $filesystem, $package_type, $exception_prefix, $root_path, config $config = null)
|
||||
{
|
||||
$this->extension_manager = $extension_manager;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->root_path = $root_path;
|
||||
|
||||
if ($config)
|
||||
{
|
||||
@@ -282,6 +284,14 @@ class extension_manager extends manager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function check_requirements()
|
||||
{
|
||||
return parent::check_requirements() && $this->filesystem->is_writable($this->root_path . 'ext/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the extensions when installing
|
||||
*
|
||||
|
@@ -77,7 +77,13 @@ class installer
|
||||
{
|
||||
if ($config)
|
||||
{
|
||||
$this->repositories = (array) unserialize($config['exts_composer_repositories']);
|
||||
$repositories = unserialize($config['exts_composer_repositories']);
|
||||
|
||||
if (!is_array($repositories) && !empty($repositories))
|
||||
{
|
||||
$this->repositories = (array) $repositories;
|
||||
}
|
||||
|
||||
$this->packagist = (bool) $config['exts_composer_packagist'];
|
||||
$this->composer_filename = $config['exts_composer_json_file'];
|
||||
$this->packages_vendor_dir = $config['exts_composer_vendor_dir'];
|
||||
@@ -395,6 +401,22 @@ class installer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the requirements of the manager and returns true if it can be used.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function check_requirements()
|
||||
{
|
||||
$filesystem = new \phpbb\filesystem\filesystem();
|
||||
|
||||
return $filesystem->is_writable([
|
||||
$this->root_path . $this->composer_filename,
|
||||
$this->root_path . $this->packages_vendor_dir,
|
||||
$this->root_path . substr($this->composer_filename, 0, -5) . '.lock',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates $compatible_packages with the versions of $versions compatibles with the $core_constraint
|
||||
*
|
||||
|
@@ -276,7 +276,7 @@ class manager implements manager_interface
|
||||
*/
|
||||
public function check_requirements()
|
||||
{
|
||||
return true;
|
||||
return $this->installer->check_requirements();
|
||||
}
|
||||
|
||||
protected function normalize_version($packages)
|
||||
|
@@ -57,7 +57,7 @@ class install extends \phpbb\console\command\command
|
||||
->setDescription($this->language->lang('CLI_DESCRIPTION_EXTENSION_INSTALL'))
|
||||
->addOption(
|
||||
'enable',
|
||||
'e',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
$this->language->lang('CLI_DESCRIPTION_EXTENSION_INSTALL_OPTION_ENABLE'))
|
||||
->addArgument(
|
||||
@@ -79,6 +79,13 @@ class install extends \phpbb\console\command\command
|
||||
$output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
if (!$this->manager->check_requirements())
|
||||
{
|
||||
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
|
||||
$extensions = $input->getArgument('extensions');
|
||||
|
||||
|
@@ -72,6 +72,13 @@ class manage extends \phpbb\console\command\command
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
if (!$this->manager->check_requirements())
|
||||
{
|
||||
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
|
||||
|
||||
$extension = $input->getArgument('extension');
|
||||
|
@@ -57,7 +57,7 @@ class remove extends \phpbb\console\command\command
|
||||
->setDescription($this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE'))
|
||||
->addOption(
|
||||
'purge',
|
||||
'p',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
$this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE_OPTION_PURGE'))
|
||||
->addArgument(
|
||||
@@ -79,6 +79,13 @@ class remove extends \phpbb\console\command\command
|
||||
$output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
if (!$this->manager->check_requirements())
|
||||
{
|
||||
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
|
||||
$extensions = $input->getArgument('extensions');
|
||||
|
||||
|
@@ -71,6 +71,13 @@ class update extends \phpbb\console\command\command
|
||||
$output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
if (!$this->manager->check_requirements())
|
||||
{
|
||||
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
|
||||
$extensions = $input->getArgument('extensions');
|
||||
|
||||
|
Reference in New Issue
Block a user