diff --git a/framework/core/src/Extension/ExtensionManager.php b/framework/core/src/Extension/ExtensionManager.php index 7ac0f9a90..e9aaed950 100644 --- a/framework/core/src/Extension/ExtensionManager.php +++ b/framework/core/src/Extension/ExtensionManager.php @@ -73,12 +73,20 @@ class ExtensionManager // Load all packages installed by composer. $installed = json_decode($this->filesystem->get($this->app->vendorPath().'/composer/installed.json'), true); + // Composer 2.0 changes the structure of the installed.json manifest + $installed = $installed['packages'] ?? $installed; + foreach ($installed as $package) { if (Arr::get($package, 'type') != 'flarum-extension' || empty(Arr::get($package, 'name'))) { continue; } + + $path = isset($package['install-path']) + ? $this->getExtensionsDir().'/composer/'.$package['install-path'] + : $this->getExtensionsDir().'/'.Arr::get($package, 'name'); + // Instantiates an Extension object using the package path and composer.json file. - $extension = new Extension($this->getExtensionsDir().'/'.Arr::get($package, 'name'), $package); + $extension = new Extension($path, $package); // Per default all extensions are installed if they are registered in composer. $extension->setInstalled(true); diff --git a/framework/core/src/Install/Steps/EnableBundledExtensions.php b/framework/core/src/Install/Steps/EnableBundledExtensions.php index 33d448906..14167e527 100644 --- a/framework/core/src/Install/Steps/EnableBundledExtensions.php +++ b/framework/core/src/Install/Steps/EnableBundledExtensions.php @@ -89,14 +89,22 @@ class EnableBundledExtensions implements Step private function loadExtensions() { $json = file_get_contents("$this->vendorPath/composer/installed.json"); + $installed = json_decode($json, true); - return (new Collection(json_decode($json, true))) + // Composer 2.0 changes the structure of the installed.json manifest + $installed = $installed['packages'] ?? $installed; + + return (new Collection($installed)) ->filter(function ($package) { return Arr::get($package, 'type') == 'flarum-extension'; })->filter(function ($package) { return ! empty(Arr::get($package, 'name')); })->map(function ($package) { - $extension = new Extension($this->vendorPath.'/'.Arr::get($package, 'name'), $package); + $path = isset($package['install-path']) + ? "$this->vendorPath/composer/".$package['install-path'] + : $this->vendorPath.'/'.Arr::get($package, 'name'); + + $extension = new Extension($path, $package); $extension->setVersion(Arr::get($package, 'version')); return $extension;