<?php
+/**
+ * Job to fix double redirects after moving a page
+ *
+ * @ingroup JobQueue
+ */
class DoubleRedirectJob extends Job {
var $reason, $redirTitle, $destTitleText;
static $user;
/**
* Insert jobs into the job queue to fix redirects to the given title
- * @param string $type The reason for the fix, see message double-redirect-fixed-<reason>
- * @param Title $redirTitle The title which has changed, redirects pointing to this title are fixed
+ * @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 Not used
*/
public static function fixRedirects( $reason, $redirTitle, $destTitle = false ) {
# Need to use the master to get the redirect table updated in the same transaction
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 ) {
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 ) {
/**
* Get the final destination of a redirect
- * Returns false if the specified title is not a redirect, or if it is a circular redirect
+ * @return false if the specified title is not a redirect, or if it is a circular redirect
*/
public static function getFinalDestination( $title ) {
$dbw = wfGetDB( DB_MASTER );