]> git.mxchange.org Git - friendica.git/commitdiff
Replace select(limit => 1) by selectFirst() in Model\Term and include/enotify
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 10 Jan 2018 18:04:00 +0000 (13:04 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Wed, 10 Jan 2018 18:04:00 +0000 (13:04 -0500)
- Add new array declaration syntax
- Add braces

include/enotify.php
src/Model/Term.php

index e128ae9bedf4213e7e8eb2359503e25b3611018d..2869572562fd6cc258b5ead042ea0f787a04de92 100644 (file)
@@ -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))) {
index 07dec521348f068e59808d8adc1edfc7fb1ec071..5f536cae424199feac52039414f6d75f5378cc02 100644 (file)
@@ -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
+                               ]);
                        }
                }
        }