// 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
$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 ) {
// If revision deleted, exit immediately
if ( $file->isDeleted( File::DELETED_FILE ) ) {
+ wfProfileOut( __METHOD__ );
return array();
}
// 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 );
}
* @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'] )
// 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];
}
}
// 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
* @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;