Merge "Add new grammar forms for language names in Russian"
[lhc/web/wiklou.git] / includes / filerepo / file / File.php
index f9e1128..ec5af85 100644 (file)
@@ -213,14 +213,15 @@ abstract class File implements IDBAccessObject {
        }
 
        /**
-        * Normalize a file extension to the common form, and ensure it's clean.
-        * Extensions with non-alphanumeric characters will be discarded.
+        * Normalize a file extension to the common form, making it lowercase and checking some synonyms,
+        * and ensure it's clean. Extensions with non-alphanumeric characters will be discarded.
+        * Keep in sync with mw.Title.normalizeExtension() in JS.
         *
-        * @param string $ext (without the .)
-        * @return string
+        * @param string $extension File extension (without the leading dot)
+        * @return string File extension in canonical form
         */
-       static function normalizeExtension( $ext ) {
-               $lower = strtolower( $ext );
+       static function normalizeExtension( $extension ) {
+               $lower = strtolower( $extension );
                $squish = array(
                        'htm' => 'html',
                        'jpeg' => 'jpg',
@@ -382,7 +383,7 @@ abstract class File implements IDBAccessObject {
                                wfDebug( __METHOD__ . ': supposed to render ' . $this->getName() .
                                        ' (' . $this->getMimeType() . "), but can't!\n" );
 
-                               return $this->getURL(); #hm... return NULL?
+                               return $this->getURL(); # hm... return NULL?
                        }
                } else {
                        return $this->getURL();
@@ -423,7 +424,10 @@ abstract class File implements IDBAccessObject {
                if ( !isset( $this->fsFile ) ) {
                        $starttime = microtime( true );
                        $this->fsFile = $this->repo->getLocalReference( $this->getPath() );
-                       RequestContext::getMain()->getStats()->timing( 'media.thumbnail.generate.fetchoriginal', microtime( true ) - $starttime );
+
+                       $statTiming = microtime( true ) - $starttime;
+                       RequestContext::getMain()->getStats()->timing(
+                               'media.thumbnail.generate.fetchoriginal', 1000 * $statTiming );
 
                        if ( !$this->fsFile ) {
                                $this->fsFile = false; // null => false; cache negative hits
@@ -802,17 +806,17 @@ abstract class File implements IDBAccessObject {
 
                $type = $this->getMediaType();
                $mime = $this->getMimeType();
-               #wfDebug( "LocalFile::isSafeFile: type= $type, mime= $mime\n" );
+               # wfDebug( "LocalFile::isSafeFile: type= $type, mime= $mime\n" );
 
                if ( !$type || $type === MEDIATYPE_UNKNOWN ) {
-                       return false; #unknown type, not trusted
+                       return false; # unknown type, not trusted
                }
                if ( in_array( $type, $wgTrustedMediaFormats ) ) {
                        return true;
                }
 
                if ( $mime === "unknown/unknown" ) {
-                       return false; #unknown type, not trusted
+                       return false; # unknown type, not trusted
                }
                if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
                        return true;
@@ -835,8 +839,8 @@ abstract class File implements IDBAccessObject {
         * @return bool
         */
        function isTrustedFile() {
-               #this could be implemented to check a flag in the database,
-               #look for signatures, etc
+               # this could be implemented to check a flag in the database,
+               # look for signatures, etc
                return false;
        }
 
@@ -1120,7 +1124,8 @@ abstract class File implements IDBAccessObject {
                $thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
                $tmpFile->bind( $thumb ); // keep alive with $thumb
 
-               $stats->timing( 'media.thumbnail.generate.transform', microtime( true ) - $starttime );
+               $statTiming = microtime( true ) - $starttime;
+               $stats->timing( 'media.thumbnail.generate.transform', 1000 * $statTiming );
 
                if ( !$thumb ) { // bad params?
                        $thumb = false;
@@ -1143,7 +1148,8 @@ abstract class File implements IDBAccessObject {
                                $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $transformParams, $flags );
                        }
 
-                       $stats->timing( 'media.thumbnail.generate.store', microtime( true ) - $starttime );
+                       $statTiming = microtime( true ) - $starttime;
+                       $stats->timing( 'media.thumbnail.generate.store', 1000 * $statTiming );
 
                        // Give extensions a chance to do something with this thumbnail...
                        Hooks::run( 'FileTransformed', array( $this, $thumb, $tmpThumbPath, $thumbPath ) );
@@ -1180,8 +1186,6 @@ abstract class File implements IDBAccessObject {
 
                $params = $this->getHandler()->sanitizeParamsForBucketing( $params );
 
-               $bucketName = $this->getBucketThumbName( $bucket );
-
                $tmpFile = $this->makeTransformTmpFile( $bucketPath );
 
                if ( !$tmpFile ) {
@@ -1201,7 +1205,8 @@ abstract class File implements IDBAccessObject {
                // this object exists
                $tmpFile->bind( $this );
 
-               RequestContext::getMain()->getStats()->timing( 'media.thumbnail.generate.bucket', $buckettime );
+               RequestContext::getMain()->getStats()->timing(
+                       'media.thumbnail.generate.bucket', 1000 * $buckettime );
 
                return true;
        }