From: Hypolite Petovan Date: Wed, 10 Jan 2018 18:04:00 +0000 (-0500) Subject: Replace select(limit => 1) by selectFirst() in Model\Term and include/enotify X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1fda0ae4ae60449bb8d260d00b6ccae411dfcf0c;p=friendica.git Replace select(limit => 1) by selectFirst() in Model\Term and include/enotify - Add new array declaration syntax - Add braces --- diff --git a/include/enotify.php b/include/enotify.php index e128ae9bed..2869572562 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -50,8 +50,8 @@ function notification($params) } if ($params['type'] != SYSTEM_EMAIL) { - $user = dba::select('user', array('nickname', 'page-flags'), - array('uid' => $params['uid']), array('limit' => 1)); + $user = dba::selectFirst('user', ['nickname', 'page-flags'], + ['uid' => $params['uid']]); // There is no need to create notifications for forum accounts if (!DBM::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) { diff --git a/src/Model/Term.php b/src/Model/Term.php index 07dec52134..5f536cae42 100644 --- a/src/Model/Term.php +++ b/src/Model/Term.php @@ -16,13 +16,11 @@ class Term */ public static function createFromItem($itemid) { - $messages = dba::select('item', ['uid', 'deleted', 'file'], ['id' => $itemid], ['limit' => 1]); - if (!$messages) { + $message = dba::selectFirst('item', ['uid', 'deleted', 'file'], ['id' => $itemid]); + if (!\Friendica\Database\DBM::is_result($message)) { return; } - $message = $messages[0]; - // Clean up all tags q("DELETE FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)", intval(TERM_OBJ_POST), @@ -30,18 +28,31 @@ class Term intval(TERM_FILE), intval(TERM_CATEGORY)); - if ($message["deleted"]) + if ($message["deleted"]) { return; + } if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) { foreach ($files[1] as $file) { - dba::insert('term', ['uid' => $message["uid"], 'oid' => $itemid, 'otype' => TERM_OBJ_POST, 'type' => TERM_FILE, 'term' => $file]); + dba::insert('term', [ + 'uid' => $message["uid"], + 'oid' => $itemid, + 'otype' => TERM_OBJ_POST, + 'type' => TERM_FILE, + 'term' => $file + ]); } } if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files)) { foreach ($files[1] as $file) { - dba::insert('term', ['uid' => $message["uid"], 'oid' => $itemid, 'otype' => TERM_OBJ_POST, 'type' => TERM_CATEGORY, 'term' => $file]); + dba::insert('term', [ + 'uid' => $message["uid"], + 'oid' => $itemid, + 'otype' => TERM_OBJ_POST, + 'type' => TERM_CATEGORY, + 'term' => $file + ]); } } }