Cast namespaceId to int in SpecialEditWatchlist::cleanupWatchlist
[lhc/web/wiklou.git] / maintenance / cleanupCaps.php
index 9e88c13..641250d 100644 (file)
@@ -37,29 +37,32 @@ require_once __DIR__ . '/cleanupTable.inc';
  * @ingroup Maintenance
  */
 class CapsCleanup extends TableCleanup {
+
+       private $user;
+
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Script to cleanup capitalization";
+               $this->addDescription( 'Script to cleanup capitalization' );
                $this->addOption( 'namespace', 'Namespace number to run caps cleanup on', false, true );
        }
 
        public function execute() {
-               global $wgCapitalLinks, $wgUser;
+               global $wgCapitalLinks;
 
                if ( $wgCapitalLinks ) {
                        $this->error( "\$wgCapitalLinks is on -- no need for caps links cleanup.", true );
                }
 
-               $wgUser = User::newFromName( 'Conversion script' );
+               $this->user = User::newSystemUser( 'Conversion script', [ 'steal' => true ] );
 
                $this->namespace = intval( $this->getOption( 'namespace', 0 ) );
                $this->dryrun = $this->hasOption( 'dry-run' );
 
-               $this->runTable( array(
+               $this->runTable( [
                        'table' => 'page',
-                       'conds' => array( 'page_namespace' => $this->namespace ),
+                       'conds' => [ 'page_namespace' => $this->namespace ],
                        'index' => 'page_id',
-                       'callback' => 'processRow' ) );
+                       'callback' => 'processRow' ] );
        }
 
        protected function processRow( $row ) {
@@ -87,7 +90,9 @@ class CapsCleanup extends TableCleanup {
                        $this->output( "\"$display\" -> \"$targetDisplay\": DRY RUN, NOT MOVED\n" );
                        $ok = true;
                } else {
-                       $ok = $current->moveTo( $target, false, 'Converting page titles to lowercase' );
+                       $mp = new MovePage( $current, $target );
+                       $status = $mp->move( $this->user, 'Converting page titles to lowercase', true );
+                       $ok = $status->isOK() ? 'OK' : $status->getWikiText();
                        $this->output( "\"$display\" -> \"$targetDisplay\": $ok\n" );
                }
                if ( $ok === true ) {