IMPORTANT: Making prev. Memcached_DataObject working again with schemaDef

Lots of the Memcached_DataObject classes stopped working when upgraded to
Managed_DataObject because they lacked schemaDef().

I have _hopefully_ made it so that all the references to the table uses
each class' schemaDef, rather than the more manual ColumnDef stuff. Not
all plugins have been tested thoroughly yet.

NOTE: This is applied with getKV calls instead of staticGet, as it was
important for PHP Strict Standards compliance to avoid calling the non-
static functions statically. (unfortunately DB and DB_DataObject still do
this within themselves...)
This commit is contained in:
Mikael Nordfeldth
2013-08-19 17:08:18 +02:00
parent b1465a7559
commit 3a7261f70a
42 changed files with 453 additions and 1332 deletions

View File

@@ -37,22 +37,29 @@ class GNUsocialProfileExtensionField extends Managed_DataObject
public $__table = 'GNUsocialProfileExtensionField';
public $id; // int(11)
public $systemname; // varchar(64)
public $title; // varchar(256)
public $title; // varchar(255)
public $description; // text
public $type; // varchar(256)
public $type; // varchar(255)
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
function table()
public static function schemaDef()
{
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'systemname' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'title' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'type' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
}
function keys()
{
return array_keys($this->keyTypes());
return array(
'fields' => array(
'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension field'),
'systemname' => array('type' => 'varchar', 'not null' => true, 'length' => 64, 'description' => 'field systemname'),
'title' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'field title'),
'description' => array('type' => 'text', 'not null' => true, 'description' => 'field description'),
'type' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'field type'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'indexes' => array(
'gnusocialprofileextensionfield_title_idx' => array('title'),
),
);
}
function keyTypes()

View File

@@ -39,28 +39,29 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject
public $extension_id; // int(11)
public $profile_id; // int(11)
public $value; // text
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
function table()
public static function schemaDef()
{
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'extension_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
'value' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
}
function keys()
{
return array_keys($this->keyTypes());
}
function keyTypes()
{
return array('id' => 'K');
}
function sequenceKey()
{
return array(false, false, false);
return array(
'fields' => array(
'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension response'),
'extension_id' => array('type' => 'int', 'not null' => true, 'description' => 'The extension field ID'),
'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'Profile id that made the response'),
'value' => array('type' => 'text', 'not null' => true, 'description' => 'response entry'),
'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'),
),
'primary key' => array('id'),
'foreign keys' => array(
'gnusocialprofileextensionresponse_profile_id_fkey' => array('profile', array('profile_id' => 'id')),
'gnusocialprofileextensionresponse_extension_id_fkey' => array('GNUsocialProfileExtensionField', array('extension_id' => 'id')),
),
'indexes' => array(
'gnusocialprofileextensionresponse_extension_id_idx' => array('extension_id'),
),
);
}
static function newResponse($extension_id, $profile_id, $value)