Moved MediaWiki::articleFromTitle() to Article::newFromTitle(), this has nothing...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 22 May 2011 18:38:04 +0000 (18:38 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 22 May 2011 18:38:04 +0000 (18:38 +0000)
includes/Article.php
includes/Wiki.php
includes/api/ApiPurge.php
includes/search/SearchEngine.php
index.php

index 1b23a67..807a029 100644 (file)
@@ -85,6 +85,40 @@ class Article {
                $this->mOldId = $oldId;
        }
 
+       /**
+        * Create an Article object of the appropriate class for the given page.
+        *
+        * @param $title Title
+        * @param $context RequestContext
+        * @return Article object
+        */
+       public static function newFromTitle( $title, RequestContext $context ) {
+               if ( NS_MEDIA == $title->getNamespace() ) {
+                       // FIXME: where should this go?
+                       $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
+               }
+
+               $article = null;
+               wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) );
+               if ( $article ) {
+                       $article->setContext( $context );
+                       return $article;
+               }
+
+               switch( $title->getNamespace() ) {
+                       case NS_FILE:
+                               $page = new ImagePage( $title );
+                               break;
+                       case NS_CATEGORY:
+                               $page = new CategoryPage( $title );
+                               break;
+                       default:
+                               $page = new Article( $title );
+               }
+               $page->setContext( $context );
+               return $page;
+       }
+
        /**
         * Constructor from an page id
         * @param $id Int article ID to load
index fe9b0e3..cf5856f 100644 (file)
@@ -228,34 +228,13 @@ class MediaWiki {
        /**
         * Create an Article object of the appropriate class for the given page.
         *
+        * @deprecated in 1.19; use Article::newFromTitle() instead
         * @param $title Title
         * @param $context RequestContext
         * @return Article object
         */
        public static function articleFromTitle( $title, RequestContext $context ) {
-               if ( NS_MEDIA == $title->getNamespace() ) {
-                       // @todo FIXME: Where should this go?
-                       $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
-               }
-
-               $article = null;
-               wfRunHooks( 'ArticleFromTitle', array( &$title, &$article ) );
-               if ( $article ) {
-                       return $article;
-               }
-
-               switch( $title->getNamespace() ) {
-                       case NS_FILE:
-                               $page = new ImagePage( $title );
-                               break;
-                       case NS_CATEGORY:
-                               $page = new CategoryPage( $title );
-                               break;
-                       default:
-                               $page = new Article( $title );
-               }
-               $page->setContext( $context );
-               return $page;
+               return Article::newFromTitle( $title, $context );
        }
 
        /**
@@ -302,7 +281,7 @@ class MediaWiki {
                wfProfileIn( __METHOD__ );
 
                $action = $this->context->request->getVal( 'action', 'view' );
-               $article = self::articleFromTitle( $this->context->title, $this->context );
+               $article = Article::newFromTitle( $this->context->title, $this->context );
                // NS_MEDIAWIKI has no redirects.
                // It is also used for CSS/JS, so performance matters here...
                if ( $this->context->title->getNamespace() == NS_MEDIAWIKI ) {
@@ -339,7 +318,7 @@ class MediaWiki {
                                }
                                if ( is_object( $target ) ) {
                                        // Rewrite environment to redirected article
-                                       $rarticle = self::articleFromTitle( $target, $this->context );
+                                       $rarticle = Article::newFromTitle( $target, $this->context );
                                        $rarticle->loadPageData();
                                        if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
                                                $rarticle->setRedirectedFrom( $this->context->title );
index 6f2635f..5757b0a 100644 (file)
@@ -69,7 +69,7 @@ class ApiPurge extends ApiBase {
                                continue;
                        }
                        $context = RequestContext::getMain();
-                       $article = MediaWiki::articleFromTitle( $title, $context );
+                       $article = Article::newFromTitle( $title, $context );
                        $article->doPurge(); // Directly purge and skip the UI part of purge().
                        $r['purged'] = '';
                        
index 1d82190..2941d7d 100644 (file)
@@ -177,7 +177,7 @@ class SearchEngine {
 
                        # See if it still otherwise has content is some sane sense
                        $context->setTitle( $title );
-                       $article = MediaWiki::articleFromTitle( $title, $context );
+                       $article = Article::newFromTitle( $title, $context );
                        if ( $article->hasViewableContent() ) {
                                return $title;
                        }
index ba325e0..309e3ad 100644 (file)
--- a/index.php
+++ b/index.php
@@ -124,7 +124,7 @@ function wfIndexMain() {
                                        $cache->loadFromFileCache();
                                }
                                # Do any stats increment/watchlist stuff
-                               $article = MediaWiki::articleFromTitle( $wgTitle, $context );
+                               $article = Article::newFromTitle( $wgTitle, $context );
                                $article->viewUpdates();
                                # Tell OutputPage that output is taken care of
                                $context->output->disable();