2017-02-24 22:56:31 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
2017-02-10 18:09:05 +00:00
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
2017-02-24 22:56:31 +00:00
|
|
|
|
|
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-08 21:31:25 +00:00
|
|
|
* Maintenance script to purge the module_deps database cache table for ResourceLoader.
|
2017-02-24 22:56:31 +00:00
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
|
|
|
|
class PurgeModuleDeps extends Maintenance {
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->addDescription(
|
|
|
|
|
'Remove all cache entries for ResourceLoader modules from the database' );
|
|
|
|
|
$this->setBatchSize( 500 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
$this->output( "Cleaning up module_deps table...\n" );
|
|
|
|
|
|
2021-04-29 02:37:11 +00:00
|
|
|
$dbw = $this->getDB( DB_PRIMARY );
|
2023-09-21 11:54:38 +00:00
|
|
|
$res = $dbw->newSelectQueryBuilder()
|
|
|
|
|
->select( [ 'md_module', 'md_skin' ] )
|
|
|
|
|
->from( 'module_deps' )
|
|
|
|
|
->caller( __METHOD__ )->fetchResultSet();
|
2017-02-24 22:56:31 +00:00
|
|
|
$rows = iterator_to_array( $res, false );
|
|
|
|
|
|
|
|
|
|
$modDeps = $dbw->tableName( 'module_deps' );
|
|
|
|
|
$i = 1;
|
2017-11-05 08:09:51 +00:00
|
|
|
foreach ( array_chunk( $rows, $this->getBatchSize() ) as $chunk ) {
|
2017-02-24 22:56:31 +00:00
|
|
|
// WHERE ( mod=A AND skin=A ) OR ( mod=A AND skin=B) ..
|
2021-02-07 02:17:10 +00:00
|
|
|
$conds = array_map( static function ( stdClass $row ) use ( $dbw ) {
|
2017-02-24 22:56:31 +00:00
|
|
|
return $dbw->makeList( (array)$row, IDatabase::LIST_AND );
|
|
|
|
|
}, $chunk );
|
|
|
|
|
$conds = $dbw->makeList( $conds, IDatabase::LIST_OR );
|
|
|
|
|
|
|
|
|
|
$this->beginTransaction( $dbw, __METHOD__ );
|
|
|
|
|
$dbw->query( "DELETE FROM $modDeps WHERE $conds", __METHOD__ );
|
|
|
|
|
$numRows = $dbw->affectedRows();
|
|
|
|
|
$this->output( "Batch $i: $numRows rows\n" );
|
|
|
|
|
$this->commitTransaction( $dbw, __METHOD__ );
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->output( "Done\n" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = PurgeModuleDeps::class;
|
2017-02-24 22:56:31 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|