Merge "Drop index oi_name_archive_name on table oldimage"
[lhc/web/wiklou.git] / includes / page / ImagePage.php
index b60b010..f8202a6 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use Wikimedia\Rdbms\ResultWrapper;
+
 /**
  * Class for viewing MediaWiki file description pages
  *
@@ -213,7 +215,7 @@ class ImagePage extends Article {
                }
 
                $out->addModuleStyles( [
-                       'filepage', // always show the local local Filepage.css, bug 29277
+                       'filepage', // always show the local local Filepage.css, T31277
                        'mediawiki.action.view.filepage', // Add MediaWiki styles for a file page
                ] );
        }
@@ -336,7 +338,7 @@ class ImagePage extends Article {
                        $filename = wfEscapeWikiText( $this->displayImg->getName() );
                        $linktext = $filename;
 
-                       // Use of &$this in hooks triggers warnings in PHP 7.1
+                       // Avoid PHP 7.1 warning from passing $this by reference
                        $imagePage = $this;
 
                        Hooks::run( 'ImageOpenShowImageInlineBefore', [ &$imagePage, &$out ] );
@@ -534,7 +536,7 @@ class ImagePage extends Article {
                                // this will get messy.
                                // The dirmark, however, must not be immediately adjacent
                                // to the filename, because it can get copied with it.
-                               // See bug 25277.
+                               // See T27277.
                                // @codingStandardsIgnoreStart Ignore long line
                                $out->addWikiText( <<<EOT
 <div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
@@ -585,6 +587,8 @@ EOT
                } else {
                        # Image does not exist
                        if ( !$this->getId() ) {
+                               $dbr = wfGetDB( DB_REPLICA );
+
                                # No article exists either
                                # Show deletion log to be consistent with normal articles
                                LogEventsList::showLogExtract(
@@ -593,7 +597,7 @@ EOT
                                        $this->getTitle()->getPrefixedText(),
                                        '',
                                        [ 'lim' => 10,
-                                               'conds' => [ "log_action != 'revision'" ],
+                                               'conds' => [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ],
                                                'showIfEmpty' => false,
                                                'msgKey' => [ 'moveddeleted-notice' ]
                                        ]