diff --git a/modules/system/behaviors/SettingsModel.php b/modules/system/behaviors/SettingsModel.php
index 56d2c2952..66f16be11 100644
--- a/modules/system/behaviors/SettingsModel.php
+++ b/modules/system/behaviors/SettingsModel.php
@@ -63,7 +63,6 @@ class SettingsModel extends ModelBehavior
/*
* Parse the config
*/
- $this->fieldConfig = $this->makeConfig($this->model->settingsFields);
$this->recordCode = $this->model->settingsCode;
}
@@ -236,7 +235,11 @@ class SettingsModel extends ModelBehavior
*/
public function getFieldConfig()
{
- return $this->fieldConfig;
+ if ($this->fieldConfig !== null) {
+ return $this->fieldConfig;
+ }
+
+ return $this->fieldConfig = $this->makeConfig($this->model->settingsFields);
}
/**
diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php
index 3f0cf0e84..1d350dcb9 100644
--- a/modules/system/controllers/Updates.php
+++ b/modules/system/controllers/Updates.php
@@ -60,7 +60,7 @@ class Updates extends Controller
$this->vars['projectId'] = Parameters::get('system::project.id');
$this->vars['projectName'] = Parameters::get('system::project.name');
$this->vars['projectOwner'] = Parameters::get('system::project.owner');
- $this->vars['pluginsActiveCount'] = PluginVersion::isEnabled()->count();
+ $this->vars['pluginsActiveCount'] = PluginVersion::applyEnabled()->count();
$this->vars['pluginsCount'] = PluginVersion::count();
return $this->asExtension('ListController')->index();
}
diff --git a/modules/system/models/Parameters.php b/modules/system/models/Parameters.php
index de75ed071..847e8ce92 100644
--- a/modules/system/models/Parameters.php
+++ b/modules/system/models/Parameters.php
@@ -1,7 +1,8 @@
table, $this->namespace, $this->group, $this->item]));
+ }
+
/**
* Returns a setting value by the module (or plugin) name and setting name.
* @param string $key Specifies the setting key value, for example 'system:updates.check'
@@ -40,7 +49,7 @@ class Parameters extends Model
return static::$cache[$key];
}
- $record = static::findRecord($key)->first();
+ $record = static::findRecord($key);
if (!$record) {
return static::$cache[$key] = $default;
}
@@ -62,7 +71,7 @@ class Parameters extends Model
return true;
}
- $record = static::findRecord($key)->first();
+ $record = static::findRecord($key);
if (!$record) {
$record = new static;
list($namespace, $group, $item) = $record->parseKey($key);
@@ -78,20 +87,36 @@ class Parameters extends Model
return true;
}
+ /**
+ * Returns a record (cached)
+ * @return self
+ */
+ public static function findRecord($key)
+ {
+ $record = new static;
+
+ list($namespace, $group, $item) = $record->parseKey($key);
+
+ return $record
+ ->applyKey($key)
+ ->remember(5, implode('-', [$record->getTable(), $namespace, $group, $item]))
+ ->first();
+ }
+
/**
* Scope to find a setting record for the specified module (or plugin) name and setting name.
* @param string $key Specifies the setting key value, for example 'system:updates.check'
* @param mixed $default The default value to return if the setting doesn't exist in the DB.
- * @return mixed Returns the found record or null.
+ * @return QueryBuilder
*/
- public function scopeFindRecord($query, $key)
+ public function scopeApplyKey($query, $key)
{
list($namespace, $group, $item) = $this->parseKey($key);
$query = $query
- ->where('namespace', $namespace)
- ->where('group', $group)
- ->where('item', $item);
+ ->where('namespace', $namespace)
+ ->where('group', $group)
+ ->where('item', $item);
return $query;
}
diff --git a/modules/system/models/PluginVersion.php b/modules/system/models/PluginVersion.php
index dd5bead38..0754e4223 100644
--- a/modules/system/models/PluginVersion.php
+++ b/modules/system/models/PluginVersion.php
@@ -87,7 +87,7 @@ class PluginVersion extends Model
* @param $query
* @return mixed
*/
- public function scopeIsEnabled($query)
+ public function scopeApplyEnabled($query)
{
return $query->where('is_disabled', '!=', 1);
}