Update formatting on includes/deferred/
[lhc/web/wiklou.git] / includes / WikiFilePage.php
index 9fb1522..2b192b0 100644 (file)
@@ -41,7 +41,9 @@ class WikiFilePage extends WikiPage {
        }
 
        public function getActionOverrides() {
-               return array( 'revert' => 'RevertFileAction' );
+               $overrides = parent::getActionOverrides();
+               $overrides['revert'] = 'RevertFileAction';
+               return $overrides;
        }
 
        /**
@@ -103,13 +105,12 @@ class WikiFilePage extends WikiPage {
        }
 
        /**
-        * @param bool $text
         * @return bool
         */
-       public function isRedirect( $text = false ) {
+       public function isRedirect() {
                $this->loadFile();
                if ( $this->mFile->isLocal() ) {
-                       return parent::isRedirect( $text );
+                       return parent::isRedirect();
                }
 
                return (bool)$this->mFile->getRedirected();
@@ -182,6 +183,51 @@ class WikiFilePage extends WikiPage {
                        // to be updated (in case the cached information is wrong)
                        $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) );
                }
+               if ( $this->mRepo ) {
+                       // Purge redirect cache
+                       $this->mRepo->invalidateImageRedirect( $this->mTitle );
+               }
                return parent::doPurge();
        }
+
+       /**
+        * Get the categories this file is a member of on the wiki where it was uploaded.
+        * For local files, this is the same as getCategories().
+        * For foreign API files (InstantCommons), this is not supported currently.
+        * Results will include hidden categories.
+        *
+        * @return TitleArray|Title[]
+        * @since 1.23
+        */
+       public function getForeignCategories() {
+               $this->loadFile();
+               $title = $this->mTitle;
+               $file = $this->mFile;
+
+               if ( ! $file instanceof LocalFile ) {
+                       wfDebug( __CLASS__ . '::' . __METHOD__ . ' is not supported for this file' );
+                       return TitleArray::newFromResult( new FakeResultWrapper( array() ) );
+               }
+
+               /** @var LocalRepo $repo */
+               $repo = $file->getRepo();
+               $dbr = $repo->getSlaveDB();
+
+               $res = $dbr->select(
+                       array( 'page', 'categorylinks' ),
+                       array(
+                               'page_title' => 'cl_to',
+                               'page_namespace' => NS_CATEGORY,
+                       ),
+                       array(
+                               'page_namespace' => $title->getNamespace(),
+                               'page_title' => $title->getDBkey(),
+                       ),
+                       __METHOD__,
+                       array(),
+                       array( 'categorylinks' => array( 'INNER JOIN', 'page_id = cl_from' ) )
+               );
+
+               return TitleArray::newFromResult( $res );
+       }
 }