mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 11:44:42 +02:00
Add system update 20 which corrects an issue in the DB where some original/core system pages had an incorrect (though inconsequential) created_users_id that referred to the admin page rather than the original admin user.
This commit is contained in:
29
wire/modules/System/SystemUpdater/SystemUpdate20.php
Normal file
29
wire/modules/System/SystemUpdater/SystemUpdate20.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php namespace ProcessWire;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Correct created_users_id on some pages from admin page ID to be default superuser ID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SystemUpdate20 extends SystemUpdate {
|
||||||
|
public function execute() {
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@@ -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
|
* This version number is important, as this updater keeps the systemVersion up with this version
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
'version' => 19,
|
'version' => 20,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user