X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FTwitterBridge%2FNotice_to_status.php;h=313adaeafc0eb229a41c14cc2ade134645fc71e0;hb=f519858044a627e99244b334b7bef3f7f96fa317;hp=ecd4905dcc0d2979ee9794c6a0bfc0ecf0be6bd7;hpb=a1981770ce113d0fa20e5f1b57ddcf3d88177102;p=quix0rs-gnu-social.git diff --git a/plugins/TwitterBridge/Notice_to_status.php b/plugins/TwitterBridge/Notice_to_status.php index ecd4905dcc..313adaeafc 100644 --- a/plugins/TwitterBridge/Notice_to_status.php +++ b/plugins/TwitterBridge/Notice_to_status.php @@ -71,7 +71,6 @@ class Notice_to_status extends Memcached_DataObject * @return Notice_to_status object found, or null for no hits * */ - function staticGet($k, $v=null) { return Memcached_DataObject::staticGet('Notice_to_status', $k, $v); @@ -85,7 +84,6 @@ class Notice_to_status extends Memcached_DataObject * * @return array array of column definitions */ - function table() { return array('notice_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL, @@ -102,7 +100,6 @@ class Notice_to_status extends Memcached_DataObject * * @return array list of key field names */ - function keys() { return array_keys($this->keyTypes()); @@ -120,7 +117,6 @@ class Notice_to_status extends Memcached_DataObject * 'K' for primary key: for compound keys, add an entry for each component; * 'U' for unique keys: compound keys are not well supported here. */ - function keyTypes() { return array('notice_id' => 'K', 'status_id' => 'U'); @@ -136,7 +132,6 @@ class Notice_to_status extends Memcached_DataObject * * @return array magic three-false array that stops auto-incrementing. */ - function sequenceKey() { return array(false, false, false); @@ -144,15 +139,35 @@ class Notice_to_status extends Memcached_DataObject /** * Save a mapping between a notice and a status + * Warning: status_id values may not fit in 32-bit integers. * * @param integer $notice_id ID of the notice in StatusNet * @param integer $status_id ID of the status in Twitter * * @return Notice_to_status new object for this value */ - static function saveNew($notice_id, $status_id) { + if (empty($notice_id)) { + throw new Exception("Invalid notice_id $notice_id"); + } + $n2s = Notice_to_status::staticGet('notice_id', $notice_id); + + if (!empty($n2s)) { + return $n2s; + } + + if (empty($status_id)) { + throw new Exception("Invalid status_id $status_id"); + } + $n2s = Notice_to_status::staticGet('status_id', $status_id); + + if (!empty($n2s)) { + return $n2s; + } + + common_debug("Mapping notice {$notice_id} to Twitter status {$status_id}"); + $n2s = new Notice_to_status(); $n2s->notice_id = $notice_id;