summaryrefslogtreecommitdiff
path: root/classes/Queue_item.php
diff options
context:
space:
mode:
authorEvan Prodromou <git@evanprodromou.name>2009-01-23 08:58:31 +0100
committerEvan Prodromou <git@evanprodromou.name>2009-01-23 08:58:31 +0100
commita7c85bebd5be9ea019a8c80d74730d7eb28d4651 (patch)
treec3fdf9575a342624bc71aad1d439ae73594f558c /classes/Queue_item.php
parent4873277b58941ae6ec16543f437f4267ccab5ac0 (diff)
parent7aa496cd8a939960eeaf79f3397f6fe94097e047 (diff)
Merge branch 'master' of /var/www/mublog
Conflicts: actions/api.php actions/deletenotice.php actions/recoverpassword.php actions/remotesubscribe.php actions/tag.php actions/tagrss.php actions/twitapiaccount.php actions/twitapiusers.php classes/Notice.php classes/User.php lib/common.php lib/language.php lib/subs.php lib/twitterapi.php lib/util.php scripts/inbox_users.php scripts/update_translations.php Merged development trunk into laconica head. woohoo!
Diffstat (limited to 'classes/Queue_item.php')
-rw-r--r--classes/Queue_item.php66
1 files changed, 34 insertions, 32 deletions
diff --git a/classes/Queue_item.php b/classes/Queue_item.php
index 8ba3281de..9b909ec22 100644
--- a/classes/Queue_item.php
+++ b/classes/Queue_item.php
@@ -16,40 +16,42 @@ class Queue_item extends Memcached_DataObject
public $claimed; // datetime()
/* Static get */
- function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Queue_item',$k,$v); }
+ function staticGet($k,$v=null)
+ { return Memcached_DataObject::staticGet('Queue_item',$k,$v); }
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function sequenceKey() { return array(false, false); }
-
- static function top($transport) {
-
- $qi = new Queue_item();
- $qi->transport = $transport;
- $qi->orderBy('created');
- $qi->whereAdd('claimed is NULL');
-
- $qi->limit(1);
-
- $cnt = $qi->find(TRUE);
-
- if ($cnt) {
- # XXX: potential race condition
- # can we force it to only update if claimed is still NULL
- # (or old)?
- common_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id . ' for transport ' . $transport);
- $orig = clone($qi);
- $qi->claimed = common_sql_now();
- $result = $qi->update($orig);
- if ($result) {
- common_log(LOG_INFO, 'claim succeeded.');
- return $qi;
- } else {
- common_log(LOG_INFO, 'claim failed.');
- }
- }
- $qi = NULL;
- return NULL;
- }
+ function sequenceKey()
+ { return array(false, false); }
+
+ static function top($transport) {
+
+ $qi = new Queue_item();
+ $qi->transport = $transport;
+ $qi->orderBy('created');
+ $qi->whereAdd('claimed is null');
+
+ $qi->limit(1);
+
+ $cnt = $qi->find(true);
+
+ if ($cnt) {
+ # XXX: potential race condition
+ # can we force it to only update if claimed is still null
+ # (or old)?
+ common_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id . ' for transport ' . $transport);
+ $orig = clone($qi);
+ $qi->claimed = common_sql_now();
+ $result = $qi->update($orig);
+ if ($result) {
+ common_log(LOG_INFO, 'claim succeeded.');
+ return $qi;
+ } else {
+ common_log(LOG_INFO, 'claim failed.');
+ }
+ }
+ $qi = null;
+ return null;
+ }
}