]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
IMPORTANT - fixed HubSub to properly fetch primary keys
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 21 Aug 2013 09:25:08 +0000 (11:25 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 21 Aug 2013 09:25:08 +0000 (11:25 +0200)
In commit e95f77d34c501d345e731ccf6bc722034d155b77 HubSub lost the
'staticGet' function in a consolidation into the Managed_DataObject class.
This was done carelessly by me as HubSub::staticGet was actually taking
two arguments, none of which was a key and merging them in HubSub::hashkey()
(staticGet was renamed getKV 2a4dc77a633cc78907934fd93200ac16d55be78e).

NOTE: This complements commit 7e4718a4eb8d0e932398d6f150339fa6aec05267 which
fixed a similar issue for the Magicsig class.

plugins/OStatus/actions/pushhub.php
plugins/OStatus/classes/HubSub.php
plugins/OStatus/lib/hubprepqueuehandler.php

index 1c19c7e52e01327e97b623b0b602ddc1dc451ed5..e44d06e1996f93a0fee5c6cafd699ff378338c39 100644 (file)
@@ -109,7 +109,7 @@ class PushHubAction extends Action
             throw new ClientException(sprintf(_m('Invalid hub.secret "%s". It must be under 200 bytes.'),$secret));
         }
 
-        $sub = HubSub::getKV($topic, $callback);
+        $sub = HubSub::getByHashkey($topic, $callback);
         if (!$sub) {
             // Creating a new one!
             $sub = new HubSub();
@@ -222,6 +222,6 @@ class PushHubAction extends Action
      */
     protected function getSub($feed, $callback)
     {
-        return HubSub::getKV($feed, $callback);
+        return HubSub::getByHashkey($feed, $callback);
     }
 }
index 7a32e8df1b1aa1437ee53aef3c35042c2df864a0..7996da39304e5f14f9b87298ea44cbfeaeb49ee9 100644 (file)
@@ -45,6 +45,11 @@ class HubSub extends Managed_DataObject
         return sha1($topic . '|' . $callback);
     }
 
+    public static function getByHashkey($topic, $callback)
+    {
+        return self::getKV('hashkey', self::hashkey($topic, $callback));
+    }
+
     public static function schemaDef()
     {
         return array(
@@ -158,7 +163,7 @@ class HubSub extends Managed_DataObject
             throw new ClientException(sprintf(_m('Hub subscriber verification returned HTTP %s.'),$status));
         }
 
-        $old = HubSub::getKV($this->topic, $this->callback);
+        $old = HubSub::getByHashkey($this->topic, $this->callback);
         if ($mode == 'subscribe') {
             if ($old) {
                 $this->update($old);
@@ -244,7 +249,7 @@ class HubSub extends Managed_DataObject
         // destroy the result data for the parent query.
         // @fixme use clone() again when it's safe to copy an
         // individual item from a multi-item query again.
-        $sub = HubSub::getKV($this->topic, $this->callback);
+        $sub = HubSub::getByHashkey($this->topic, $this->callback);
         $data = array('sub' => $sub,
                       'atom' => $atom,
                       'retries' => $retries);
index 90ee6a8bd97e8ab79bb3fee636443328360381a9..f6abfcf30dabf3e8e65d96517d036bf76bef8487 100644 (file)
@@ -65,7 +65,7 @@ class HubPrepQueueHandler extends QueueHandler
             while (count($pushCallbacks) && $n < self::ROLLING_BATCH) {
                 $n++;
                 $callback = array_shift($pushCallbacks);
-                $sub = HubSub::getKV($topic, $callback);
+                $sub = HubSub::getByHashkey($topic, $callback);
                 if (!$sub) {
                     common_log(LOG_ERR, "Skipping PuSH delivery for deleted(?) consumer $callback on $topic");
                     continue;