(bug 18487) Another fix for r48379: move up getMemcKey() as well
[lhc/web/wiklou.git] / includes / DoubleRedirectJob.php
index 41f5a2e..889beec 100644 (file)
@@ -66,6 +66,13 @@ class DoubleRedirectJob extends Job {
                        return true;
                }
 
+               # Check for a suppression tag (used e.g. in periodically archived discussions)
+               $mw = MagicWord::get( 'staticredirect' );
+               if ( $mw->match( $text ) ) {
+                       wfDebug( __METHOD__.": skipping: suppressed with __STATICREDIRECT__\n" );
+                       return true;
+               }
+
                # Find the current final destination
                $newTitle = self::getFinalDestination( $this->redirTitle );
                if ( !$newTitle ) {
@@ -78,11 +85,15 @@ class DoubleRedirectJob extends Job {
                        wfDebug( __METHOD__.": skipping, already good\n" );
                }
 
+               # Preserve fragment (bug 14904)
+               $newTitle = Title::makeTitle( $newTitle->getNamespace(), $newTitle->getDBkey(), 
+                       $currentDest->getFragment() );
+
                # Fix the text
                # Remember that redirect pages can have categories, templates, etc.,
                # so the regex has to be fairly general
                $newText = preg_replace( '/ \[ \[  [^\]]*  \] \] /x', 
-                       '[[' . $newTitle->getPrefixedText() . ']]',
+                       '[[' . $newTitle->getFullText() . ']]',
                        $text, 1 );
 
                if ( $newText === $text ) {