$schema->ensureTable('msn_waiting_message',\r
array(new ColumnDef('id', 'integer', null,\r
false, 'PRI', null, null, true),\r
- new ColumnDef('screenname', 'integer', null, false),\r
+ new ColumnDef('screenname', 'varchar', 255, false),\r
new ColumnDef('message', 'text', null, false),\r
new ColumnDef('created', 'datetime', null, false),\r
new ColumnDef('claimed', 'datetime')));\r
<?php\r
/**\r
- * Table Definition for msn_plugin_message\r
+ * Table Definition for msn_waiting_message\r
*/\r
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';\r
\r
}\r
\r
/**\r
- * @param mixed $screenname screenname or array of screennames to pull from\r
+ * return table definition for DB_DataObject\r
+ *\r
+ * DB_DataObject needs to know something about the table to manipulate\r
+ * instances. This method provides all the DB_DataObject needs to know.\r
+ *\r
+ * @return array array of column definitions\r
+ */\r
+ public function table() {\r
+ return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,\r
+ 'screenname' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
+ 'message' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
+ 'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,\r
+ 'claimed' => DB_DATAOBJECT_STR);\r
+ }\r
+\r
+ /**\r
+ * return key definitions for DB_DataObject\r
+ *\r
+ * DB_DataObject needs to know about keys that the table has, since it\r
+ * won't appear in StatusNet's own keys list. In most cases, this will\r
+ * simply reference your keyTypes() function.\r
+ *\r
+ * @return array list of key field names\r
+ */\r
+ public function keys() {\r
+ return array_keys($this->keyTypes());\r
+ }\r
+\r
+ /**\r
+ * return key definitions for Memcached_DataObject\r
+ *\r
+ * Our caching system uses the same key definitions, but uses a different\r
+ * method to get them. This key information is used to store and clear\r
+ * cached data, so be sure to list any key that will be used for static\r
+ * lookups.\r
+ *\r
+ * @return array associative array of key definitions, field name to type:\r
+ * 'K' for primary key: for compound keys, add an entry for each component;\r
+ * 'U' for unique keys: compound keys are not well supported here.\r
+ */\r
+ public function keyTypes() {\r
+ return array('id' => 'K');\r
+ }\r
+\r
+ /**\r
+ * Magic formula for non-autoincrementing integer primary keys\r
+ *\r
+ * If a table has a single integer column as its primary key, DB_DataObject\r
+ * assumes that the column is auto-incrementing and makes a sequence table\r
+ * to do this incrementation. Since we don't need this for our class, we\r
+ * overload this method and return the magic formula that DB_DataObject needs.\r
+ *\r
+ * @return array magic three-false array that stops auto-incrementing.\r
+ */\r
+ function sequenceKey() {\r
+ return array(false, false, false);\r
+ }\r
+\r
+ /**\r
+ * @param string $screenname screenname or array of screennames to pull from\r
* If not specified, checks all queues in the system.\r
*/\r
public static function top($screenname = null) {\r
* @param array $data Data\r
*/\r
public function handle_session_ready($data) {\r
- while (($wm = Msn_waiting_message::top($data['to']) != NULL)) {\r
+ $wm = Msn_waiting_message::top($data['to']);\r
+ while ($wm != NULL) {\r
if ($this->conn->sendMessage($wm->screenname, $wm->message, $ignore)) {\r
$wm->delete();\r
} else {\r
// Requeue the message in the regular queue\r
$this->plugin->send_message($wm->screenname, $wm->message);\r
}\r
+\r
+ $wm = Msn_waiting_message::top($data['to']);\r
}\r
}\r
\r