Chad has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/367929 )
Change subject: Add simple clenaup script for old minerva preferences ...................................................................... Add simple clenaup script for old minerva preferences Based on my other work in core Bug: T171644 Change-Id: Ibca378b9b137dd9af980a87c747de96aa326cfa5 --- A maintenance/cleanupOldPrefs.php 1 file changed, 94 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/MinervaNeue refs/changes/29/367929/1 diff --git a/maintenance/cleanupOldPrefs.php b/maintenance/cleanupOldPrefs.php new file mode 100644 index 0000000..010e403 --- /dev/null +++ b/maintenance/cleanupOldPrefs.php @@ -0,0 +1,94 @@ +<?php + +/** + * Clean up old user preferences from MobileFrontend and such + * + * 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 + */ + +$IP = getenv( 'MW_INSTALL_PATH' ); +if ( $IP === false ) { + $IP = __DIR__ . '/../../..'; +} +require_once "$IP/maintenance/Maintenance.php"; +require_once __DIR__ . '/../includes/Maintenance/Maintenance.php'; + +class CleanupMinervaPrefs extends Maintenance { + public function __construct() { + parent::__construct(); + $this->mDescription = 'Clean up old minerva preferences'; + $this->setBatchSize( 50 ); + $this->addOption( 'dry-run', 'Print debug info instead of actually deleting' ); + } + + public function execute() { + $dbw = $this->getDB( DB_MASTER ); + $this->output( "Cleanup up old Minerva prefs...\n" ); + $total = 0; + + while ( true ) { + $res = $dbw->select( + 'user_properties', + '*', // The table lacks a primary key, so select the whole row + [ + 'up_property' => 'skin', + 'up_value' => ['minerva', 'minerva-neue'], + ], + __METHOD__, + [ 'LIMIT' => $this->mBatchSize ] + ); + + $numRows = $res->numRows(); + $total += $numRows; + if ( $res->numRows() <= 0 ) { + // All done! + $this->output( "DONE! (handled $total entries)\n" ); + break; + } + + // Progress or something + $this->output( "..doing $numRows entries\n" ); + + // Delete our batch, then wait + foreach( $res as $row ) { + if ( $this->hasOption( 'dry-run' ) ) { + $this->output( + " DRY RUN, would fix: " . + "[up_user] => '{$row->up_user}' " . + "[up_property] => '{$row->up_property}' " . + "[up_value] => '{$row->up_value}'\n" + ); + continue; + } + $this->beginTransaction( $dbw, __METHOD__ ); + $dbw->update( + 'user_properties', + [ 'up_value' => 'minerva-neue' ], + [ + 'up_user' => $row->up_user, + 'up_property' => $row->up_property, + 'up_value' => $row->up_value, + ], + __METHOD__ + ); + $this->commitTransaction( $dbw, __METHOD__ ); + } + } + } +} + +$maintClass = 'CleanupPreferences'; // Tells it to run the class +require_once RUN_MAINTENANCE_IF_MAIN; -- To view, visit https://gerrit.wikimedia.org/r/367929 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibca378b9b137dd9af980a87c747de96aa326cfa5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/skins/MinervaNeue Gerrit-Branch: master Gerrit-Owner: Chad <ch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits