X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FnukeNS.php;h=0326e02308426cea7079e0075363d84c60c4fe85;hb=b12086b6188886cefba2dac518fc7d589a0148c6;hp=64bf1b6fa933fbc66d9da9766a2e4f0b175400f8;hpb=f0edb3e368a5fc69218d20f76f1538b68f37db42;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index 64bf1b6fa9..0326e02308 100644 --- a/maintenance/nukeNS.php +++ b/maintenance/nukeNS.php @@ -44,7 +44,7 @@ require_once __DIR__ . '/Maintenance.php'; class NukeNS extends Maintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Remove pages with only 1 revision from any namespace"; + $this->addDescription( 'Remove pages with only 1 revision from any namespace' ); $this->addOption( 'delete', "Actually delete the page" ); $this->addOption( 'ns', 'Namespace to delete from, default NS_MEDIAWIKI', false, true ); $this->addOption( 'all', 'Delete everything regardless of revision count' ); @@ -54,8 +54,8 @@ class NukeNS extends Maintenance { $ns = $this->getOption( 'ns', NS_MEDIAWIKI ); $delete = $this->getOption( 'delete', false ); $all = $this->getOption( 'all', false ); - $dbw = wfGetDB( DB_MASTER ); - $dbw->begin( __METHOD__ ); + $dbw = $this->getDB( DB_MASTER ); + $this->beginTransaction( $dbw, __METHOD__ ); $tbl_pag = $dbw->tableName( 'page' ); $tbl_rev = $dbw->tableName( 'revision' ); @@ -70,7 +70,7 @@ class NukeNS extends Maintenance { // Get corresponding revisions $res2 = $dbw->query( "SELECT rev_id FROM $tbl_rev WHERE rev_page = $id" ); - $revs = array(); + $revs = []; foreach ( $res2 as $row2 ) { $revs[] = $row2->rev_id; @@ -86,7 +86,7 @@ class NukeNS extends Maintenance { // I already have the id & revs if ( $delete ) { $dbw->query( "DELETE FROM $tbl_pag WHERE page_id = $id" ); - $dbw->commit( __METHOD__ ); + $this->commitTransaction( $dbw, __METHOD__ ); // Delete revisions as appropriate $child = $this->runChild( 'NukePage', 'nukePage.php' ); $child->deleteRevisions( $revs ); @@ -97,7 +97,7 @@ class NukeNS extends Maintenance { $this->output( "skip: " . $title->getPrefixedText() . "\n" ); } } - $dbw->commit( __METHOD__ ); + $this->commitTransaction( $dbw, __METHOD__ ); if ( $n_deleted > 0 ) { # update statistics - better to decrement existing count, or just count @@ -106,8 +106,8 @@ class NukeNS extends Maintenance { $pages -= $n_deleted; $dbw->update( 'site_stats', - array( 'ss_total_pages' => $pages ), - array( 'ss_row_id' => 1 ), + [ 'ss_total_pages' => $pages ], + [ 'ss_row_id' => 1 ], __METHOD__ ); }