diff --git a/phpBB/phpbb/composer/installer.php b/phpBB/phpbb/composer/installer.php index 5c3bf712e7..8be6194497 100644 --- a/phpBB/phpbb/composer/installer.php +++ b/phpBB/phpbb/composer/installer.php @@ -32,6 +32,8 @@ use Symfony\Component\Console\Output\OutputInterface; */ class installer { + const PHPBB_TYPES = ['phpbb-extension', 'phpbb-style', 'phpbb-language']; + /** * @var array Repositories to look packages from */ @@ -132,12 +134,14 @@ class installer /** * Returns the list of currently installed packages * - * @param string $type Returns only the packages with the given type + * @param string|array $types Returns only the packages with the given type(s) * * @return array The installed packages associated to their version. */ - public function get_installed_packages($type) + public function get_installed_packages($types) { + $types = (array) $types; + $original_vendor_dir = getenv('COMPOSER_VENDOR_DIR'); try @@ -151,7 +155,7 @@ class installer foreach ($packages as $package) { - if ($package->getType() === $type) + if (in_array($package->getType(), $types, true)) { $installed[$package->getName()] = $package->getPrettyVersion(); } @@ -180,6 +184,8 @@ class installer { try { + $this->generate_ext_json_file($this->get_installed_packages(self::PHPBB_TYPES)); + $io = new NullIO(); $composer = Factory::create($io, $this->get_composer_ext_json_filename(), false); diff --git a/phpBB/phpbb/composer/manager.php b/phpBB/phpbb/composer/manager.php index 6f087ea19d..02ca33ecb8 100644 --- a/phpBB/phpbb/composer/manager.php +++ b/phpBB/phpbb/composer/manager.php @@ -36,10 +36,15 @@ class manager implements manager_interface protected $exception_prefix; /** - * @var array Caches the managed packages list + * @var array Caches the managed packages list (for the current type) */ private $managed_packages; + /** + * @var array Caches the managed packages list (for all phpBB types) + */ + private $all_managed_packages; + /** * @var array Caches the available packages list */ @@ -84,7 +89,7 @@ class manager implements manager_interface */ protected function do_install($packages) { - $managed_packages = array_merge($this->get_managed_packages(), $packages); + $managed_packages = array_merge($this->get_all_managed_packages(), $packages); ksort($managed_packages); $this->installer->install($managed_packages, array_keys($packages)); @@ -110,7 +115,7 @@ class manager implements manager_interface throw new runtime_exception($this->exception_prefix, 'NOT_MANAGED', [implode('|', array_keys($not_managed))]); } - $managed_packages = array_merge($this->get_managed_packages(), $packages); + $managed_packages = array_merge($this->get_all_managed_packages(), $packages); ksort($managed_packages); $this->installer->install($managed_packages, array_keys($packages)); @@ -134,7 +139,7 @@ class manager implements manager_interface throw new runtime_exception($this->exception_prefix, 'NOT_MANAGED', [implode('|', array_keys($not_managed))]); } - $managed_packages = array_diff_key($this->get_managed_packages(), $packages); + $managed_packages = array_diff_key($this->get_all_managed_packages(), $packages); ksort($managed_packages); $this->installer->install($managed_packages, array_keys($packages)); @@ -154,7 +159,7 @@ class manager implements manager_interface } /** - * Returns the list of managed packages + * Returns the list of managed packages for the current type * * @return array The managed packages associated to their version. */ @@ -168,6 +173,21 @@ class manager implements manager_interface return $this->managed_packages; } + /** + * Returns the list of managed packages for all phpBB types + * + * @return array The managed packages associated to their version. + */ + public function get_all_managed_packages() + { + if ($this->all_managed_packages === null) + { + $this->all_managed_packages = $this->installer->get_installed_packages(installer::PHPBB_TYPES); + } + + return $this->all_managed_packages; + } + /** * Returns the list of available packages *