Merge "mw.language.convertPlural: Check if matching form exists"
[lhc/web/wiklou.git] / includes / media / FormatMetadata.php
index 91c4c9a..74e51cf 100644 (file)
@@ -105,7 +105,7 @@ class FormatMetadata extends ContextSource {
                        // This seems ugly to wrap non-array's in an array just to unwrap again,
                        // especially when most of the time it is not an array
                        if ( !is_array( $tags[$tag] ) ) {
-                               $vals = Array( $vals );
+                               $vals = array( $vals );
                        }
 
                        // _type is a special value to say what array type
@@ -977,7 +977,7 @@ class FormatMetadata extends ContextSource {
                                        $defaultItem = $vals['x-default'];
                                        unset( $vals['x-default'] );
                                }
-                               foreach( $priorityLanguages as $pLang ) {
+                               foreach ( $priorityLanguages as $pLang ) {
                                        if ( isset( $vals[$pLang] ) ) {
                                                $isDefault = false;
                                                if ( $vals[$pLang] === $defaultItem ) {
@@ -1479,6 +1479,7 @@ class FormatMetadata extends ContextSource {
 
                // If revision deleted, exit immediately
                if ( $file->isDeleted( File::DELETED_FILE ) ) {
+                       wfProfileOut( __METHOD__ );
                        return array();
                }
 
@@ -1506,7 +1507,7 @@ class FormatMetadata extends ContextSource {
                        // This is an API-specific function so it would be cleaner to call it from
                        // outside fetchExtendedMetadata, but this way we don't need to redo the
                        // computation on a cache hit.
-                       $this->sanitizeArrayForXml($extendedMetadata);
+                       $this->sanitizeArrayForXml( $extendedMetadata );
                        $valueToCache = array( 'data' => $extendedMetadata, 'timestamp' => wfTimestampNow() );
                        $wgMemc->set( $cacheKey, $valueToCache, $maxCacheTime );
                }
@@ -1616,8 +1617,7 @@ class FormatMetadata extends ContextSource {
         * @return mixed value in best language, null if there were no languages at all
         * @since 1.23
         */
-       protected function resolveMultilangValue( $value )
-       {
+       protected function resolveMultilangValue( $value ) {
                if (
                        !is_array( $value )
                        || !isset( $value['_type'] )
@@ -1628,7 +1628,7 @@ class FormatMetadata extends ContextSource {
 
                // choose the language best matching user or site settings
                $priorityLanguages = $this->getPriorityLanguages();
-               foreach( $priorityLanguages as $lang ) {
+               foreach ( $priorityLanguages as $lang ) {
                        if ( isset( $value[$lang] ) ) {
                                return $value[$lang];
                        }
@@ -1640,9 +1640,9 @@ class FormatMetadata extends ContextSource {
                }
 
                // otherwise just return any one language
-               unset($value['_type']);
-               if (!empty($value)) {
-                       return reset($value);
+               unset( $value['_type'] );
+               if ( !empty( $value ) ) {
+                       return reset( $value );
                }
 
                // this should not happen; signal error
@@ -1731,8 +1731,7 @@ class FormatMetadata extends ContextSource {
         * @return array
         * @since 1.23
         */
-       protected function getPriorityLanguages()
-       {
+       protected function getPriorityLanguages() {
                $priorityLanguages = Language::getFallbacksIncludingSiteLanguage( $this->getLanguage()->getCode() );
                $priorityLanguages = array_merge( (array) $this->getLanguage()->getCode(), $priorityLanguages[0], $priorityLanguages[1] );
                return $priorityLanguages;