]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Config.php
Misses this file to merge. I like the comments.
[quix0rs-gnu-social.git] / classes / Config.php
index e14730438eb306936c81652c6b8897df04398ea8..2e8492849c4b9f68abb1586aad52f9406e9c81f2 100644 (file)
@@ -27,7 +27,7 @@ if (!defined('STATUSNET')) {
 
 require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 
-class Config extends Memcached_DataObject
+class Config extends Managed_DataObject
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
@@ -35,21 +35,34 @@ class Config extends Memcached_DataObject
     public $__table = 'config';                          // table name
     public $section;                         // varchar(32)  primary_key not_null
     public $setting;                         // varchar(32)  primary_key not_null
-    public $value;                           // varchar(255)
-
-    /* Static get */
-    function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Config',$k,$v); }
+    public $value;                           // varchar(191)   not 255 because utf8mb4 takes more space
 
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
 
+    public static function schemaDef()
+    {
+        return array(
+            'fields' => array(
+                'section' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration section'),
+                'setting' => array('type' => 'varchar', 'length' => 32, 'not null' => true, 'default' => '', 'description' => 'configuration setting'),
+                'value' => array('type' => 'varchar', 'length' => 191, 'description' => 'configuration value'),
+            ),
+            'primary key' => array('section', 'setting'),
+        );
+    }
+
     const settingsKey = 'config:settings';
 
     static function loadSettings()
     {
-        $settings = self::_getSettings();
-        if (!empty($settings)) {
-            self::_applySettings($settings);
+        try {
+            $settings = self::_getSettings();
+            if (!empty($settings)) {
+                self::_applySettings($settings);
+            }
+        } catch (Exception $e) {
+            return;
         }
     }
 
@@ -102,29 +115,24 @@ class Config extends Memcached_DataObject
         return $result;
     }
 
-    function delete()
+    function delete($useWhere=false)
     {
-        $result = parent::delete();
-        if ($result) {
+        $result = parent::delete($useWhere);
+        if ($result !== false) {
             Config::_blowSettingsCache();
         }
         return $result;
     }
 
-    function update($orig=null)
+    function update($dataObject=false)
     {
-        $result = parent::update($orig);
-        if ($result) {
+        $result = parent::update($dataObject);
+        if ($result !== false) {
             Config::_blowSettingsCache();
         }
         return $result;
     }
 
-    function pkeyGet($kv)
-    {
-        return Memcached_DataObject::pkeyGet('Config', $kv);
-    }
-
     static function save($section, $setting, $value)
     {
         $result = null;