summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/File.php2
-rw-r--r--classes/Memcached_DataObject.php37
-rw-r--r--classes/Queue_item.php30
-rw-r--r--classes/statusnet.ini6
4 files changed, 55 insertions, 20 deletions
diff --git a/classes/File.php b/classes/File.php
index c527c4ffe..34e4632a8 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -251,6 +251,8 @@ class File extends Memcached_DataObject
if($oembed->modified) $enclosure->modified=$oembed->modified;
unset($oembed->size);
}
+ } else {
+ return false;
}
}
}
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 4ecab9db6..33645a3e8 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -19,8 +19,6 @@
if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
-require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
-
class Memcached_DataObject extends DB_DataObject
{
/**
@@ -315,6 +313,39 @@ class Memcached_DataObject extends DB_DataObject
return new ArrayWrapper($cached);
}
+ /**
+ * sends query to database - this is the private one that must work
+ * - internal functions use this rather than $this->query()
+ *
+ * Overridden to do logging.
+ *
+ * @param string $string
+ * @access private
+ * @return mixed none or PEAR_Error
+ */
+ function _query($string)
+ {
+ $start = microtime(true);
+ $result = parent::_query($string);
+ $delta = microtime(true) - $start;
+
+ $limit = common_config('db', 'log_slow_queries');
+ if (($limit > 0 && $delta >= $limit) || common_config('db', 'log_queries')) {
+ $clean = $this->sanitizeQuery($string);
+ common_log(LOG_DEBUG, sprintf("DB query (%0.3fs): %s", $delta, $clean));
+ }
+ return $result;
+ }
+
+ // Sanitize a query for logging
+ // @fixme don't trim spaces in string literals
+ function sanitizeQuery($string)
+ {
+ $string = preg_replace('/\s+/', ' ', $string);
+ $string = trim($string);
+ return $string;
+ }
+
// We overload so that 'SET NAMES "utf8"' is called for
// each connection
@@ -353,7 +384,7 @@ class Memcached_DataObject extends DB_DataObject
unset($_DB_DATAOBJECT['CONNECTIONS'][$index]);
}
}
-
+
$result = parent::_connect();
if ($result && !$exists) {
diff --git a/classes/Queue_item.php b/classes/Queue_item.php
index cf805a606..f83c2cef1 100644
--- a/classes/Queue_item.php
+++ b/classes/Queue_item.php
@@ -10,8 +10,8 @@ class Queue_item extends Memcached_DataObject
/* the code below is auto generated do not remove the above tag */
public $__table = 'queue_item'; // table name
- public $notice_id; // int(4) primary_key not_null
- public $transport; // varchar(8) primary_key not_null
+ public $id; // int(4) primary_key not_null
+ public $frame; // blob not_null
public $created; // datetime() not_null
public $claimed; // datetime()
@@ -22,14 +22,21 @@ class Queue_item extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
- function sequenceKey()
- { return array(false, false); }
-
- static function top($transport=null) {
+ /**
+ * @param mixed $transports name of a single queue or array of queues to pull from
+ * If not specified, checks all queues in the system.
+ */
+ static function top($transports=null) {
$qi = new Queue_item();
- if ($transport) {
- $qi->transport = $transport;
+ if ($transports) {
+ if (is_array($transports)) {
+ // @fixme use safer escaping
+ $list = implode("','", array_map('addslashes', $transports));
+ $qi->whereAdd("transport in ('$list')");
+ } else {
+ $qi->transport = $transports;
+ }
}
$qi->orderBy('created');
$qi->whereAdd('claimed is null');
@@ -42,7 +49,7 @@ class Queue_item extends Memcached_DataObject
# 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 .
+ common_log(LOG_INFO, 'claiming queue item id = ' . $qi->id .
' for transport ' . $qi->transport);
$orig = clone($qi);
$qi->claimed = common_sql_now();
@@ -57,9 +64,4 @@ class Queue_item extends Memcached_DataObject
$qi = null;
return null;
}
-
- function pkeyGet($kv)
- {
- return Memcached_DataObject::pkeyGet('Queue_item', $kv);
- }
}
diff --git a/classes/statusnet.ini b/classes/statusnet.ini
index 44088cf6b..6203650a6 100644
--- a/classes/statusnet.ini
+++ b/classes/statusnet.ini
@@ -428,14 +428,14 @@ tagged = K
tag = K
[queue_item]
-notice_id = 129
+id = 129
+frame = 66
transport = 130
created = 142
claimed = 14
[queue_item__keys]
-notice_id = K
-transport = K
+id = K
[related_group]
group_id = 129