Replace select(limit => 1) by selectFirst() in Model\Term and include/enotify

- Add new array declaration syntax
- Add braces
This commit is contained in:
Hypolite Petovan 2018-01-10 13:04:00 -05:00
parent 483d1a1bcb
commit 1fda0ae4ae
2 changed files with 20 additions and 9 deletions

View file

@ -50,8 +50,8 @@ function notification($params)
} }
if ($params['type'] != SYSTEM_EMAIL) { if ($params['type'] != SYSTEM_EMAIL) {
$user = dba::select('user', array('nickname', 'page-flags'), $user = dba::selectFirst('user', ['nickname', 'page-flags'],
array('uid' => $params['uid']), array('limit' => 1)); ['uid' => $params['uid']]);
// There is no need to create notifications for forum accounts // 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))) { if (!DBM::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) {

View file

@ -16,13 +16,11 @@ class Term
*/ */
public static function createFromItem($itemid) public static function createFromItem($itemid)
{ {
$messages = dba::select('item', ['uid', 'deleted', 'file'], ['id' => $itemid], ['limit' => 1]); $message = dba::selectFirst('item', ['uid', 'deleted', 'file'], ['id' => $itemid]);
if (!$messages) { if (!\Friendica\Database\DBM::is_result($message)) {
return; return;
} }
$message = $messages[0];
// Clean up all tags // Clean up all tags
q("DELETE FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)", q("DELETE FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)",
intval(TERM_OBJ_POST), intval(TERM_OBJ_POST),
@ -30,18 +28,31 @@ class Term
intval(TERM_FILE), intval(TERM_FILE),
intval(TERM_CATEGORY)); intval(TERM_CATEGORY));
if ($message["deleted"]) if ($message["deleted"]) {
return; return;
}
if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) { if (preg_match_all("/\[(.*?)\]/ism", $message["file"], $files)) {
foreach ($files[1] as $file) { 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)) { if (preg_match_all("/\<(.*?)\>/ism", $message["file"], $files)) {
foreach ($files[1] as $file) { 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
]);
} }
} }
} }