From 696404739bdd3db8eae4255c2d622de8a45df18d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 17 May 2017 19:25:30 +0000 Subject: [PATCH] Bugfix Diaspora: We exited with the wrong return values and the guid for messages was too short --- boot.php | 2 +- include/dbstructure.php | 4 ++-- include/diaspora.php | 35 +++++++++++++++++++++++------------ mod/receive.php | 4 ++-- update.php | 2 +- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/boot.php b/boot.php index 4c09785c8e..48381f5435 100644 --- a/boot.php +++ b/boot.php @@ -40,7 +40,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5.2-rc' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1224 ); +define ( 'DB_UPDATE_VERSION', 1225 ); /** * @brief Constant with a HTML line break. diff --git a/include/dbstructure.php b/include/dbstructure.php index 6a14220c24..c9c37c9390 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -808,7 +808,7 @@ function db_definition() { $database["conv"] = array( "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), - "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "recips" => array("type" => "text"), "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")), "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), @@ -1205,7 +1205,7 @@ function db_definition() { "fields" => array( "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"), "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "relation" => array("user" => "uid")), - "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""), + "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), diff --git a/include/diaspora.php b/include/diaspora.php index 820f8bd896..545edcc4bf 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1395,7 +1395,7 @@ class Diaspora { $message_id = self::message_exists($importer["uid"], $guid); if ($message_id) { - return $message_id; + return true; } $parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact); @@ -1454,6 +1454,10 @@ class Diaspora { $message_id = item_store($datarray); + if ($message_id <= 0) { + return false; + } + if ($message_id) { logger("Stored comment ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); } @@ -1472,7 +1476,7 @@ class Diaspora { proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id); } - return $message_id; + return true; } /** @@ -1623,7 +1627,7 @@ class Diaspora { } if (!$conversation) { logger("unable to create conversation."); - return; + return false; } foreach ($messages as $mesg) @@ -1701,7 +1705,7 @@ class Diaspora { $message_id = self::message_exists($importer["uid"], $guid); if ($message_id) - return $message_id; + return true; $parent_item = self::parent_item($importer["uid"], $parent_guid, $author, $contact); if (!$parent_item) @@ -1754,8 +1758,13 @@ class Diaspora { $message_id = item_store($datarray); - if ($message_id) + if ($message_id <= 0) { + return false; + } + + if ($message_id) { logger("Stored like ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + } // If we are the origin of the parent we store the original data and notify our followers if ($message_id AND $parent_item["origin"]) { @@ -1771,7 +1780,7 @@ class Diaspora { proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id); } - return $message_id; + return true; } /** @@ -2348,7 +2357,7 @@ class Diaspora { $message_id = self::message_exists($importer["uid"], $guid); if ($message_id) { - return $message_id; + return true; } $original_item = self::original_item($root_guid, $root_author, $author); @@ -2399,9 +2408,10 @@ class Diaspora { if ($message_id) { logger("Stored reshare ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + return true; + } else { + return false; } - - return $message_id; } /** @@ -2532,7 +2542,7 @@ class Diaspora { $message_id = self::message_exists($importer["uid"], $guid); if ($message_id) { - return $message_id; + return true; } $address = array(); @@ -2616,9 +2626,10 @@ class Diaspora { if ($message_id) { logger("Stored item ".$datarray["guid"]." with message id ".$message_id, LOGGER_DEBUG); + return true; + } else { + return false; } - - return $message_id; } /* ************************************************************************************** * diff --git a/mod/receive.php b/mod/receive.php index 2873cb971a..8b28c16562 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -63,14 +63,14 @@ function receive_post(App $a) { logger('mod-diaspora: dispatching', LOGGER_DEBUG); - $ret = 0; + $ret = true; if ($public) { Diaspora::dispatch_public($msg); } else { $ret = Diaspora::dispatch($importer, $msg); } - http_status_exit(($ret) ? $ret : 200); + http_status_exit(($ret) ? 200 : 500); // NOTREACHED } diff --git a/update.php b/update.php index e3b1c31b33..9c509be4b7 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@