Fix up r47473: descend into subarrays in ForeignAPIFile::getMetadata()
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 5 May 2009 09:47:53 +0000 (09:47 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 5 May 2009 09:47:53 +0000 (09:47 +0000)
includes/filerepo/ForeignAPIFile.php

index 0a29367..03498fb 100644 (file)
@@ -60,15 +60,22 @@ class ForeignAPIFile extends File {
        
        public function getMetadata() {
                if ( isset( $this->mInfo['metadata'] ) ) {
-                       $ret = array();
-                       foreach( $this->mInfo['metadata'] as $meta ) {
-                               $ret[ $meta['name'] ] = $meta['value'];
-                       }
-                       return serialize( $ret );
+                       return serialize( self::parseMetadata( $this->mInfo['metadata'] ) );
                }
                return null;
        }
        
+       public static function parseMetadata( $metadata ) {
+               if( !is_array( $metadata ) ) {
+                       return $metadata;
+               }
+               $ret = array();
+               foreach( $metadata as $meta ) {
+                       $ret[ $meta['name'] ] = self::parseMetadata( $meta['value'] );
+               }
+               return $ret;
+       }
+       
        public function getSize() {
                return intval( @$this->mInfo['size'] );
        }