jenkins-bot has submitted this change and it was merged.

Change subject: Pass context to FormatMetadata class on ImagePage
......................................................................


Pass context to FormatMetadata class on ImagePage

This avoids on image page:
ContextSource::getContext (FormatMetadata): called and $context is null.
Using RequestContext::getMain() for sanity

Change-Id: I92774e1a88f03d44967d1797c6c2b8a31c1b10fc
---
M includes/filerepo/file/File.php
M includes/media/ExifBitmap.php
M includes/media/GIF.php
M includes/media/MediaHandler.php
M includes/media/PNG.php
M includes/media/SVG.php
M includes/page/ImagePage.php
7 files changed, 20 insertions(+), 13 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index df85f9c..eec8d21 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -1765,14 +1765,15 @@
        }
 
        /**
+        * @param bool|IContextSource $context Context to use (optional)
         * @return bool
         */
-       function formatMetadata() {
+       function formatMetadata( $context = false ) {
                if ( !$this->getHandler() ) {
                        return false;
                }
 
-               return $this->getHandler()->formatMetadata( $this, 
$this->getMetadata() );
+               return $this->getHandler()->formatMetadata( $this, $context );
        }
 
        /**
diff --git a/includes/media/ExifBitmap.php b/includes/media/ExifBitmap.php
index b7657cb..f56a947 100644
--- a/includes/media/ExifBitmap.php
+++ b/includes/media/ExifBitmap.php
@@ -125,15 +125,16 @@
 
        /**
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
                }
 
-               return $this->formatMetadataHelper( $meta );
+               return $this->formatMetadataHelper( $meta, $context );
        }
 
        public function getCommonMetaArray( File $file ) {
diff --git a/includes/media/GIF.php b/includes/media/GIF.php
index 5992be1..e3621fb 100644
--- a/includes/media/GIF.php
+++ b/includes/media/GIF.php
@@ -44,15 +44,16 @@
 
        /**
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
                }
 
-               return $this->formatMetadataHelper( $meta );
+               return $this->formatMetadataHelper( $meta, $context );
        }
 
        /**
diff --git a/includes/media/MediaHandler.php b/includes/media/MediaHandler.php
index b88a1b1..0103946 100644
--- a/includes/media/MediaHandler.php
+++ b/includes/media/MediaHandler.php
@@ -507,9 +507,10 @@
         * to some standard. That makes it possible to do things like visual
         * indication of grouped and chained streams in ogg container files.
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                return false;
        }
 
@@ -520,15 +521,16 @@
         * This is used by the media handlers that use the FormatMetadata class
         *
         * @param array $metadataArray Metadata array
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array Array for use displaying metadata.
         */
-       function formatMetadataHelper( $metadataArray ) {
+       function formatMetadataHelper( $metadataArray, $context = false ) {
                $result = array(
                        'visible' => array(),
                        'collapsed' => array()
                );
 
-               $formatted = FormatMetadata::getFormattedData( $metadataArray );
+               $formatted = FormatMetadata::getFormattedData( $metadataArray, 
$context );
                // Sort fields into visible and collapsed
                $visibleFields = $this->visibleMetadataFields();
                foreach ( $formatted as $name => $value ) {
diff --git a/includes/media/PNG.php b/includes/media/PNG.php
index 3cf8488..5f1aca5 100644
--- a/includes/media/PNG.php
+++ b/includes/media/PNG.php
@@ -49,15 +49,16 @@
 
        /**
         * @param File $image
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image ) {
+       function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
                }
 
-               return $this->formatMetadataHelper( $meta );
+               return $this->formatMetadataHelper( $meta, $context );
        }
 
        /**
diff --git a/includes/media/SVG.php b/includes/media/SVG.php
index 53abfef..0618f7e 100644
--- a/includes/media/SVG.php
+++ b/includes/media/SVG.php
@@ -410,9 +410,10 @@
 
        /**
         * @param File $file
+        * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $file ) {
+       function formatMetadata( $file, $context = false ) {
                $result = array(
                        'visible' => array(),
                        'collapsed' => array()
diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php
index b8f67c2..803e425 100644
--- a/includes/page/ImagePage.php
+++ b/includes/page/ImagePage.php
@@ -140,7 +140,7 @@
 
                if ( $wgShowEXIF && $this->displayImg->exists() ) {
                        // @todo FIXME: Bad interface, see note on 
MediaHandler::formatMetadata().
-                       $formattedMetadata = 
$this->displayImg->formatMetadata();
+                       $formattedMetadata = $this->displayImg->formatMetadata( 
$this->getContext() );
                        $showmeta = $formattedMetadata !== false;
                } else {
                        $showmeta = false;

-- 
To view, visit https://gerrit.wikimedia.org/r/182002
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I92774e1a88f03d44967d1797c6c2b8a31c1b10fc
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to