X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fthreads.php;h=61bc5292ff7621fba0c3f96d653d6c4ae8794db8;hb=bae725c2797fcae0d61c13822d27e4277ec0cc0e;hp=e776a37e7e068a56878591666dc081ab9db5893d;hpb=ec02af593db87e78b0b388047ac4265aa5f987b1;p=friendica.git diff --git a/include/threads.php b/include/threads.php index e776a37e7e..61bc5292ff 100644 --- a/include/threads.php +++ b/include/threads.php @@ -1,9 +1,6 @@ $data) - if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) { + if (!in_array($field, ["guid", "title", "body", "rendered-html", "rendered-hash"])) { if ($sql != "") { $sql .= ", "; } @@ -253,7 +96,7 @@ function delete_thread($itemid, $itemuri = "") { } // Using dba::delete at this time could delete the associated item entries - $result = q("DELETE FROM `thread` WHERE `iid` = %d", intval($itemid)); + $result = dba::e("DELETE FROM `thread` WHERE `iid` = ?", $itemid); logger("delete_thread: Deleted thread for item ".$itemid." - ".print_r($result, true), LOGGER_DEBUG); @@ -263,52 +106,8 @@ function delete_thread($itemid, $itemuri = "") { intval($item["uid"]) ); if (!DBM::is_result($r)) { - dba::delete('item', array('uri' => $itemuri, 'uid' => 0)); + dba::delete('item', ['uri' => $itemuri, 'uid' => 0]); logger("delete_thread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG); } } } - -function update_threads() { - logger("update_threads: start"); - - $messages = dba::select('item', array('id'), array("`id` = `parent`")); - - logger("update_threads: fetched messages: ".dba::num_rows($messages)); - - while ($message = dba::fetch($messages)) { - add_thread($message["id"]); - add_shadow_thread($message["id"]); - } - dba::close($messages); -} - -function update_threads_mention() { - $users = q("SELECT `uid`, `nickname` FROM `user` ORDER BY `uid`"); - - foreach ($users AS $user) { - $self = normalise_link(System::baseUrl() . '/profile/' . $user['nickname']); - $selfhttps = str_replace("http://", "https://", $self); - $parents = q("SELECT DISTINCT(`parent`) FROM `item` WHERE `uid` = %d AND - ((`owner-link` IN ('%s', '%s')) OR (`author-link` IN ('%s', '%s')))", - $user["uid"], $self, $selfhttps, $self, $selfhttps); - - foreach ($parents AS $parent) - q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", $parent["parent"]); - } -} - - -function update_shadow_copy() { - logger("start"); - - $condition = "`uid` != 0 AND `network` IN ('', ?, ?, ?) AND `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private`"; - $messages = dba::select('thread', array('iid'), array($condition, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS), - array('order' => 'created')); - - logger("fetched messages: ".dba::num_rows($messages)); - while ($message = dba::fetch($messages)) - add_shadow_thread($message["iid"]); - - dba::close($messages); -}