Skip to content

Commit

Permalink
Dev: Fix model race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 23, 2016
1 parent 9411411 commit 375640e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions application/libraries/PluginManager/PluginBase.php
Expand Up @@ -400,8 +400,16 @@ public function readConfigFile()
{
// Do everything related to reading config fields
// TODO: Create a config object for this? One object for each config field? Then loop through those fields.
$this->checkActive();
$this->saveNewVersion();
$pluginModel = \Plugin::model()->findByPk($this->id);

// "Impossible"
if (empty($pluginModel))
{
throw new \Exception('Internal error: Found no database entry for plugin id ' . $this->id);
}

$this->checkActive($pluginModel);
$this->saveNewVersion($pluginModel);
}
}
else
Expand All @@ -415,16 +423,8 @@ public function readConfigFile()
* This is the 'active-by-default' feature.
* @return void
*/
protected function checkActive()
protected function checkActive($pluginModel)
{
$pluginModel = \Plugin::model()->findByPk($this->id);

// "Impossible"
if (empty($pluginModel))
{
throw new \Exception('Internal error: Found no database entry for plugin id ' . $this->id);
}

if ($this->config->active == 1)
{
// Activate plugin
Expand Down

0 comments on commit 375640e

Please sign in to comment.