git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit e95f77d3 authored by mmn's avatar mmn

Updating all Memcached_DataObject extended classes to Managed_DataObject

In some brief tests, this causes no problems.

In this state however, you would need to modify DB_DataObject to have a static declaration of staticget (and probably pkeyGet). The next commit will change the staticGet overload to a unique function name (like getKV for getKeyValue), which means we can properly call the function by PHP Strict Standards.
parent c36608b2
......@@ -81,8 +81,4 @@ class Old_school_prefs extends Managed_DataObject
),
);
}
function staticGet($k,$v=NULL) {
return Memcached_DataObject::staticGet('Old_school_prefs',$k,$v);
}
}
......@@ -42,7 +42,7 @@ class Status_network extends Safe_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */
function staticGet($k,$v=NULL) {
static function staticGet($k,$v=NULL) {
$i = DB_DataObject::staticGet('Status_network',$k,$v);
// Don't use local process cache; if we're fetching multiple
......
......@@ -50,20 +50,6 @@ class Unavailable_status_network extends Managed_DataObject
public $nickname; // varchar(64) UUID
public $created; // datetime
/**
* Get an instance by key
*
* @param string $k Key to use to lookup (usually 'id' for this class)
* @param mixed $v Value to lookup
*
* @return Happening object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Unavailable_status_network', $k, $v);
}
/**
* The One True Thingy that must be defined and declared.
*/
......
......@@ -44,7 +44,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class Fave_tally extends Memcached_DataObject
class Fave_tally extends Managed_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
......@@ -54,9 +54,6 @@ class Fave_tally extends Memcached_DataObject
public $count; // int(4) not_null
public $modified; // datetime not_null default_0000-00-00%2000%3A00%3A00
/* Static get */
function staticGet($k, $v = NULL) { return Memcached_DataObject::staticGet('Fave_tally', $k, $v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
......
......@@ -44,28 +44,12 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Homepage_blacklist extends Memcached_DataObject
class Homepage_blacklist extends Managed_DataObject
{
public $__table = 'homepage_blacklist'; // table name
public $pattern; // string pattern
public $created; // datetime
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return Homepage_blacklist object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Homepage_blacklist', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -44,28 +44,12 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Nickname_blacklist extends Memcached_DataObject
class Nickname_blacklist extends Managed_DataObject
{
public $__table = 'nickname_blacklist'; // table name
public $pattern; // string pattern
public $created; // datetime
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup
* @param mixed $v Value to lookup
*
* @return Nickname_blacklist object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Nickname_blacklist', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -42,7 +42,7 @@ if (!defined('STATUSNET')) {
*
* @see DB_DataObject
*/
class Bookmark extends Memcached_DataObject
class Bookmark extends Managed_DataObject
{
public $__table = 'bookmark'; // table name
public $id; // char(36) primary_key not_null
......@@ -53,22 +53,6 @@ class Bookmark extends Memcached_DataObject
public $uri; // varchar(255)
public $created; // datetime
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return User_greeting_count object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Bookmark', $k, $v);
}
/**
* Get an instance by compound key
*
......
......@@ -46,7 +46,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Email_summary_status extends Memcached_DataObject
class Email_summary_status extends Managed_DataObject
{
public $__table = 'email_summary_status'; // table name
public $user_id; // int(4) primary_key not_null
......@@ -55,20 +55,6 @@ class Email_summary_status extends Memcached_DataObject
public $created; // datetime not_null
public $modified; // datetime not_null
/**
* Get an instance by key
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return Email_summary_status object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('email_summary_status', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -48,29 +48,13 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Notice_to_item extends Memcached_DataObject
class Notice_to_item extends Managed_DataObject
{
public $__table = 'notice_to_item'; // table name
public $notice_id; // int(4) primary_key not_null
public $item_id; // varchar(255) not null
public $created; // datetime
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup
* @param mixed $v Value to lookup
*
* @return Notice_to_item object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Notice_to_item', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -52,27 +52,12 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class User_followeveryone_prefs extends Memcached_DataObject
class User_followeveryone_prefs extends Managed_DataObject
{
public $__table = 'user_followeveryone_prefs'; // table name
public $user_id; // int(4) primary_key not_null
public $followeveryone; // tinyint(1)
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return User_followeveryone_prefs object found, or null for no hits
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('User_followeveryone_prefs', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET')) {
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
class GNUsocialPhoto extends Memcached_DataObject
class GNUsocialPhoto extends Managed_DataObject
{
public $__table = 'GNUsocialPhoto';
public $id; // int(11)
......@@ -42,17 +42,6 @@ class GNUsocialPhoto extends Memcached_DataObject
public $thumb_uri; // varchar(512)
public $title; // varchar(512)
public $photo_description; // text
/**
*
* k key
* v value
*/
function staticGet($k,$v=NULL)
{
return Memcached_DataObject::staticGet('GNUsocialPhoto',$k,$v);
}
/* function delete()
{
......
......@@ -33,7 +33,7 @@ if (!defined('STATUSNET')) {
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
class GNUsocialPhotoAlbum extends Memcached_DataObject
class GNUsocialPhotoAlbum extends Managed_DataObject
{
public $__table = 'GNUsocialPhotoAlbum';
public $album_id; // int(11) -- Unique identifier for the album
......@@ -41,13 +41,6 @@ class GNUsocialPhotoAlbum extends Memcached_DataObject
public $album_name; // varchar(256) -- Title for this album
public $album_description; // text -- A description of the album
function staticGet($k,$v=NULL)
{
return Memcached_DataObject::staticGet('GNUsocialPhotoAlbum',$k,$v);
}
/* TODO: Primary key on both album_id, profile_id / foriegn key on profile_id */
function table()
{
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET')) {
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
class GNUsocialProfileExtensionField extends Memcached_DataObject
class GNUsocialProfileExtensionField extends Managed_DataObject
{
public $__table = 'GNUsocialProfileExtensionField';
public $id; // int(11)
......@@ -41,17 +41,6 @@ class GNUsocialProfileExtensionField extends Memcached_DataObject
public $description; // text
public $type; // varchar(256)
/**
*
* k key
* v value
*/
function staticGet($k,$v=NULL)
{
return Memcached_DataObject::staticGet('GNUsocialProfileExtensionField',$k,$v);
}
function table()
{
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET')) {
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
class GNUsocialProfileExtensionResponse extends Memcached_DataObject
class GNUsocialProfileExtensionResponse extends Managed_DataObject
{
public $__table = 'GNUsocialProfileExtensionResponse';
public $id; // int(11)
......@@ -40,17 +40,6 @@ class GNUsocialProfileExtensionResponse extends Memcached_DataObject
public $profile_id; // int(11)
public $value; // text
/**
*
* k key
* v value
*/
function staticGet($k,$v=NULL)
{
return Memcached_DataObject::staticGet('GNUsocialProfileExtensionResponse',$k,$v);
}
function table()
{
return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
......
......@@ -32,7 +32,7 @@ if (!defined('STATUSNET')) {
require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
class GNUsocialPhoto extends Memcached_DataObject
class GNUsocialPhoto extends Managed_DataObject
{
public $__table = 'GNUsocialPhoto';
public $id; // int(11)
......@@ -42,17 +42,6 @@ class GNUsocialPhoto extends Memcached_DataObject
public $thumb_uri; // varchar(512)
public $title; // varchar(512)
public $photo_description; // text
/**
*
* k key
* v value
*/
function staticGet($k,$v=NULL)
{
return Memcached_DataObject::staticGet('GNUsocialPhoto',$k,$v);
}
/* function delete()
{
......
......@@ -44,7 +44,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Group_message extends Memcached_DataObject
class Group_message extends Managed_DataObject
{
public $__table = 'group_message'; // table name
public $id; // char(36) primary_key not_null
......@@ -56,21 +56,6 @@ class Group_message extends Memcached_DataObject
public $url;
public $created;
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return Group_message object found, or null for no hits
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Group_message', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -44,28 +44,13 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Group_message_profile extends Memcached_DataObject
class Group_message_profile extends Managed_DataObject
{
public $__table = 'group_message_profile'; // table name
public $to_profile; // int
public $group_message_id; // char(36) primary_key not_null
public $created;
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return Group_message object found, or null for no hits
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Group_message_profile', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -44,7 +44,7 @@ if (!defined('STATUSNET')) {
*
* @see DB_DataObject
*/
class Group_privacy_settings extends Memcached_DataObject
class Group_privacy_settings extends Managed_DataObject
{
public $__table = 'group_privacy_settings';
/** ID of the group. */
......@@ -70,21 +70,6 @@ class Group_privacy_settings extends Memcached_DataObject
const MEMBER = 2;
const ADMIN = 4;
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return User_greeting_count object found, or null for no hits
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Group_privacy_settings', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -5,7 +5,7 @@
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Irc_waiting_message extends Memcached_DataObject {
class Irc_waiting_message extends Managed_DataObject {
public $__table = 'irc_waiting_message'; // table name
public $id; // int primary_key not_null auto_increment
......@@ -15,11 +15,6 @@ class Irc_waiting_message extends Memcached_DataObject {
public $created; // datetime() not_null
public $claimed; // datetime()
/* Static get */
public function staticGet($k, $v = null) {
return Memcached_DataObject::staticGet('Irc_waiting_message', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -4,7 +4,7 @@
*/
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Msn_waiting_message extends Memcached_DataObject {
class Msn_waiting_message extends Managed_DataObject {
public $__table = 'msn_waiting_message'; // table name
public $id; // int primary_key not_null auto_increment
......@@ -13,11 +13,6 @@ class Msn_waiting_message extends Memcached_DataObject {
public $created; // datetime() not_null
public $claimed; // datetime()
/* Static get */
public function staticGet($k, $v = null) {
return Memcached_DataObject::staticGet('Msn_waiting_message', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -44,7 +44,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class Notice_title extends Memcached_DataObject
class Notice_title extends Managed_DataObject
{
const MAXCHARS = 255;
......@@ -52,22 +52,6 @@ class Notice_title extends Memcached_DataObject
public $notice_id; // int(4) primary_key not_null
public $title; // varchar(255)
/**
* Get an instance by key
*
* This is a utility method to get a single instance with a given key value.
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return Notice_title object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Notice_title', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -59,7 +59,7 @@ class FeedDBException extends FeedSubException
* Higher-level behavior building OStatus stuff on top is handled
* under Ostatus_profile.
*/
class FeedSub extends Memcached_DataObject
class FeedSub extends Managed_DataObject
{
public $__table = 'feedsub';
......@@ -78,11 +78,6 @@ class FeedSub extends Memcached_DataObject
public $created;
public $modified;
public /*static*/ function staticGet($k, $v=null)
{
return parent::staticGet(__CLASS__, $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -26,7 +26,7 @@ if (!defined('STATUSNET')) {
* @package Hub
* @author Brion Vibber <brion@status.net>
*/
class HubSub extends Memcached_DataObject
class HubSub extends Managed_DataObject
{
public $__table = 'hubsub';
......@@ -40,11 +40,6 @@ class HubSub extends Memcached_DataObject
public $created;
public $modified;
public /*static*/ function staticGet($topic, $callback)
{
return parent::staticGet(__CLASS__, 'hashkey', self::hashkey($topic, $callback));
}
protected static function hashkey($topic, $callback)
{
return sha1($topic . '|' . $callback);
......
......@@ -33,7 +33,7 @@ if (!defined('STATUSNET')) {
require_once 'Crypt/RSA.php';
class Magicsig extends Memcached_DataObject
class Magicsig extends Managed_DataObject
{
const PUBLICKEYREL = 'magic-public-key';
......@@ -81,32 +81,6 @@ class Magicsig extends Memcached_DataObject
$this->alg = $alg;
}
/**
* Fetch a Magicsig object from the cache or database on a field match.
*
* @param string $k
* @param mixed $v
* @return Magicsig
*/
public /*static*/ function staticGet($k, $v=null)
{
$obj = parent::staticGet(__CLASS__, $k, $v);
if (!empty($obj)) {
$obj = Magicsig::fromString($obj->keypair);
// Double check keys: Crypt_RSA did not
// consistently generate good keypairs.
// We've also moved to 1024 bit keys.
if (strlen($obj->publicKey->modulus->toBits()) != 1024) {
$obj->delete();
return false;
}
}
return $obj;
}
function table()
{
return array(
......
......@@ -25,7 +25,7 @@ if (!defined('STATUSNET')) {
* @package OStatusPlugin
* @maintainer Brion Vibber <brion@status.net>
*/
class Ostatus_source extends Memcached_DataObject
class Ostatus_source extends Managed_DataObject
{
public $__table = 'ostatus_source';
......@@ -33,11 +33,6 @@ class Ostatus_source extends Memcached_DataObject
public $profile_uri; // uri of the ostatus_profile this came through -- may be a group feed
public $method; // push or salmon
public /*static*/ function staticGet($k, $v=null)
{
return parent::staticGet(__CLASS__, $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -7,7 +7,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
class User_openid extends Memcached_DataObject
class User_openid extends Managed_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
......@@ -19,10 +19,6 @@ class User_openid extends Memcached_DataObject
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */
function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('User_openid',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
......
......@@ -7,7 +7,7 @@ if (!defined('STATUSNET')) {
exit(1);
}
class User_openid_trustroot extends Memcached_DataObject
class User_openid_trustroot extends Managed_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
......@@ -18,10 +18,6 @@ class User_openid_trustroot extends Memcached_DataObject
public $created; // datetime() not_null
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */
function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('User_openid_trustroot',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
......
......@@ -42,27 +42,13 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
class Registration_ip extends Memcached_DataObject
class Registration_ip extends Managed_DataObject
{
public $__table = 'registration_ip'; // table name
public $user_id; // int(4) primary_key not_null
public $ipaddress; // varchar(15)
public $created; // timestamp
/**
* Get an instance by key
*
* @param string $k Key to use to lookup (usually 'user_id' for this class)
* @param mixed $v Value to lookup
*
* @return User_greeting_count object found, or null for no hits
*
*/
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Registration_ip', $k, $v);
}
/**
* return table definition for DB_DataObject
*
......
......@@ -52,27 +52,12 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
*
* @see DB_DataObject
*/
class User_greeting_count extends Memcached_DataObject