summaryrefslogtreecommitdiff
path: root/lib/queuemanager.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-08 16:43:37 -0800
committerBrion Vibber <brion@pobox.com>2010-02-10 12:27:41 -0800
commit045797331c82b86e03c61f00f4db68a085688520 (patch)
tree96d31110682e81c732d8529f62b86b3bf5a0da25 /lib/queuemanager.php
parentc4557d4d0700c09742b9d2e002c2d2b0161558f3 (diff)
fix up hub queueing to work w/ stomp queues
Diffstat (limited to 'lib/queuemanager.php')
-rw-r--r--lib/queuemanager.php36
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/queuemanager.php b/lib/queuemanager.php
index afe710e88..149617eb5 100644
--- a/lib/queuemanager.php
+++ b/lib/queuemanager.php
@@ -155,26 +155,26 @@ abstract class QueueManager extends IoManager
}
/**
- * Encode an object for queued storage.
- * Next gen may use serialization.
+ * Encode an object or variable for queued storage.
+ * Notice objects are currently stored as an id reference;
+ * other items are serialized.
*
- * @param mixed $object
+ * @param mixed $item
* @return string
*/
- protected function encode($object)
+ protected function encode($item)
{
- if ($object instanceof Notice) {
- return $object->id;
- } else if (is_string($object)) {
- return $object;
+ if ($item instanceof Notice) {
+ // Backwards compat
+ return $item->id;
} else {
- throw new ServerException("Can't queue this type", 500);
+ return serialize($item);
}
}
/**
* Decode an object from queued storage.
- * Accepts back-compat notice reference entries and strings for now.
+ * Accepts notice reference entries and serialized items.
*
* @param string
* @return mixed
@@ -182,9 +182,23 @@ abstract class QueueManager extends IoManager
protected function decode($frame)
{
if (is_numeric($frame)) {
+ // Back-compat for notices...
return Notice::staticGet(intval($frame));
- } else {
+ } elseif (substr($frame, 0, 1) == '<') {
+ // Back-compat for XML source
return $frame;
+ } else {
+ // Deserialize!
+ #$old = error_reporting();
+ #error_reporting($old & ~E_NOTICE);
+ $out = unserialize($frame);
+ #error_reporting($old);
+
+ if ($out === false && $frame !== 'b:0;') {
+ common_log(LOG_ERR, "Couldn't unserialize queued frame: $frame");
+ return false;
+ }
+ return $out;
}
}