]> git.mxchange.org Git - friendica.git/blobdiff - include/threads.php
Merge pull request #2758 from annando/1609-sql-charset
[friendica.git] / include / threads.php
index 3cfa02564036b4d38577da017a31ee48f1b243a7..2e02e7ada3290ae0ecb690cad1d6ca912e307379 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 function add_thread($itemid, $onlyshadow = false) {
-       $items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`,
-                       `deleted`, `origin`, `forum_mode`, `mention`, `network`  FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
+       $items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`,
+                       `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
+                       `deleted`, `origin`, `forum_mode`, `mention`, `network`, `author-id`, `owner-id`
+               FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
 
        if (!$items)
                return;
@@ -66,6 +68,7 @@ function add_thread($itemid, $onlyshadow = false) {
 
                        unset($item[0]['id']);
                        $item[0]['uid'] = 0;
+                       $item[0]['origin'] = 0;
                        $item[0]['contact-id'] = get_contact($item[0]['author-link'], 0);
                        $public_shadow = item_store($item[0], false, false, true);
 
@@ -87,7 +90,6 @@ function add_shadow_entry($item) {
 
        // Is there already a shadow entry?
        $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc($item['uri']));
-
        if (count($r))
                return;
 
@@ -112,8 +114,8 @@ function update_thread_uri($itemuri, $uid) {
 }
 
 function update_thread($itemid, $setmention = false) {
-       $items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`,
-                       `deleted`, `origin`, `forum_mode`, `network`  FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
+       $items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
+                       `deleted`, `origin`, `forum_mode`, `network`, `rendered-html`, `rendered-hash` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
 
        if (!$items)
                return;
@@ -126,7 +128,7 @@ function update_thread($itemid, $setmention = false) {
        $sql = "";
 
        foreach ($item AS $field => $data)
-               if (!in_array($field, array("guid", "title", "body"))) {
+               if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) {
                        if ($sql != "")
                                $sql .= ", ";
 
@@ -143,9 +145,11 @@ function update_thread($itemid, $setmention = false) {
        if (!$items)
                return;
 
-       $result = q("UPDATE `item` SET `title` = '%s', `body` = '%s' WHERE `id` = %d",
+       $result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d",
                        dbesc($item["title"]),
                        dbesc($item["body"]),
+                       dbesc($item["rendered-html"]),
+                       dbesc($item["rendered-hash"]),
                        intval($items[0]["id"])
                );
        logger("Updating public shadow for post ".$items[0]["id"]." - guid ".$item["guid"]." Result: ".print_r($result, true), LOGGER_DEBUG);
@@ -172,7 +176,7 @@ function delete_thread($itemid, $itemuri = "") {
                                intval($item["uid"])
                        );
                if (!count($r)) {
-                       $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0)",
+                       $r = q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = 0",
                                dbesc($itemuri)
                        );
                        logger("delete_thread: Deleted shadow for item ".$itemuri." - ".print_r($result, true), LOGGER_DEBUG);