From d98b4055745b477d577bdcda1f99ae7932c14601 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Wed, 30 Dec 2020 12:54:47 -0500 Subject: [PATCH] Add System Update #19, which removes a few redundant legacy entries from modules table --- .../System/SystemUpdater/SystemUpdate19.php | 28 +++++++++++++++++++ .../System/SystemUpdater/SystemUpdater.module | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 wire/modules/System/SystemUpdater/SystemUpdate19.php diff --git a/wire/modules/System/SystemUpdater/SystemUpdate19.php b/wire/modules/System/SystemUpdater/SystemUpdate19.php new file mode 100644 index 00000000..1daeb51d --- /dev/null +++ b/wire/modules/System/SystemUpdater/SystemUpdate19.php @@ -0,0 +1,28 @@ +wire()->addHookAfter('ProcessWire::ready', $this, 'executeAtReady'); + return 0; // indicates we will update system version ourselves when ready + } + public function executeAtReady() { + $database = $this->wire()->database; + $modules = $this->wire()->modules; + $query = $database->prepare('DELETE FROM modules WHERE class=:name'); + $qty = 0; + foreach(array('ProcessPage', 'InputfieldWrapper', 'FieldtypeNumber') as $name) { + if($modules->isInstalled($name)) continue; + $query->bindValue(':name', $name); + $query->execute(); + if($query->rowCount()) $qty++; + } + $query->closeCursor(); + if($qty) $this->message("Removed $qty redundant modules table entries", Notice::debug); + $this->updater->saveSystemVersion(19); + } +} + diff --git a/wire/modules/System/SystemUpdater/SystemUpdater.module b/wire/modules/System/SystemUpdater/SystemUpdater.module index 2d98e241..9e3870da 100644 --- a/wire/modules/System/SystemUpdater/SystemUpdater.module +++ b/wire/modules/System/SystemUpdater/SystemUpdater.module @@ -26,7 +26,7 @@ class SystemUpdater extends WireData implements Module, ConfigurableModule { * This version number is important, as this updater keeps the systemVersion up with this version * */ - 'version' => 18, + 'version' => 19, ); }