From 335a38a456b6ca97b053610e869734892d1f14e7 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 8 Jun 2012 09:02:35 +0200 Subject: [PATCH] make isValidMoveTarget() use content object instead of regular expressions --- includes/Title.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 71d8f16d5e..4a28dca91b 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3873,24 +3873,24 @@ class Title { if( !is_object( $rev ) ){ return false; } - $text = $rev->getText(); + $content = $rev->getContent(); # Does the redirect point to the source? # Or is it a broken self-redirect, usually caused by namespace collisions? - $m = array(); - if ( preg_match( "/\\[\\[\\s*([^\\]\\|]*)]]/", $text, $m ) ) { - $redirTitle = Title::newFromText( $m[1] ); - if ( !is_object( $redirTitle ) || - ( $redirTitle->getPrefixedDBkey() != $this->getPrefixedDBkey() && - $redirTitle->getPrefixedDBkey() != $nt->getPrefixedDBkey() ) ) { + $redirTitle = $content->getRedirectTarget(); + + if ( $redirTitle ) { + if ( $redirTitle->getPrefixedDBkey() != $this->getPrefixedDBkey() && + $redirTitle->getPrefixedDBkey() != $nt->getPrefixedDBkey() ) { wfDebug( __METHOD__ . ": redirect points to other page\n" ); return false; + } else { + return true; } } else { - # Fail safe - wfDebug( __METHOD__ . ": failsafe\n" ); + # Fail safe (not a redirect after all. strange.) + wfDebug( __METHOD__ . ": failsafe: database sais " . $nt->getPrefixedDBkey() . " is a redirect, but it doesn't contain a valid redirect.\n" ); return false; } - return true; } /** -- 2.20.1