UnregisteredLocalFile.php: Override File::getBitDepth() stub
authorVivek Ghaisas <v.a.ghaisas@gmail.com>
Thu, 25 Dec 2014 08:52:12 +0000 (11:52 +0300)
committerVivek Ghaisas <v.a.ghaisas@gmail.com>
Fri, 13 Feb 2015 17:54:50 +0000 (23:24 +0530)
The File::getBitDepth() stub simply returns 0 and UnregisteredLocalFile was not
overriding this to return the actual bit depth. UnregisteredLocalFile::getBitDepth()
now handles this by returning the 'bits' field of $this->getImageSize().

This commit just fixes the above bug, but some rethinking of the structure and
behaviour of this class and the UploadStashFile class is required.

Bug: T36952
Change-Id: I4a8fd6b74b923f2052ccd2e47980486299ad2a6e

includes/filerepo/file/UnregisteredLocalFile.php

index 5a3e4e9..4c11341 100644 (file)
@@ -165,6 +165,18 @@ class UnregisteredLocalFile extends File {
                return $this->handler->getImageSize( $this, $this->getLocalRefPath() );
        }
 
+       /**
+       * @return int
+       */
+       function getBitDepth() {
+               $gis = $this->getImageSize( $this->getLocalRefPath() );
+
+               if ( !$gis || !isset( $gis['bits'] ) ) {
+                       return 0;
+               }
+               return $gis['bits'];
+       }
+
        /**
         * @return bool
         */