media: Mark public MediaHandler/ImageHandler methods as such
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Mon, 25 Feb 2019 09:16:30 +0000 (10:16 +0100)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Mon, 25 Feb 2019 09:16:30 +0000 (10:16 +0100)
Note I'm intentionally not touching the entire file, but only methods
I'm absolutely sure are already called from outside, e.g. from
MediaHandlerFactory, and must be public because of this.

I'm intentionally not doing anything with private or protected in this
patch, as such changes are much more fragile.

This is a direct follow up for the changes proposed in Iaa4f60d.

Change-Id: Ida817b289ddd5e9a8c162cc1fa3335c639a0bbe5

15 files changed:
includes/media/BitmapHandler.php
includes/media/BitmapHandler_ClientOnly.php
includes/media/BmpHandler.php
includes/media/DjVuHandler.php
includes/media/ExifBitmapHandler.php
includes/media/GIFHandler.php
includes/media/ImageHandler.php
includes/media/JpegHandler.php
includes/media/MediaHandler.php
includes/media/PNGHandler.php
includes/media/SvgHandler.php
includes/media/TiffHandler.php
includes/media/TransformationalImageHandler.php
includes/media/XCFHandler.php
tests/phpunit/mocks/media/MockDjVuHandler.php

index e2d32cf..b8b706d 100644 (file)
@@ -91,7 +91,7 @@ class BitmapHandler extends TransformationalImageHandler {
         * @param array &$params
         * @return bool
         */
-       function normaliseParams( $image, &$params ) {
+       public function normaliseParams( $image, &$params ) {
                global $wgMaxInterlacingAreas;
                if ( !parent::normaliseParams( $image, $params ) ) {
                        return false;
index fa5b0a6..8e7998e 100644 (file)
@@ -37,7 +37,7 @@ class BitmapHandler_ClientOnly extends BitmapHandler {
         * @param array &$params
         * @return bool
         */
-       function normaliseParams( $image, &$params ) {
+       public function normaliseParams( $image, &$params ) {
                return ImageHandler::normaliseParams( $image, $params );
        }
 
index ed6e76f..09cbdac 100644 (file)
@@ -44,7 +44,7 @@ class BmpHandler extends BitmapHandler {
         * @param array|null $params
         * @return array
         */
-       function getThumbType( $text, $mime, $params = null ) {
+       public function getThumbType( $text, $mime, $params = null ) {
                return [ 'png', 'image/png' ];
        }
 
index 00dfb72..4413525 100644 (file)
@@ -32,7 +32,7 @@ class DjVuHandler extends ImageHandler {
        /**
         * @return bool
         */
-       function isEnabled() {
+       public function isEnabled() {
                global $wgDjvuRenderer, $wgDjvuDump, $wgDjvuToXML;
                if ( !$wgDjvuRenderer || ( !$wgDjvuDump && !$wgDjvuToXML ) ) {
                        wfDebug( "DjVu is disabled, please set \$wgDjvuRenderer and \$wgDjvuDump\n" );
@@ -353,7 +353,7 @@ class DjVuHandler extends ImageHandler {
                return $this->getDjVuImage( $image, $path )->getImageSize();
        }
 
-       function getThumbType( $ext, $mime, $params = null ) {
+       public function getThumbType( $ext, $mime, $params = null ) {
                global $wgDjvuOutputExtension;
                static $mime;
                if ( !isset( $mime ) ) {
@@ -364,7 +364,7 @@ class DjVuHandler extends ImageHandler {
                return [ $wgDjvuOutputExtension, $mime ];
        }
 
-       function getMetadata( $image, $path ) {
+       public function getMetadata( $image, $path ) {
                wfDebug( "Getting DjVu metadata for $path\n" );
 
                $xml = $this->getDjVuImage( $image, $path )->retrieveMetaData();
@@ -380,17 +380,17 @@ class DjVuHandler extends ImageHandler {
                return 'djvuxml';
        }
 
-       function isMetadataValid( $image, $metadata ) {
+       public function isMetadataValid( $image, $metadata ) {
                return !empty( $metadata ) && $metadata != serialize( [] );
        }
 
-       function pageCount( File $image ) {
+       public function pageCount( File $image ) {
                $info = $this->getDimensionInfo( $image );
 
                return $info ? $info['pageCount'] : false;
        }
 
-       function getPageDimensions( File $image, $page ) {
+       public function getPageDimensions( File $image, $page ) {
                $index = $page - 1; // MW starts pages at 1
 
                $info = $this->getDimensionInfo( $image );
index 4267210..1760eb8 100644 (file)
@@ -83,7 +83,7 @@ class ExifBitmapHandler extends BitmapHandler {
         * @param array $metadata
         * @return bool|int
         */
-       function isMetadataValid( $image, $metadata ) {
+       public function isMetadataValid( $image, $metadata ) {
                global $wgShowEXIF;
                if ( !$wgShowEXIF ) {
                        # Metadata disabled and so an empty field is expected
@@ -127,7 +127,7 @@ class ExifBitmapHandler extends BitmapHandler {
         * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image, $context = false ) {
+       public function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
index d65f872..556e83c 100644 (file)
@@ -29,7 +29,7 @@
 class GIFHandler extends BitmapHandler {
        const BROKEN_FILE = '0'; // value to store in img_metadata if error extracting metadata.
 
-       function getMetadata( $image, $filename ) {
+       public function getMetadata( $image, $filename ) {
                try {
                        $parsedGIFMetadata = BitmapMetadataHandler::GIF( $filename );
                } catch ( Exception $e ) {
@@ -47,7 +47,7 @@ class GIFHandler extends BitmapHandler {
         * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image, $context = false ) {
+       public function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
@@ -125,7 +125,7 @@ class GIFHandler extends BitmapHandler {
                return 'parsed-gif';
        }
 
-       function isMetadataValid( $image, $metadata ) {
+       public function isMetadataValid( $image, $metadata ) {
                if ( $metadata === self::BROKEN_FILE ) {
                        // Do not repetitivly regenerate metadata on broken file.
                        return self::METADATA_GOOD;
@@ -156,7 +156,7 @@ class GIFHandler extends BitmapHandler {
         * @param File $image
         * @return string
         */
-       function getLongDesc( $image ) {
+       public function getLongDesc( $image ) {
                global $wgLang;
 
                $original = parent::getLongDesc( $image );
index e88c1b0..b7042dc 100644 (file)
@@ -238,7 +238,7 @@ abstract class ImageHandler extends MediaHandler {
         * @param File $file
         * @return string
         */
-       function getLongDesc( $file ) {
+       public function getLongDesc( $file ) {
                global $wgLang;
                $pages = $file->pageCount();
                $size = htmlspecialchars( $wgLang->formatSize( $file->getSize() ) );
index f7de5f5..eaf842e 100644 (file)
@@ -34,7 +34,7 @@ class JpegHandler extends ExifBitmapHandler {
        const SRGB_EXIF_COLOR_SPACE = 'sRGB';
        const SRGB_ICC_PROFILE_DESCRIPTION = 'sRGB IEC61966-2.1';
 
-       function normaliseParams( $image, &$params ) {
+       public function normaliseParams( $image, &$params ) {
                if ( !parent::normaliseParams( $image, $params ) ) {
                        return false;
                }
@@ -98,7 +98,7 @@ class JpegHandler extends ExifBitmapHandler {
                return $res;
        }
 
-       function getMetadata( $image, $filename ) {
+       public function getMetadata( $image, $filename ) {
                try {
                        $meta = BitmapMetadataHandler::Jpeg( $filename );
                        if ( !is_array( $meta ) ) {
index 66a4291..a54da7d 100644 (file)
@@ -87,7 +87,7 @@ abstract class MediaHandler {
         * @param File $image
         * @param array &$params
         */
-       abstract function normaliseParams( $image, &$params );
+       abstract public function normaliseParams( $image, &$params );
 
        /**
         * Get an image size array like that returned by getimagesize(), or false if it
@@ -119,7 +119,7 @@ abstract class MediaHandler {
         * @param string $path The filename
         * @return string A string of metadata in php serialized form (Run through serialize())
         */
-       function getMetadata( $image, $path ) {
+       public function getMetadata( $image, $path ) {
                return '';
        }
 
@@ -195,7 +195,7 @@ abstract class MediaHandler {
         * @param string $metadata The metadata in serialized form
         * @return bool
         */
-       function isMetadataValid( $image, $metadata ) {
+       public function isMetadataValid( $image, $metadata ) {
                return self::METADATA_GOOD;
        }
 
@@ -287,7 +287,7 @@ abstract class MediaHandler {
         * @param array|null $params Handler specific rendering parameters
         * @return array Thumbnail extension and MIME type
         */
-       function getThumbType( $ext, $mime, $params = null ) {
+       public function getThumbType( $ext, $mime, $params = null ) {
                $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
                if ( !$ext || $magic->isMatchingExtension( $ext, $mime ) === false ) {
                        // The extension is not valid for this MIME type and we do
@@ -340,7 +340,7 @@ abstract class MediaHandler {
         * @param File $file
         * @return bool
         */
-       function pageCount( File $file ) {
+       public function pageCount( File $file ) {
                return false;
        }
 
@@ -381,7 +381,7 @@ abstract class MediaHandler {
         * False if the handler is disabled for all files
         * @return bool
         */
-       function isEnabled() {
+       public function isEnabled() {
                return true;
        }
 
@@ -401,7 +401,7 @@ abstract class MediaHandler {
         * @param int $page What page to get dimensions of
         * @return array|bool
         */
-       function getPageDimensions( File $image, $page ) {
+       public function getPageDimensions( File $image, $page ) {
                $gis = $this->getImageSize( $image, $image->getLocalRefPath() );
                if ( $gis ) {
                        return [
@@ -477,7 +477,7 @@ abstract class MediaHandler {
         * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image, $context = false ) {
+       public function formatMetadata( $image, $context = false ) {
                return false;
        }
 
@@ -582,7 +582,7 @@ abstract class MediaHandler {
         * @param File $file
         * @return string
         */
-       function getLongDesc( $file ) {
+       public function getLongDesc( $file ) {
                return self::getGeneralLongDesc( $file );
        }
 
@@ -660,7 +660,7 @@ abstract class MediaHandler {
         * @param string $fileName The local path to the file.
         * @return Status
         */
-       function verifyUpload( $fileName ) {
+       public function verifyUpload( $fileName ) {
                return Status::newGood();
        }
 
index 6748b26..a4b4dc5 100644 (file)
@@ -34,7 +34,7 @@ class PNGHandler extends BitmapHandler {
         * @param string $filename
         * @return string
         */
-       function getMetadata( $image, $filename ) {
+       public function getMetadata( $image, $filename ) {
                try {
                        $metadata = BitmapMetadataHandler::PNG( $filename );
                } catch ( Exception $e ) {
@@ -52,7 +52,7 @@ class PNGHandler extends BitmapHandler {
         * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $image, $context = false ) {
+       public function formatMetadata( $image, $context = false ) {
                $meta = $this->getCommonMetaArray( $image );
                if ( count( $meta ) === 0 ) {
                        return false;
@@ -111,7 +111,7 @@ class PNGHandler extends BitmapHandler {
                return 'parsed-png';
        }
 
-       function isMetadataValid( $image, $metadata ) {
+       public function isMetadataValid( $image, $metadata ) {
                if ( $metadata === self::BROKEN_FILE ) {
                        // Do not repetitivly regenerate metadata on broken file.
                        return self::METADATA_GOOD;
@@ -142,7 +142,7 @@ class PNGHandler extends BitmapHandler {
         * @param File $image
         * @return string
         */
-       function getLongDesc( $image ) {
+       public function getLongDesc( $image ) {
                global $wgLang;
                $original = parent::getLongDesc( $image );
 
index e3057f4..436483b 100644 (file)
@@ -41,7 +41,7 @@ class SvgHandler extends ImageHandler {
                'title' => 'ObjectName',
        ];
 
-       function isEnabled() {
+       public function isEnabled() {
                global $wgSVGConverters, $wgSVGConverter;
                if ( !isset( $wgSVGConverters[$wgSVGConverter] ) ) {
                        wfDebug( "\$wgSVGConverter is invalid, disabling SVG rendering.\n" );
@@ -399,7 +399,7 @@ class SvgHandler extends ImageHandler {
                }
        }
 
-       function getThumbType( $ext, $mime, $params = null ) {
+       public function getThumbType( $ext, $mime, $params = null ) {
                return [ 'png', 'image/png' ];
        }
 
@@ -412,7 +412,7 @@ class SvgHandler extends ImageHandler {
         * @param File $file
         * @return string
         */
-       function getLongDesc( $file ) {
+       public function getLongDesc( $file ) {
                global $wgLang;
 
                $metadata = $this->unpackMetadata( $file->getMetadata() );
@@ -438,7 +438,7 @@ class SvgHandler extends ImageHandler {
         * @param string $filename
         * @return string Serialised metadata
         */
-       function getMetadata( $file, $filename ) {
+       public function getMetadata( $file, $filename ) {
                $metadata = [ 'version' => self::SVG_METADATA_VERSION ];
                try {
                        $metadata += SVGMetadataExtractor::getMetadata( $filename );
@@ -469,7 +469,7 @@ class SvgHandler extends ImageHandler {
                return 'parsed-svg';
        }
 
-       function isMetadataValid( $image, $metadata ) {
+       public function isMetadataValid( $image, $metadata ) {
                $meta = $this->unpackMetadata( $metadata );
                if ( $meta === false ) {
                        return self::METADATA_BAD;
@@ -493,7 +493,7 @@ class SvgHandler extends ImageHandler {
         * @param bool|IContextSource $context Context to use (optional)
         * @return array|bool
         */
-       function formatMetadata( $file, $context = false ) {
+       public function formatMetadata( $file, $context = false ) {
                $result = [
                        'visible' => [],
                        'collapsed' => []
index 441513e..15c4dbf 100644 (file)
@@ -64,7 +64,7 @@ class TiffHandler extends ExifBitmapHandler {
         * @param array|null $params
         * @return bool
         */
-       function getThumbType( $ext, $mime, $params = null ) {
+       public function getThumbType( $ext, $mime, $params = null ) {
                global $wgTiffThumbnailType;
 
                return $wgTiffThumbnailType;
@@ -76,7 +76,7 @@ class TiffHandler extends ExifBitmapHandler {
         * @throws MWException
         * @return string
         */
-       function getMetadata( $image, $filename ) {
+       public function getMetadata( $image, $filename ) {
                global $wgShowEXIF;
 
                if ( $wgShowEXIF ) {
index ea0d61b..38dc390 100644 (file)
@@ -41,7 +41,7 @@ abstract class TransformationalImageHandler extends ImageHandler {
         * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
         * @return bool
         */
-       function normaliseParams( $image, &$params ) {
+       public function normaliseParams( $image, &$params ) {
                if ( !parent::normaliseParams( $image, $params ) ) {
                        return false;
                }
index 0cb618f..33f33bd 100644 (file)
@@ -49,7 +49,7 @@ class XCFHandler extends BitmapHandler {
         * @param array|null $params
         * @return array
         */
-       function getThumbType( $ext, $mime, $params = null ) {
+       public function getThumbType( $ext, $mime, $params = null ) {
                return [ 'png', 'image/png' ];
        }
 
index 0e0b943..29cc6b3 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 class MockDjVuHandler extends DjVuHandler {
-       function isEnabled() {
+       public function isEnabled() {
                return true;
        }