diff --git a/wire/modules/System/SystemUpdater/SystemUpdate20.php b/wire/modules/System/SystemUpdater/SystemUpdate20.php new file mode 100644 index 00000000..9f2b8195 --- /dev/null +++ b/wire/modules/System/SystemUpdater/SystemUpdate20.php @@ -0,0 +1,29 @@ +wire()->addHookAfter('ProcessWire::ready', $this, 'executeAtReady'); + return 0; // indicates we will update system version ourselves when ready + } + public function executeAtReady() { + $database = $this->wire()->database; + $config = $this->wire()->config; + /** @var User $u */ + $u = $this->wire()->users->get($config->superUserPageID); + $superuserId = $u->id && $u->isSuperuser() ? $u->id : 0; + $sql = 'UPDATE pages SET created_users_id=:superuser_id WHERE created_users_id=:admin_page_id'; + $query = $database->prepare($sql); + $query->bindValue(':superuser_id', $superuserId, \PDO::PARAM_INT); + $query->bindValue(':admin_page_id', $config->adminRootPageID, \PDO::PARAM_INT); + $query->execute(); + $rowCount = $query->rowCount(); + if($rowCount) $this->message("Updated $rowCount page(s) for correct created_users_id"); + $this->updater->saveSystemVersion(20); + } +} + + diff --git a/wire/modules/System/SystemUpdater/SystemUpdater.module b/wire/modules/System/SystemUpdater/SystemUpdater.module index 9e3870da..9d37f1cf 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' => 19, + 'version' => 20, ); }