Revert r37006 -- causes fatal errors:
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 4 Jul 2008 00:04:58 +0000 (00:04 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 4 Jul 2008 00:04:58 +0000 (00:04 +0000)
PHP Fatal error:  Using $this when not in object context in Article.php on line 135

docs/hooks.txt
includes/Article.php
includes/Wiki.php

index ab7ccdc..de06b14 100644 (file)
@@ -698,12 +698,6 @@ $page: ImagePage object
 &$file: File object
 &$displayFile: displayed File object
 
-'InitializeArticleMaybeRedirect': MediaWiki check to see if title is a redirect
-$title: Title object ($wgTitle)
-$request: WebRequest
-$ignoreRedirect: boolean to skip redirect check
-$target: Title/string of redirect target
-
 'InitPreferencesForm': called at the end of PreferencesForm's constructor
 $form: the PreferencesForm
 $request: the web request to initialized from
index aa200d9..fecc434 100644 (file)
@@ -111,18 +111,10 @@ class Article {
         *
         * @return mixed false, Title of in-wiki target, or string with URL
         */
-       public function followRedirect() {
+       function followRedirect() {
                $text = $this->getContent();
-               return self::followRedirectText( $text );
-       }
-       
-       /**
-        * Get the Title object this text redirects to
-        *
-        * @return mixed false, Title of in-wiki target, or string with URL
-        */
-       public static function followRedirectText( $text ) {
                $rt = Title::newFromRedirect( $text );
+
                # process if title object is valid and not special:userlogout
                if( $rt ) {
                        if( $rt->getInterwiki() != '' ) {
@@ -152,6 +144,7 @@ class Article {
                                return $rt;
                        }
                }
+
                // No or invalid redirect
                return false;
        }
index fa49290..a1bb307 100644 (file)
@@ -43,7 +43,7 @@ class MediaWiki {
         * Initialization of ... everything
         * Performs the request too
         *
-        * @param $title Title ($wgTitle)
+        * @param $title Title
         * @param $article Article
         * @param $output OutputPage
         * @param $user User
@@ -264,7 +264,7 @@ class MediaWiki {
         * Initialize the object to be known as $wgArticle for "standard" actions
         * Create an Article object for the page, following redirects if needed.
         *
-        * @param $title Title ($wgTitle)
+        * @param $title Title
         * @param $request WebRequest
         * @return mixed an Article, or a string to redirect to another URL
         */
@@ -280,22 +280,18 @@ class MediaWiki {
                // Check for redirects ...
                $file = $title->getNamespace() == NS_IMAGE ? $article->getFile() : null;
                if( ( $action == 'view' || $action == 'render' )        // ... for actions that show content
-                                       && !$request->getVal( 'oldid' ) &&    // ... and are not old revisions
+                                       && !$request->getVal( 'oldid' ) &&                      // ... and are not old revisions
                                        $request->getVal( 'redirect' ) != 'no' &&       // ... unless explicitly told not to
-                                       // ... and the article is not a non-redirect image page with associated file
-                                       !( is_object( $file ) && $file->exists() && !$file->getRedirected() ) ) {
-
-                       # Give extensions a change to ignore/handle redirects as needed
-                       $ignoreRedirect = $target = false;
-                       wfRunHooks( 'InitializeArticleMaybeRedirect', array( &$title, &$request, &$ignoreRedirect, &$target ) );
+                                       // ... and the article is not an image page with associated file
+                                       !( is_object( $file ) && $file->exists() &&
+                                                       !$file->getRedirected() ) ) { // ... unless it is really an image redirect
 
                        $dbr = wfGetDB( DB_SLAVE );
                        $article->loadPageData( $article->pageDataFromTitle( $dbr, $title ) );
 
                        // Follow redirects only for... redirects
-                       if( !$ignoreRedirect && $article->isRedirect() ) {
-                               # Is the target already set by an extension?
-                               $target = $target ? $target : $article->followRedirect();
+                       if( $article->isRedirect() ) {
+                               $target = $article->followRedirect();
                                if( is_string( $target ) ) {
                                        if( !$this->getVal( 'DisableHardRedirects' ) ) {
                                                // we'll need to redirect
@@ -307,7 +303,9 @@ class MediaWiki {
                                        // Rewrite environment to redirected article
                                        $rarticle = self::articleFromTitle( $target );
                                        $rarticle->loadPageData( $rarticle->pageDataFromTitle( $dbr, $target ) );
-                                       if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
+                                       if ( $rarticle->getTitle()->exists() || 
+                                                               ( is_object( $file ) && 
+                                                               !$file->isLocal() ) ) {
                                                $rarticle->setRedirectedFrom( $title );
                                                $article = $rarticle;
                                                $title = $target;