Merge "mw.Upload.BookletLayout: Better handle error messages from AbuseFilter and...
[lhc/web/wiklou.git] / includes / jobqueue / jobs / DoubleRedirectJob.php
index ab63896..3cd3448 100644 (file)
@@ -62,30 +62,30 @@ class DoubleRedirectJob extends Job {
                # Need to use the master to get the redirect table updated in the same transaction
                $dbw = wfGetDB( DB_MASTER );
                $res = $dbw->select(
-                       array( 'redirect', 'page' ),
-                       array( 'page_namespace', 'page_title' ),
-                       array(
+                       [ 'redirect', 'page' ],
+                       [ 'page_namespace', 'page_title' ],
+                       [
                                'page_id = rd_from',
                                'rd_namespace' => $redirTitle->getNamespace(),
                                'rd_title' => $redirTitle->getDBkey()
-                       ), __METHOD__ );
+                       ], __METHOD__ );
                if ( !$res->numRows() ) {
                        return;
                }
-               $jobs = array();
+               $jobs = [];
                foreach ( $res as $row ) {
                        $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                        if ( !$title ) {
                                continue;
                        }
 
-                       $jobs[] = new self( $title, array(
+                       $jobs[] = new self( $title, [
                                'reason' => $reason,
-                               'redirTitle' => $redirTitle->getPrefixedDBkey() ) );
+                               'redirTitle' => $redirTitle->getPrefixedDBkey() ] );
                        # Avoid excessive memory usage
                        if ( count( $jobs ) > 10000 ) {
                                JobQueueGroup::singleton()->push( $jobs );
-                               $jobs = array();
+                               $jobs = [];
                        }
                }
                JobQueueGroup::singleton()->push( $jobs );
@@ -167,7 +167,8 @@ class DoubleRedirectJob extends Job {
                $reason = wfMessage( 'double-redirect-fixed-' . $this->reason,
                        $this->redirTitle->getPrefixedText(), $newTitle->getPrefixedText()
                )->inContentLanguage()->text();
-               $article->doEditContent( $newContent, $reason, EDIT_UPDATE | EDIT_SUPPRESS_RC, false, $user );
+               $flags = EDIT_UPDATE | EDIT_SUPPRESS_RC | EDIT_INTERNAL;
+               $article->doEditContent( $newContent, $reason, $flags, false, $user );
                $wgUser = $oldUser;
 
                return true;
@@ -178,13 +179,14 @@ class DoubleRedirectJob extends Job {
         *
         * @param Title $title
         *
-        * @return bool If the specified title is not a redirect, or if it is a circular redirect
+        * @return Title|bool The final Title after following all redirects, or false if
+        *  the page is not a redirect or the redirect loops.
         */
        public static function getFinalDestination( $title ) {
                $dbw = wfGetDB( DB_MASTER );
 
                // Circular redirect check
-               $seenTitles = array();
+               $seenTitles = [];
                $dest = false;
 
                while ( true ) {
@@ -205,13 +207,13 @@ class DoubleRedirectJob extends Job {
                        }
 
                        $row = $dbw->selectRow(
-                               array( 'redirect', 'page' ),
-                               array( 'rd_namespace', 'rd_title', 'rd_interwiki' ),
-                               array(
+                               [ 'redirect', 'page' ],
+                               [ 'rd_namespace', 'rd_title', 'rd_interwiki' ],
+                               [
                                        'rd_from=page_id',
                                        'page_namespace' => $title->getNamespace(),
                                        'page_title' => $title->getDBkey()
-                               ), __METHOD__ );
+                               ], __METHOD__ );
                        if ( !$row ) {
                                # No redirect from here, chain terminates
                                break;