additionalData is now properly supported
authorAlexander Ebert <ebert@woltlab.com>
Fri, 21 Oct 2011 18:51:28 +0000 (20:51 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 21 Oct 2011 18:51:28 +0000 (20:51 +0200)
If additional data is an array and contains a serialized array, ObjectType will treat its content as data variables (allows $objectType->foo access)

wcfsetup/install/files/lib/data/object/type/ObjectType.class.php
wcfsetup/install/files/lib/system/cache/builder/ObjectTypeCacheBuilder.class.php

index e3ef46d0c081496e398829cf1139d047bfbe55ec..ce20edb902cbf704d0bc4b5182896c04ef4590d4 100644 (file)
@@ -25,6 +25,22 @@ class ObjectType extends ProcessibleDatabaseObject {
         */
        protected static $databaseTableIndexName = 'objectTypeID';
        
+       /**
+        * @see wcf\data\IStorableObject::__get()
+        */
+       public function __get($name) {
+               $value = parent::__get($name);
+               
+               // treat additional data as data variables if it is an array
+               if ($value === null) {
+                       if (is_array($this->additionalData) && isset($this->additionalData[$name])) {
+                               $value = $this->additionalData[$name];
+                       }
+               }
+               
+               return $value;
+       }
+       
        /**
         * @see wcf\data\ProcessibleDatabaseObject::getProcessor()
         */
index f03b86c460bcfdff725d34e0801b30a5dfd6432f..c365925f56eeb2d6fe0599e719795cd30683ee8d 100644 (file)
@@ -48,6 +48,7 @@ class ObjectTypeCacheBuilder implements ICacheBuilder {
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(array($packageID));
                while ($row = $statement->fetchArray()) {
+                       $row['additionalData'] = unserialize($row['additionalData']);
                        $data['objectTypes'][$row['objectTypeID']] = new ObjectType(null, $row);
                }