]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix for auto_increment parameter in auto-created tables via checkschema.
authorBrion Vibber <brion@status.net>
Mon, 4 Jan 2010 18:30:19 +0000 (10:30 -0800)
committerBrion Vibber <brion@status.net>
Mon, 4 Jan 2010 18:30:58 +0000 (10:30 -0800)
Update FeedSub plugin for non-Plugin_DataObject setup and working checkschema updates.

lib/columndef.php
lib/schema.php
plugins/FeedSub/FeedSubPlugin.php
plugins/FeedSub/feedinfo.php

index 1bae6b33bbfa251fd1166839aafe44fef94e6f25..ac2fcd23eaaed3f91ff407fcfcbd8e6bb88500ed 100644 (file)
@@ -74,6 +74,7 @@ class ColumnDef
      * @param string  $key      type of key
      * @param value   $default  default value
      * @param value   $extra    unused
+     * @param boolean $auto_increment
      */
 
     function __construct($name=null, $type=null, $size=null,
index a8ba91b87fcde9ab1132db0ac81ad0c30c7e53d4..6fe442d56bbfcef5227f7b09196d3005b9ba7d07 100644 (file)
@@ -523,6 +523,10 @@ class Schema
         } else {
             $sql .= ($cd->nullable) ? "null " : "not null ";
         }
+        
+        if (!empty($cd->auto_increment)) {
+            $sql .= " auto_increment ";
+        }
 
         return $sql;
     }
index 857a9794d500526f773eee57bd7f3df9b2279f7e..e49e2a648a044d93d48b9a7eca1523a2f6032e38 100644 (file)
@@ -105,12 +105,11 @@ class FeedSubPlugin extends Plugin
         return true;
     }
 
-    /*
-    // auto increment seems to be broken
     function onCheckSchema() {
+        // warning: the autoincrement doesn't seem to set.
+        // alter table feedinfo change column id id int(11) not null  auto_increment;
         $schema = Schema::get();
-        $schema->ensureDataObject('Feedinfo');
+        $schema->ensureTable('feedinfo', Feedinfo::schemaDef());
         return true;
     }
-    */
 }
index fff66afe97a1d3a51a64f86a4c792d36172513c8..b166bd6e12e4b68796a484901d15d0eff69e67b7 100644 (file)
@@ -31,7 +31,7 @@ class FeedDBException extends FeedSubException
     }
 }
 
-class Feedinfo extends Plugin_DataObject
+class Feedinfo extends Memcached_DataObject
 {
     public $__table = 'feedinfo';
 
@@ -56,34 +56,90 @@ class Feedinfo extends Plugin_DataObject
         return parent::staticGet(__CLASS__, $k, $v);
     }
 
-    function tableDef()
+    /**
+     * return table definition for DB_DataObject
+     *
+     * DB_DataObject needs to know something about the table to manipulate
+     * instances. This method provides all the DB_DataObject needs to know.
+     *
+     * @return array array of column definitions
+     */
+
+    function table()
+    {
+        return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
+                     'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
+                     'feeduri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+                     'homeuri' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+                     'huburi' =>  DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+                     'verify_token' => DB_DATAOBJECT_STR,
+                     'sub_start' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
+                     'sub_end' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME,
+                     'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL,
+                     'lastupdate' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE + DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
+    }
+    
+    static function schemaDef()
+    {
+        return array(new ColumnDef('id', 'integer',
+                                   /*size*/ null,
+                                   /*nullable*/ false,
+                                   /*key*/ 'PRI',
+                                   /*default*/ '0',
+                                   /*extra*/ null,
+                                   /*auto_increment*/ true),
+                     new ColumnDef('profile_id', 'integer',
+                                   null, false),
+                     new ColumnDef('feeduri', 'varchar',
+                                   255, false, 'UNI'),
+                     new ColumnDef('homeuri', 'varchar',
+                                   255, false),
+                     new ColumnDef('huburi', 'varchar',
+                                   255, false),
+                     new ColumnDef('verify_token', 'varchar',
+                                   32, true),
+                     new ColumnDef('sub_start', 'datetime',
+                                   null, true),
+                     new ColumnDef('sub_end', 'datetime',
+                                   null, true),
+                     new ColumnDef('created', 'datetime',
+                                   null, false),
+                     new ColumnDef('lastupdate', 'datetime',
+                                   null, false));
+    }
+
+    /**
+     * return key definitions for DB_DataObject
+     *
+     * DB_DataObject needs to know about keys that the table has; this function
+     * defines them.
+     *
+     * @return array key definitions
+     */
+
+    function keys()
     {
-        class_exists('Schema'); // autoload hack
-        // warning: the autoincrement doesn't seem to set.
-        // alter table feedinfo change column id id int(11) not null  auto_increment;
-        return new TableDef($this->__table,
-                            array(new ColumnDef('id', 'integer',
-                                                null, false, 'PRI', '0', null, true),
-                                  new ColumnDef('profile_id', 'integer',
-                                                null, false),
-                                  new ColumnDef('feeduri', 'varchar',
-                                                255, false, 'UNI'),
-                                  new ColumnDef('homeuri', 'varchar',
-                                                255, false),
-                                  new ColumnDef('huburi', 'varchar',
-                                                255, false),
-                                  new ColumnDef('verify_token', 'varchar',
-                                                32, true),
-                                  new ColumnDef('sub_start', 'datetime',
-                                                null, true),
-                                  new ColumnDef('sub_end', 'datetime',
-                                                null, true),
-                                  new ColumnDef('created', 'datetime',
-                                                null, false),
-                                  new ColumnDef('lastupdate', 'datetime',
-                                                null, false)));
+        return array('id' => 'P'); //?
     }
 
+    /**
+     * return key definitions for Memcached_DataObject
+     *
+     * Our caching system uses the same key definitions, but uses a different
+     * method to get them.
+     *
+     * @return array key definitions
+     */
+
+    function keyTypes()
+    {
+        return $this->keys();
+    }
+
+    /**
+     * Fetch the StatusNet-side profile for this feed
+     * @return Profile
+     */
     public function getProfile()
     {
         return Profile::staticGet('id', $this->profile_id);