]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
DBA: Do a fallback to other db functions on problems
[friendica.git] / include / diaspora.php
index 762018b170c4f1f9ec35ff498b143f319427b051..77c459e649830ed16e89cad5abd7340ab2ae847c 100644 (file)
@@ -1529,6 +1529,8 @@ class Diaspora {
 
                $person = self::person_by_handle($msg_author);
 
+               dba::lock('mail');
+
                $r = q("SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
                        dbesc($msg_guid),
                        intval($importer["uid"])
@@ -1556,6 +1558,8 @@ class Diaspora {
                        dbesc($msg_created_at)
                );
 
+               dba::unlock();
+
                q("UPDATE `conv` SET `updated` = '%s' WHERE `id` = %d",
                        dbesc(datetime_convert()),
                        intval($conversation["id"])
@@ -1832,6 +1836,12 @@ class Diaspora {
                        return false;
                }
 
+               $body = diaspora2bb($text);
+
+               $body = self::replace_people_guid($body, $person["url"]);
+
+               dba::lock('mail');
+
                $r = q("SELECT `id` FROM `mail` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
                        dbesc($guid),
                        intval($importer["uid"])
@@ -1841,10 +1851,6 @@ class Diaspora {
                        return false;
                }
 
-               $body = diaspora2bb($text);
-
-               $body = self::replace_people_guid($body, $person["url"]);
-
                q("INSERT INTO `mail` (`uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`)
                                VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
                        intval($importer["uid"]),
@@ -1863,6 +1869,8 @@ class Diaspora {
                        dbesc($created_at)
                );
 
+               dba::unlock();
+
                q("UPDATE `conv` SET `updated` = '%s' WHERE `id` = %d",
                        dbesc(datetime_convert()),
                        intval($conversation["id"])
@@ -3721,7 +3729,7 @@ class Diaspora {
                 * This will break Diaspora compatibility with Friendica versions prior to 3.5.
                 */
                q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
-                       intval($message_id),
+                       intval($post_id),
                        dbesc(json_encode($message))
                );