Merge "Ensure users are able to edit the page after changing the content model"
[lhc/web/wiklou.git] / includes / page / WikiFilePage.php
index 92a14af..c478550 100644 (file)
  * @ingroup Media
  */
 class WikiFilePage extends WikiPage {
-       /**
-        * @var File
-        */
+       /** @var File */
        protected $mFile = false;
+       /** @var LocalRepo */
        protected $mRepo = null;
+       /** @var bool */
        protected $mFileLoaded = false;
+       /** @var array */
        protected $mDupes = null;
 
        public function __construct( $title ) {
@@ -137,7 +138,7 @@ class WikiFilePage extends WikiPage {
                }
                $hash = $this->mFile->getSha1();
                if ( !( $hash ) ) {
-                       $this->mDupes = array();
+                       $this->mDupes = [];
                        return $this->mDupes;
                }
                $dupes = RepoGroup::singleton()->findBySha1( $hash );
@@ -161,29 +162,26 @@ class WikiFilePage extends WikiPage {
                return $this->mDupes;
        }
 
-       /**
-        * Override handling of action=purge
-        * @return bool
-        */
-       public function doPurge() {
+       public function doPurge( $flags = self::PURGE_ALL ) {
                $this->loadFile();
+
                if ( $this->mFile->exists() ) {
                        wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" );
                        DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ) );
-                       $this->mFile->upgradeRow();
-                       $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) );
+                       $this->mFile->purgeCache( [ 'forThumbRefresh' => true ] );
                } else {
                        wfDebug( 'ImagePage::doPurge no image for '
                                . $this->mFile->getName() . "; limiting purge to cache only\n" );
                        // even if the file supposedly doesn't exist, force any cached information
                        // to be updated (in case the cached information is wrong)
-                       $this->mFile->purgeCache( array( 'forThumbRefresh' => true ) );
+                       $this->mFile->purgeCache( [ 'forThumbRefresh' => true ] );
                }
                if ( $this->mRepo ) {
                        // Purge redirect cache
                        $this->mRepo->invalidateImageRedirect( $this->mTitle );
                }
-               return parent::doPurge();
+
+               return parent::doPurge( $flags );
        }
 
        /**
@@ -202,7 +200,7 @@ class WikiFilePage extends WikiPage {
 
                if ( !$file instanceof LocalFile ) {
                        wfDebug( __CLASS__ . '::' . __METHOD__ . " is not supported for this file\n" );
-                       return TitleArray::newFromResult( new FakeResultWrapper( array() ) );
+                       return TitleArray::newFromResult( new FakeResultWrapper( [] ) );
                }
 
                /** @var LocalRepo $repo */
@@ -210,18 +208,18 @@ class WikiFilePage extends WikiPage {
                $dbr = $repo->getSlaveDB();
 
                $res = $dbr->select(
-                       array( 'page', 'categorylinks' ),
-                       array(
+                       [ 'page', 'categorylinks' ],
+                       [
                                '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' ) )
+                       [],
+                       [ 'categorylinks' => [ 'INNER JOIN', 'page_id = cl_from' ] ]
                );
 
                return TitleArray::newFromResult( $res );