* Let followRedirect() *always* work correctly by working from the article text.
* This ensures that we're not falsely looking up data from another version and that we're not missing interwik and fragment data.
Should clean up both bug 13754 (editing old version of redirect sometimes gives the target page text)
and bug 13752 (bugs with fragments and probably interwikis in redirect target).
Haven't been able to repro 13754 at home though, so we'll see.
/**
* Get the Title object this page redirects to
*
/**
* Get the Title object this page redirects to
*
- * @param bool $getFragment should the fragment be set on the title
* @return mixed false, Title of in-wiki target, or string with URL
*/
* @return mixed false, Title of in-wiki target, or string with URL
*/
- function followRedirect( $getFragment = false ) {
- if( $getFragment )
- // We'll need to use the content of this page, as Article::getRedirectTarget()
- // now loads the data from redirect table, wich doesn't store the fragment
- $rt = Title::newFromRedirect( $this->getContent() );
- else
- $rt = $this->getRedirectTarget();
+ function followRedirect() {
+ $text = $this->getContent();
+ $rt = Title::newFromRedirect( $text );
# process if title object is valid and not special:userlogout
if( $rt ) {
# process if title object is valid and not special:userlogout
if( $rt ) {
- elseif ( $rt = $this->getRedirectTarget() ) {
+ elseif ( $rt = Title::newFromRedirect( $text ) ) {
# Display redirect
$imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
# Display redirect
$imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
$imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
// Follow redirects only for... redirects
if( $article->mIsRedirect ) {
// Follow redirects only for... redirects
if( $article->mIsRedirect ) {
- $target = $article->followRedirect( true /* getFragment */ );
+ $target = $article->followRedirect();
if( is_string( $target ) ) {
if( !$this->getVal( 'DisableHardRedirects' ) ) {
// we'll need to redirect
if( is_string( $target ) ) {
if( !$this->getVal( 'DisableHardRedirects' ) ) {
// we'll need to redirect