Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/339792 )

Change subject: resourceloader: Add purgeModuleDeps.php maintenance script
......................................................................

resourceloader: Add purgeModuleDeps.php maintenance script

Based on cleanupRemovedModules.php.

Bug: T158105
Change-Id: I05f650a0cfa8ca647f143a40e1087338adbef6da
---
A maintenance/purgeModuleDeps.php
1 file changed, 59 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/92/339792/1

diff --git a/maintenance/purgeModuleDeps.php b/maintenance/purgeModuleDeps.php
new file mode 100644
index 0000000..c924b94
--- /dev/null
+++ b/maintenance/purgeModuleDeps.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Remove all cache entries for ResourceLoader modules from the database.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ * @author Timo Tijhof
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * Maintenance script to purge the module_deps database cache table.
+ *
+ * @ingroup Maintenance
+ */
+class PurgeModuleDeps extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+               $this->addDescription(
+                       'Remove all cache entries for ResourceLoader modules 
from the database' );
+               $this->addOption( 'batchsize', 'Delete rows in batches of this 
size. Default: 500', false, true );
+       }
+
+       public function execute() {
+               $dbw = $this->getDB( DB_MASTER );
+               $limit = max( 1, intval( $this->getOption( 'batchsize', 500 ) ) 
);
+
+               $this->output( "Cleaning up module_deps table...\n" );
+               $i = 1;
+               $modDeps = $dbw->tableName( 'module_deps' );
+               do {
+                       $dbw->query( "DELETE FROM $modDeps WHERE LIMIT $limit", 
__METHOD__ );
+                       $numRows = $dbw->affectedRows();
+                       $this->output( "Batch $i: $numRows rows\n" );
+                       $i++;
+                       wfWaitForSlaves();
+               } while ( $numRows > 0 );
+               $this->output( "done\n" );
+       }
+}
+
+$maintClass = 'PurgeModuleDeps';
+require_once RUN_MAINTENANCE_IF_MAIN;

-- 
To view, visit https://gerrit.wikimedia.org/r/339792
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I05f650a0cfa8ca647f143a40e1087338adbef6da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.29.0-wmf.13
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to