Skip to content

Commit

Permalink
Load module before plugins
Browse files Browse the repository at this point in the history
resolves #2831
  • Loading branch information
brandonkelly committed May 2, 2018
1 parent d4bb993 commit 0282fe5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Changed
- Edit User pages will now warn editors when leaving the page with unsaved changes. ([#2832](https://github.com/craftcms/cms/issues/2832))
- Modules are once again loaded before plugins, so they have a chance to register Twig initialization events before a plugin initializes Twig. ([#2831](https://github.com/craftcms/cms/issues/2831))

### Fixed
- Fixed an error that could occur in the Plugin Store.
Expand Down
10 changes: 8 additions & 2 deletions src/base/ApplicationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,9 @@ public function getVolumes()
// =========================================================================

/**
* Initializes the application component
* Initializes things that should happen before the main Application::init()
*/
private function _init()
private function _preInit()
{
$this->getLog();

Expand All @@ -1119,7 +1119,13 @@ private function _init()

// Set the language
$this->updateTargetLanguage();
}

/**
* Initializes things that should happen after the main Application::init()
*/
private function _postInit()
{
// Load the plugins
$this->getPlugins()->loadPlugins();

Expand Down
5 changes: 2 additions & 3 deletions src/console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ public function __construct($config = [])
public function init()
{
$this->state = self::STATE_INIT;
// Important that we call $this->_init() before parent::init(), so that it's run before bootstrap()
// in case bootstrap() ends up loading a module that loads Twig, configuring Twig with the wrong timezone
$this->_init();
$this->_preInit();
parent::init();
$this->_postInit();
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/web/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ public function __construct(array $config = [])
public function init()
{
$this->state = self::STATE_INIT;
// Important that we call $this->_init() before parent::init(), so that it's run before bootstrap()
// in case bootstrap() ends up loading a module that loads Twig, configuring Twig with the wrong timezone
$this->_init();
$this->_preInit();
parent::init();

// Initialize web application-specific stuff
$this->ensureResourcePathExists();
$this->debugBootstrap();

$this->_postInit();
}

/**
Expand Down

0 comments on commit 0282fe5

Please sign in to comment.