From 35a18f68255f0b37b0109de4e6479cbf4312fc6e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 4 Jan 2018 09:51:05 -0500 Subject: [PATCH] Fix unused code in include (second pass) --- boot.php | 2 +- include/acl_selectors.php | 31 ++++++++++--------------------- include/api.php | 7 +------ include/enotify.php | 2 +- include/html2plain.php | 2 +- include/items.php | 6 +++--- include/message.php | 2 +- 7 files changed, 18 insertions(+), 34 deletions(-) diff --git a/boot.php b/boot.php index fbb08f619..5607260d9 100644 --- a/boot.php +++ b/boot.php @@ -676,7 +676,7 @@ function check_db($via_worker) if ($build != DB_UPDATE_VERSION) { // When we cannot execute the database update via the worker, we will do it directly if (!Worker::add(PRIORITY_CRITICAL, 'DBUpdate') && $via_worker) { - update_db(get_app()); + update_db(); } } } diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 7441061db..02ab95bb1 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -386,22 +386,20 @@ function populate_acl($user = null, $show_jotnets = false) { } -function acl_lookup(App $a, $out_type = 'json') { - +function acl_lookup(App $a, $out_type = 'json') +{ if (!local_user()) { return ''; } - $start = (x($_REQUEST,'start') ? $_REQUEST['start'] : 0); - $count = (x($_REQUEST,'count') ? $_REQUEST['count'] : 100); - $search = (x($_REQUEST,'search') ? $_REQUEST['search'] : ""); - $type = (x($_REQUEST,'type') ? $_REQUEST['type'] : ""); - $mode = (x($_REQUEST,'smode') ? $_REQUEST['smode'] : ""); - $conv_id = (x($_REQUEST,'conversation') ? $_REQUEST['conversation'] : null); + $start = defaults($_REQUEST, 'start' , 0); + $count = defaults($_REQUEST, 'count' , 100); + $search = defaults($_REQUEST, 'search' , ''); + $type = defaults($_REQUEST, 'type' , ''); + $conv_id = defaults($_REQUEST, 'conversation', null); // For use with jquery.textcomplete for private mail completion - - if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) { + if (x($_REQUEST, 'query')) { if (! $type) { $type = 'm'; } @@ -410,7 +408,7 @@ function acl_lookup(App $a, $out_type = 'json') { logger("Searching for ".$search." - type ".$type, LOGGER_DEBUG); - if ($search != "") { + if ($search != '') { $sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'"; $sql_extra2 = "AND (`attag` LIKE '%%".dbesc($search)."%%' OR `name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')"; } else { @@ -453,7 +451,6 @@ function acl_lookup(App $a, $out_type = 'json') { $contact_count = (int)$r[0]['c']; } elseif ($type == 'm') { // autocomplete for Private Messages - $r = q("SELECT COUNT(*) AS c FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` @@ -466,28 +463,23 @@ function acl_lookup(App $a, $out_type = 'json') { $contact_count = (int)$r[0]['c']; } elseif ($type == 'a') { - // autocomplete for Contacts - $r = q("SELECT COUNT(*) AS c FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `pending` $sql_extra2" , intval(local_user()) ); $contact_count = (int)$r[0]['c']; - } else { $contact_count = 0; } - - $tot = $group_count+$contact_count; + $tot = $group_count + $contact_count; $groups = array(); $contacts = array(); if ($type == '' || $type == 'g') { - /// @todo We should cache this query. // This can be done when we can delete cache entries via wildcard $r = q("SELECT `group`.`id`, `group`.`name`, GROUP_CONCAT(DISTINCT `group_member`.`contact-id` SEPARATOR ',') AS uids @@ -504,7 +496,6 @@ function acl_lookup(App $a, $out_type = 'json') { ); foreach ($r as $g) { -// logger('acl: group: ' . $g['name'] . ' members: ' . $g['uids']); $groups[] = array( "type" => "g", "photo" => "images/twopeople.png", @@ -521,7 +512,6 @@ function acl_lookup(App $a, $out_type = 'json') { } if ($type == '') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv`, (`prv` OR `forum`) AS `frm` FROM `contact` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != '' AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s', '%s')) @@ -593,7 +583,6 @@ function acl_lookup(App $a, $out_type = 'json') { $r = array(); } - if (DBM::is_result($r)) { $forums = array(); foreach ($r as $g) { diff --git a/include/api.php b/include/api.php index 6e7c369fa..bf038de90 100644 --- a/include/api.php +++ b/include/api.php @@ -3520,8 +3520,6 @@ api_register_func('api/statusnet/version', 'api_statusnet_version', false); */ function api_ff_ids($type) { - $a = get_app(); - if (! api_user()) { throw new ForbiddenException(); } @@ -3534,7 +3532,6 @@ function api_ff_ids($type) WHERE `contact`.`uid` = %s AND NOT `contact`.`self`", intval(api_user()) ); - if (!DBM::is_result($r)) { return; } @@ -3919,12 +3916,10 @@ function api_oauth_request_token() /** * Returns an OAuth Access Token. * - * @param string $type Return type (atom, rss, xml, json) - * * @return array|string * @see https://oauth.net/core/1.0/#auth_step3 */ -function api_oauth_access_token($type) +function api_oauth_access_token() { $oauth1 = new FKOAuth1(); try { diff --git a/include/enotify.php b/include/enotify.php index 06f6a84e1..58f40fe2d 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -505,7 +505,7 @@ function notification($params) $itemlink = System::baseUrl().'/notify/view/'.$notify_id; $msg = replace_macros($epreamble, array('$itemlink' => $itemlink)); $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg))); - $r = q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d", + q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d", dbesc($msg), dbesc($msg_cache), intval($notify_id), diff --git a/include/html2plain.php b/include/html2plain.php index aa634534a..83aa05ed5 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -201,7 +201,7 @@ function html2plain($html, $wraplength = 75, $compact = false) node2bbcode($doc, 'img', array('src' => '/(.+)/'), ' ', ' '); } - node2bbcode($doc, 'iframe', array('src' => '/(.+)/'), ' $1 ', '', true); + node2bbcode($doc, 'iframe', array('src' => '/(.+)/'), ' $1 ', ''); $message = $doc->saveHTML(); diff --git a/include/items.php b/include/items.php index 6000a851e..1ac8e9696 100644 --- a/include/items.php +++ b/include/items.php @@ -1116,7 +1116,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f * It is done after the transaction to avoid dead locks. */ if ($arr['last-child']) { - $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d AND `id` != %d", + q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d AND `id` != %d", dbesc($arr['uri']), intval($arr['uid']), intval($current_post) @@ -2220,12 +2220,12 @@ function drop_item($id, $interactive = true) { // Now delete them if ($parentid != "") { - $r = q("DELETE FROM `sign` WHERE `iid` IN (%s)", dbesc($parentid)); + q("DELETE FROM `sign` WHERE `iid` IN (%s)", dbesc($parentid)); } // If it's the parent of a comment thread, kill all the kids if ($item['uri'] == $item['parent-uri']) { - $r = dba::update('item', array('deleted' => true, 'title' => '', 'body' => '', + dba::update('item', array('deleted' => true, 'title' => '', 'body' => '', 'edited' => datetime_convert(), 'changed' => datetime_convert()), array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid'])); diff --git a/include/message.php b/include/message.php index 3d73b3547..844a803c0 100644 --- a/include/message.php +++ b/include/message.php @@ -196,7 +196,7 @@ function send_wallmessage($recipient = '', $body = '', $subject = '', $replyto = $convid = $r['id']; - $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, + q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`, `unknown`) VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )", intval($recipient['uid']),