diff --git a/modules/backend/widgets/Lists.php b/modules/backend/widgets/Lists.php
index 395ee537b..9af56e812 100644
--- a/modules/backend/widgets/Lists.php
+++ b/modules/backend/widgets/Lists.php
@@ -276,15 +276,20 @@ class Lists extends WidgetBase
$alias = Db::getQueryGrammar()->wrap($column->columnName);
$table = $this->model->makeRelation($column->relation)->getTable();
+ $relationType = $this->model->getRelationType($column->relation);
$sqlSelect = $this->parseTableName($column->sqlSelect, $table);
- $selects[] = DbDongle::raw("group_concat(" . $sqlSelect . " separator ', ') as ". $alias);
+ if (in_array($relationType, ['hasMany', 'belongsToMany', 'morphToMany', 'morphedByMany', 'morphMany', 'attachMany', 'hasManyThrough']))
+ $selects[] = DbDongle::raw("group_concat(" . $sqlSelect . " separator ', ') as ". $alias);
+ else
+ $selects[] = DbDongle::raw($sqlSelect . ' as '. $alias);
+
$joins[] = $column->relation;
$tables[$column->relation] = $table;
}
if ($joins)
- $query->joinWith(array_unique($joins));
+ $query->joinWith(array_unique($joins), false);
/*
* Custom select queries
diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php
index ee2c5d445..dba3baf0d 100644
--- a/modules/cms/classes/Controller.php
+++ b/modules/cms/classes/Controller.php
@@ -31,6 +31,7 @@ use Illuminate\Http\RedirectResponse;
class Controller extends BaseController
{
use \System\Traits\AssetMaker;
+ use \October\Rain\Support\Traits\Emitter;
/**
* @var \Cms\Classes\Theme A reference to the CMS theme processed by the controller.
@@ -111,7 +112,10 @@ class Controller extends BaseController
/*
* Extensibility
*/
- if ($event = Event::fire('cms.beforeDisplay', [$this, $url, $page], true))
+ if ($event = Event::fire('cms.page.beforeDisplay', [$this, $url, $page], true))
+ return $event;
+
+ if ($event = $this->fireEvent('page.beforeDisplay', [$this, $url, $page], true))
return $event;
/*
@@ -191,7 +195,10 @@ class Controller extends BaseController
/*
* Extensibility
*/
- if ($event = Event::fire('cms.afterDisplay', [$this, $url, $page], true))
+ if ($event = Event::fire('cms.page.display', [$this, $url, $page], true))
+ return $event;
+
+ if ($event = $this->fireEvent('page.display', [$this, $url, $page], true))
return $event;
return $result;
@@ -416,6 +423,15 @@ class Controller extends BaseController
*/
protected function execPageCycle()
{
+ /*
+ * Extensibility
+ */
+ if ($event = Event::fire('cms.page.start', [$this], true))
+ return $event;
+
+ if ($event = $this->fireEvent('page.start', [$this], true))
+ return $event;
+
/*
* Run layout functions
*/
@@ -449,6 +465,15 @@ class Controller extends BaseController
});
}
+ /*
+ * Extensibility
+ */
+ if ($event = Event::fire('cms.page.end', [$this], true))
+ return $event;
+
+ if ($event = $this->fireEvent('page.end', [$this], true))
+ return $event;
+
return $response;
}
diff --git a/modules/system/behaviors/SettingsModel.php b/modules/system/behaviors/SettingsModel.php
index 8cdec83ab..f539cc0ed 100644
--- a/modules/system/behaviors/SettingsModel.php
+++ b/modules/system/behaviors/SettingsModel.php
@@ -54,7 +54,7 @@ class SettingsModel extends ModelBehavior
*/
$this->model->bindEvent('model.afterFetch', [$this, 'afterModelFetch']);
$this->model->bindEvent('model.beforeSave', [$this, 'beforeModelSave']);
- $this->model->bindEvent('model.afterSetAttribute', [$this, 'setModelAttribute']);
+ $this->model->bindEvent('model.setAttribute', [$this, 'setModelAttribute']);
/*
* Parse the config
diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php
index 9c620101d..f6b0d54c7 100644
--- a/modules/system/classes/UpdateManager.php
+++ b/modules/system/classes/UpdateManager.php
@@ -392,13 +392,18 @@ class UpdateManager
* Remove the plugin database and version
*/
if (!($plugin = $this->pluginManager->findByIdentifier($name))) {
- $this->note('Unable to find: ' . $name);
- return;
+ if ($this->versionManager->purgePlugin($name)) {
+ $this->note('Purged from database: ' . $name);
+ return $this;
+ }
}
- if ($this->versionManager->removePlugin($plugin))
+ if ($this->versionManager->removePlugin($plugin)) {
$this->note('Rolled back: ' . $name);
+ return $this;
+ }
+ $this->note('Unable to find: ' . $name);
return $this;
}
diff --git a/modules/system/classes/VersionManager.php b/modules/system/classes/VersionManager.php
index 2d08fe909..f80f8b1d5 100644
--- a/modules/system/classes/VersionManager.php
+++ b/modules/system/classes/VersionManager.php
@@ -172,6 +172,24 @@ class VersionManager
return true;
}
+ /**
+ * Deletes all records from the version and history tables for a plugin.
+ * @param string $pluginCode Plugin code
+ * @return void
+ */
+ public function purgePlugin($pluginCode)
+ {
+ $versions = Db::table('system_plugin_versions')->where('code', $pluginCode);
+ if ($countVersions = $versions->count())
+ $versions->delete();
+
+ $history = Db::table('system_plugin_history')->where('code', $pluginCode);
+ if ($countHistory = $history->count())
+ $history->delete();
+
+ return (($countHistory + $countVersions) > 0) ? true : false;
+ }
+
//
// File representation
//
diff --git a/modules/system/models/PluginVersion.php b/modules/system/models/PluginVersion.php
index 7da6df771..ff99da568 100644
--- a/modules/system/models/PluginVersion.php
+++ b/modules/system/models/PluginVersion.php
@@ -15,6 +15,8 @@ class PluginVersion extends Model
protected static $versionCache = null;
+ public $orphaned = false;
+
/**
* After the model is populated
*/
@@ -33,6 +35,12 @@ class PluginVersion extends Model
$this->{$attribute} = $info;
}
}
+ else {
+ $this->name = $this->code;
+ $this->description = 'Plugin has been removed from the file system.';
+ $this->orphaned = true;
+ }
+
}
/**