mirror of
https://github.com/processwire/processwire.git
synced 2025-08-15 11:14:12 +02:00
Add System Update #19, which removes a few redundant legacy entries from modules table
This commit is contained in:
28
wire/modules/System/SystemUpdater/SystemUpdate19.php
Normal file
28
wire/modules/System/SystemUpdater/SystemUpdate19.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php namespace ProcessWire;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear legacy and irrelevant entries from modules table
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SystemUpdate19 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;
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -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' => 18,
|
'version' => 19,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user