X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FnukeNS.php;h=ee1f59c1243e617ce423936198946d8ed968f37e;hb=f85bd77b633ed7e4cacef53b436a090b4fb4298c;hp=0f2dbf64ff686f3a01d40e1a5e737fa6f33238e4;hpb=072e84d2480446f3b76c6cffe9cd414de5b0860c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index 0f2dbf64ff..ee1f59c124 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' ); @@ -52,8 +52,8 @@ class NukeNS extends Maintenance { public function execute() { $ns = $this->getOption( 'ns', NS_MEDIAWIKI ); - $delete = $this->getOption( 'delete', false ); - $all = $this->getOption( 'all', false ); + $delete = $this->hasOption( 'delete' ); + $all = $this->hasOption( 'all' ); $dbw = $this->getDB( DB_MASTER ); $this->beginTransaction( $dbw, __METHOD__ ); @@ -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; @@ -88,7 +88,7 @@ class NukeNS extends Maintenance { $dbw->query( "DELETE FROM $tbl_pag WHERE page_id = $id" ); $this->commitTransaction( $dbw, __METHOD__ ); // Delete revisions as appropriate - $child = $this->runChild( 'NukePage', 'nukePage.php' ); + $child = $this->runChild( NukePage::class, 'nukePage.php' ); $child->deleteRevisions( $revs ); $this->purgeRedundantText( true ); $n_deleted++; @@ -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__ ); } @@ -118,5 +118,5 @@ class NukeNS extends Maintenance { } } -$maintClass = "NukeNS"; +$maintClass = NukeNS::class; require_once RUN_MAINTENANCE_IF_MAIN;