Merge "Add `showThumbnails` option to slideshow galleries"
[lhc/web/wiklou.git] / includes / page / ImagePage.php
index 106911c..b60b010 100644 (file)
@@ -52,18 +52,6 @@ class ImagePage extends Article {
                return new WikiFilePage( $title );
        }
 
-       /**
-        * Constructor from a page id
-        * @param int $id Article ID to load
-        * @return ImagePage|null
-        */
-       public static function newFromID( $id ) {
-               $t = Title::newFromID( $id );
-               # @todo FIXME: Doesn't inherit right
-               return $t == null ? null : new self( $t );
-               # return $t == null ? null : new static( $t ); // PHP 5.3
-       }
-
        /**
         * @param File $file
         * @return void
@@ -81,6 +69,7 @@ class ImagePage extends Article {
                $this->fileLoaded = true;
 
                $this->displayImg = $img = false;
+
                Hooks::run( 'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
                if ( !$img ) { // not set by hook?
                        $img = wfFindFile( $this->getTitle() );
@@ -222,11 +211,11 @@ class ImagePage extends Article {
                                $out->addStyle( $css );
                        }
                }
-               // always show the local local Filepage.css, bug 29277
-               $out->addModuleStyles( 'filepage' );
 
-               // Add MediaWiki styles for a file page
-               $out->addModuleStyles( 'mediawiki.action.view.filepage' );
+               $out->addModuleStyles( [
+                       'filepage', // always show the local local Filepage.css, bug 29277
+                       'mediawiki.action.view.filepage', // Add MediaWiki styles for a file page
+               ] );
        }
 
        /**
@@ -347,7 +336,10 @@ class ImagePage extends Article {
                        $filename = wfEscapeWikiText( $this->displayImg->getName() );
                        $linktext = $filename;
 
-                       Hooks::run( 'ImageOpenShowImageInlineBefore', [ &$this, &$out ] );
+                       // Use of &$this in hooks triggers warnings in PHP 7.1
+                       $imagePage = $this;
+
+                       Hooks::run( 'ImageOpenShowImageInlineBefore', [ &$imagePage, &$out ] );
 
                        if ( $this->displayImg->allowInlineDisplay() ) {
                                # image
@@ -809,7 +801,7 @@ EOT
         * @return ResultWrapper
         */
        protected function queryImageLinks( $target, $limit ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
 
                return $dbr->select(
                        [ 'imagelinks', 'page' ],