1
0
mirror of https://github.com/flarum/core.git synced 2025-07-16 22:31:18 +02:00

Extensions should be considered enabled after boot.

Before boot, we consider them "disabled" so they get migrated.
This commit is contained in:
Alexander Skvortsov
2021-05-11 19:31:35 -04:00
parent d68d551e16
commit ce7484e2c8
3 changed files with 24 additions and 2 deletions

View File

@@ -31,6 +31,8 @@ class OverrideExtensionManagerForTests implements ExtenderInterface
$extensionManager->enable($extension); $extensionManager->enable($extension);
} }
$extensionManager->booted = true;
$extensionManager->extend($container); $extensionManager->extend($container);
} }
} }

View File

@@ -30,6 +30,11 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
*/ */
protected $enabledIds; protected $enabledIds;
/**
* @var bool
*/
public $booted = false;
public function __construct( public function __construct(
SettingsRepositoryInterface $config, SettingsRepositoryInterface $config,
Paths $paths, Paths $paths,
@@ -70,11 +75,15 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
} }
/** /**
* Since we enable every time, we always assume it's not enabled. * We assume it's not enabled during boot.
* However, since some logic needs this, as soon as we enable extensions
* we'll switch booted to on.
*/ */
public function isEnabled($extension) public function isEnabled($extension)
{ {
return false; if (!$this->booted) return false;
return parent::isEnabled($extension);
} }
/** /**

View File

@@ -125,6 +125,17 @@ class TestCaseTest extends TestCase
$this->assertTrue($tableExists); $this->assertTrue($tableExists);
} }
/**
* @test
*/
public function current_extension_considered_enabled_after_boot()
{
$this->extension('flarum-testing-tests');
$enabled = $this->app()->getContainer()->make('flarum.extensions')->isEnabled('flarum-testing-tests');
$this->assertTrue($enabled);
}
/** /**
* @test * @test
*/ */