merging latest master
[lhc/web/wiklou.git] / includes / job / DoubleRedirectJob.php
index 4e02258..6a81b27 100644 (file)
@@ -36,7 +36,7 @@ class DoubleRedirectJob extends Job {
 
        /**
         * Insert jobs into the job queue to fix redirects to the given title
-        * @param $reason String: the reason for the fix, see message double-redirect-fixed-<reason>
+        * @param $reason String: the reason for the fix, see message "double-redirect-fixed-<reason>"
         * @param $redirTitle Title: the title which has changed, redirects pointing to this title are fixed
         * @param $destTitle bool Not used
         */
@@ -94,16 +94,17 @@ class DoubleRedirectJob extends Job {
                        wfDebug( __METHOD__.": target redirect already deleted, ignoring\n" );
                        return true;
                }
-               $text = $targetRev->getText();
-               $currentDest = Title::newFromRedirect( $text );
+               $content = $targetRev->getContent();
+               $currentDest = $content->getRedirectTarget();
                if ( !$currentDest || !$currentDest->equals( $this->redirTitle ) ) {
                        wfDebug( __METHOD__.": Redirect has changed since the job was queued\n" );
                        return true;
                }
 
                # Check for a suppression tag (used e.g. in periodically archived discussions)
+               $text = ContentHandler::getContentText( $content );
                $mw = MagicWord::get( 'staticredirect' );
-               if ( $mw->match( $text ) ) {
+               if ( $mw->match( $text ) ) { #FIXME: add support for this to ContentHandler/Content
                        wfDebug( __METHOD__.": skipping: suppressed with __STATICREDIRECT__\n" );
                        return true;
                }
@@ -129,7 +130,7 @@ class DoubleRedirectJob extends Job {
                # so the regex has to be fairly general
                $newText = preg_replace( '/ \[ \[  [^\]]*  \] \] /x',
                        '[[' . $newTitle->getFullText() . ']]',
-                       $text, 1 );
+                       $text, 1 ); #FIXME: need a way to do this via ContentHandler!
 
                if ( $newText === $text ) {
                        $this->setLastError( 'Text unchanged???' );
@@ -141,8 +142,9 @@ class DoubleRedirectJob extends Job {
                $oldUser = $wgUser;
                $wgUser = $this->getUser();
                $article = WikiPage::factory( $this->title );
-               $reason = wfMsgForContent( 'double-redirect-fixed-' . $this->reason,
-                       $this->redirTitle->getPrefixedText(), $newTitle->getPrefixedText() );
+               $reason = wfMessage( 'double-redirect-fixed-' . $this->reason,
+                       $this->redirTitle->getPrefixedText(), $newTitle->getPrefixedText()
+               )->inContentLanguage()->text();
                $article->doEdit( $newText, $reason, EDIT_UPDATE | EDIT_SUPPRESS_RC, false, $this->getUser() );
                $wgUser = $oldUser;
 
@@ -194,7 +196,7 @@ class DoubleRedirectJob extends Job {
         */
        function getUser() {
                if ( !self::$user ) {
-                       self::$user = User::newFromName( wfMsgForContent( 'double-redirect-fixer' ), false );
+                       self::$user = User::newFromName( wfMessage( 'double-redirect-fixer' )->inContentLanguage()->text(), false );
                        # FIXME: newFromName could return false on a badly configured wiki.
                        if ( !self::$user->isLoggedIn() ) {
                                self::$user->addToDatabase();