diff --git a/phpBB/adm/style/acp_ext_gallery.html b/phpBB/adm/style/acp_ext_gallery.html
index dfd8ffaf04..d67b657c9c 100644
--- a/phpBB/adm/style/acp_ext_gallery.html
+++ b/phpBB/adm/style/acp_ext_gallery.html
@@ -6,6 +6,12 @@
{{lang( 'EXTENSIONS_GALLERY_EXPLAIN') }}
+{% if not enabled %}
+
+ {{ lang('EXTENSIONS_COMPOSER_NOT_WRITABLE') }}
+
+{% endif %}
+
@@ -87,12 +93,14 @@
{{ extension.description }} • {{ lang('HOMEPAGE') }} |
{% if extension.name in managed_extensions %}
- {{ lang('INSTALLED') }}
+ {{ lang('INSTALLED') }}
+ {%- if enabled -%}
({{ lang('UPDATE') }}
• {{ lang('REMOVE') }})
+ {%- endif -%}
{% elseif extension.name in installed_extensions -%}
- {{ lang('INSTALLED_MANUALLY') }} ({{ lang('MANAGE') }})
- {% else -%}
+ {{ lang('INSTALLED_MANUALLY') }}{%- if enabled %} ({{ lang('MANAGE') }}){%- endif -%}
+ {% elseif enabled -%}
{{ lang('INSTALL') }}
{%- endif -%}
|
diff --git a/phpBB/config/default/container/services_extensions.yml b/phpBB/config/default/container/services_extensions.yml
index 77ff0d2ab9..b97ae1fa9c 100644
--- a/phpBB/config/default/container/services_extensions.yml
+++ b/phpBB/config/default/container/services_extensions.yml
@@ -26,6 +26,8 @@ services:
- @filesystem
- phpbb-extension
- EXTENSIONS_
+ - %core.root_path%
+ - @config
style.composer.manager:
class: phpbb\composer\manager
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
index 28f102e006..4a89bb45a4 100644
--- a/phpBB/includes/acp/acp_extensions.php
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -642,7 +642,7 @@ class acp_extensions
'purge_on_remove' => $this->config['exts_composer_purge_on_remove'],
'repositories' => unserialize($this->config['exts_composer_repositories']),
]);
- $this->template->assign_var('enabled', $this->manager->check_requirements());
+ $this->template->assign_var('enabled', $manager->check_requirements());
$this->request->disable_super_globals();
add_form_key('gallery_settings');
@@ -672,12 +672,7 @@ class acp_extensions
}
else
{
- $message_text = $e->getPrevious()->getMessage();
- if (strpos($message_text, 'ext/') === 0 && strpos($message_text, 'does not exist and could not be created.') !== false)
- {
- $message_text = $language->lang('EXTENSIONS_DIR_NOT_WRITABLE');
- }
- $message_text .= adm_back_link($this->u_action);
+ $message_text = $e->getPrevious()->getMessage() . adm_back_link($this->u_action);
}
}
else
diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php
index 55a8778be0..e65df90c9c 100644
--- a/phpBB/language/en/acp/extensions.php
+++ b/phpBB/language/en/acp/extensions.php
@@ -161,5 +161,6 @@ $lang = array_merge($lang, array(
'EXTENSIONS_INSTALLED' => 'Extensions successfully installed.',
'EXTENSIONS_REMOVED' => 'Extensions successfully removed.',
'EXTENSIONS_UPDATED' => 'Extensions successfully updated.',
- 'EXTENSIONS_DIR_NOT_WRITABLE' => 'The extension directory is not writable',
+
+ 'EXTENSIONS_COMPOSER_NOT_WRITABLE' => 'TODO: some required files / directory are not writable => disable ',
));
diff --git a/phpBB/phpbb/composer/extension_manager.php b/phpBB/phpbb/composer/extension_manager.php
index 8b2388e693..aef1513d4b 100644
--- a/phpBB/phpbb/composer/extension_manager.php
+++ b/phpBB/phpbb/composer/extension_manager.php
@@ -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
*
diff --git a/phpBB/phpbb/composer/installer.php b/phpBB/phpbb/composer/installer.php
index 4488aadb82..9a02060316 100644
--- a/phpBB/phpbb/composer/installer.php
+++ b/phpBB/phpbb/composer/installer.php
@@ -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
*
diff --git a/phpBB/phpbb/composer/manager.php b/phpBB/phpbb/composer/manager.php
index 286551ae95..cffc6c8566 100644
--- a/phpBB/phpbb/composer/manager.php
+++ b/phpBB/phpbb/composer/manager.php
@@ -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)
diff --git a/phpBB/phpbb/console/command/extension/install.php b/phpBB/phpbb/console/command/extension/install.php
index 6365da4a0c..bbed53be30 100644
--- a/phpBB/phpbb/console/command/extension/install.php
+++ b/phpBB/phpbb/console/command/extension/install.php
@@ -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');
diff --git a/phpBB/phpbb/console/command/extension/manage.php b/phpBB/phpbb/console/command/extension/manage.php
index f308bbfb36..264d120c5d 100644
--- a/phpBB/phpbb/console/command/extension/manage.php
+++ b/phpBB/phpbb/console/command/extension/manage.php
@@ -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');
diff --git a/phpBB/phpbb/console/command/extension/remove.php b/phpBB/phpbb/console/command/extension/remove.php
index 8cb6b6c68a..69d2a62dd9 100644
--- a/phpBB/phpbb/console/command/extension/remove.php
+++ b/phpBB/phpbb/console/command/extension/remove.php
@@ -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');
diff --git a/phpBB/phpbb/console/command/extension/update.php b/phpBB/phpbb/console/command/extension/update.php
index 073b38bae8..f1479c8b0d 100644
--- a/phpBB/phpbb/console/command/extension/update.php
+++ b/phpBB/phpbb/console/command/extension/update.php
@@ -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');