Browse Source

Merge pull request #3010 from Quix0r/rewrites/mixed-static-object-reference-calls

Rewrites: mixed static object reference calls (and very sadly more ...)
pull/3027/head
Michael Vogel 6 years ago committed by GitHub
parent
commit
52f12ee28d
  1. 35
      boot.php
  2. 6
      include/Contact.php
  3. 13
      include/Core/Config.php
  4. 13
      include/Core/PConfig.php
  5. 2
      include/ForumManager.php
  6. 24
      include/NotificationsManager.php
  7. 2
      include/Probe.php
  8. 12
      include/acl_selectors.php
  9. 33
      include/api.php
  10. 6
      include/auth.php
  11. 4
      include/auth_ejabberd.php
  12. 2
      include/contact_selectors.php
  13. 6
      include/contact_widgets.php
  14. 6
      include/conversation.php
  15. 6
      include/cron.php
  16. 2
      include/cronhooks.php
  17. 2
      include/datetime.php
  18. 4
      include/dba.php
  19. 4
      include/dba_pdo.php
  20. 17
      include/dbstructure.php
  21. 16
      include/delivery.php
  22. 33
      include/dfrn.php
  23. 8
      include/diaspora.php
  24. 2
      include/discover_poco.php
  25. 11
      include/enotify.php
  26. 18
      include/event.php
  27. 2
      include/expire.php
  28. 6
      include/fcontact.php
  29. 2
      include/files.php
  30. 10
      include/follow.php
  31. 2
      include/gprobe.php
  32. 20
      include/group.php
  33. 16
      include/identity.php
  34. 37
      include/items.php
  35. 10
      include/like.php
  36. 8
      include/lock.php
  37. 8
      include/message.php
  38. 2
      include/nav.php
  39. 17
      include/network.php
  40. 14
      include/notifier.php
  41. 14
      include/oauth.php
  42. 16
      include/oembed.php
  43. 10
      include/onepoll.php
  44. 2
      include/pgettext.php
  45. 10
      include/plugin.php
  46. 2
      include/poller.php
  47. 5
      include/queue_fn.php
  48. 4
      include/redir.php
  49. 16
      include/security.php
  50. 18
      include/socgraph.php
  51. 2
      include/tags.php
  52. 21
      include/text.php
  53. 10
      include/threads.php
  54. 4
      include/uimport.php
  55. 10
      include/user.php
  56. 2
      library/langdet/Text/LanguageDetect.php
  57. 2
      mod/admin.php
  58. 2
      mod/allfriends.php
  59. 2
      mod/api.php
  60. 4
      mod/attach.php
  61. 6
      mod/cal.php
  62. 6
      mod/common.php
  63. 4
      mod/community.php
  64. 6
      mod/contactgroup.php
  65. 12
      mod/contacts.php
  66. 12
      mod/content.php
  67. 6
      mod/crepair.php
  68. 14
      mod/delegate.php
  69. 20
      mod/dfrn_confirm.php
  70. 6
      mod/dfrn_notify.php
  71. 18
      mod/dfrn_poll.php
  72. 38
      mod/dfrn_request.php
  73. 4
      mod/directory.php
  74. 2
      mod/editpost.php
  75. 7
      mod/events.php
  76. 5
      mod/fbrowser.php
  77. 4
      mod/fetch.php
  78. 4
      mod/friendica.php
  79. 8
      mod/fsuggest.php
  80. 10
      mod/group.php
  81. 2
      mod/ignored.php
  82. 2
      mod/install.php
  83. 10
      mod/item.php
  84. 10
      mod/lockview.php
  85. 4
      mod/lostpass.php
  86. 4
      mod/manage.php
  87. 2
      mod/match.php
  88. 12
      mod/message.php
  89. 2
      mod/modexp.php
  90. 2
      mod/mood.php
  91. 10
      mod/msearch.php
  92. 18
      mod/network.php
  93. 4
      mod/nogroup.php
  94. 4
      mod/noscrape.php
  95. 6
      mod/notes.php
  96. 2
      mod/notice.php
  97. 3
      mod/notifications.php
  98. 2
      mod/notify.php
  99. 2
      mod/openid.php
  100. 2
      mod/p.php
  101. Some files were not shown because too many files have changed in this diff Show More

35
boot.php

@ -767,7 +767,7 @@ class App {
}
function get_basepath() {
public static function get_basepath() {
$basepath = get_config("system", "basepath");
@ -1191,7 +1191,7 @@ class App {
q("START TRANSACTION");
$r = q("SELECT `pid` FROM `process` WHERE `pid` = %d", intval(getmypid()));
if(!dbm::is_result($r)) {
if (!dbm::is_result($r)) {
q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')",
intval(getmypid()),
dbesc($command),
@ -1207,7 +1207,7 @@ class App {
q("START TRANSACTION");
$r = q("SELECT `pid` FROM `process`");
if(dbm::is_result($r)) {
if (dbm::is_result($r)) {
foreach ($r AS $process) {
if (!posix_kill($process["pid"], 0)) {
q("DELETE FROM `process` WHERE `pid` = %d", intval($process["pid"]));
@ -1294,10 +1294,6 @@ class App {
*/
function max_processes_reached() {
// Is the function called statically?
if (!is_object($this))
return(self::$a->max_processes_reached());
if ($this->is_backend()) {
$process = "backend";
$max_processes = get_config('system', 'max_processes_backend');
@ -1329,10 +1325,6 @@ class App {
*/
function maxload_reached() {
// Is the function called statically?
if (!is_object($this))
return(self::$a->maxload_reached());
if ($this->is_backend()) {
$process = "backend";
$maxsysload = intval(get_config('system', 'maxloadavg'));
@ -1479,17 +1471,18 @@ function system_unavailable() {
function clean_urls() {
global $a;
$a = get_app();
// if($a->config['system']['clean_urls'])
return true;
// return false;
}
function z_path() {
global $a;
$base = $a->get_baseurl();
$base = App::get_baseurl();
if(! clean_urls())
$base .= '/?q=';
return $base;
}
@ -1499,10 +1492,10 @@ function z_path() {
* @see App::get_baseurl()
*
* @return string
* @TODO Maybe super-flous and deprecated? Seems to only wrap App::get_baseurl()
*/
function z_root() {
global $a;
return $a->get_baseurl();
return App::get_baseurl();
}
/**
@ -1685,7 +1678,7 @@ function run_update_function($x) {
function check_plugins(&$a) {
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
if(dbm::is_result($r))
if (dbm::is_result($r))
$installed = $r;
else
$installed = array();
@ -1903,7 +1896,7 @@ function info($s) {
* @return int
*/
function get_max_import_size() {
global $a;
$a = get_app();
return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 );
}
@ -2029,7 +2022,7 @@ function current_theme(){
$r = q("select theme from user where uid = %d limit 1",
intval($a->profile_uid)
);
if(dbm::is_result($r))
if (dbm::is_result($r))
$page_theme = $r[0]['theme'];
}
@ -2100,7 +2093,7 @@ function current_theme(){
* @return string
*/
function current_theme_url() {
global $a;
$a = get_app();
$t = current_theme();
@ -2142,7 +2135,7 @@ function feed_birthday($uid,$tz) {
intval($uid)
);
if(dbm::is_result($p)) {
if (dbm::is_result($p)) {
$tmp_dob = substr($p[0]['dob'],5);
if(intval($tmp_dob)) {
$y = datetime_convert($tz,$tz,'now','Y');

6
include/Contact.php

@ -64,7 +64,7 @@ function contact_remove($id) {
$r = q("select uid from contact where id = %d limit 1",
intval($id)
);
if((! count($r)) || (! intval($r[0]['uid'])))
if((! dbm::is_result($r)) || (! intval($r[0]['uid'])))
return;
$archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts');
@ -242,7 +242,7 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) {
FROM `gcontact` WHERE `nurl` = '%s'",
dbesc(normalise_link($url)));
if ($r) {
if (dbm::is_result($r)) {
// If there is more than one entry we filter out the connector networks
if (count($r) > 1) {
foreach ($r AS $id => $result) {
@ -428,7 +428,7 @@ function random_profile() {
ORDER BY rand() LIMIT 1",
dbesc(NETWORK_DFRN));
if(count($r))
if (dbm::is_result($r))
return dirname($r[0]['url']);
return '';
}

13
include/Core/Config.php

@ -1,5 +1,8 @@
<?php
namespace Friendica\Core;
use dbm;
/**
* @file include/Core/Config.php
*
@ -30,10 +33,10 @@ class Config {
* @return void
*/
public static function load($family) {
global $a;
$a = get_app();
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
if (count($r)) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$k = $rr['k'];
if ($family === 'config') {
@ -72,7 +75,7 @@ class Config {
*/
public static function get($family, $key, $default_value = null, $refresh = false) {
global $a;
$a = get_app();
if (!$refresh) {
// Looking if the whole family isn't set
@ -123,7 +126,7 @@ class Config {
* @return mixed Stored $value or false if the database update failed
*/
public static function set($family, $key, $value) {
global $a;
$a = get_app();
$stored = self::get($family, $key);
@ -171,7 +174,7 @@ class Config {
*/
public static function delete($family, $key) {
global $a;
$a = get_app();
if (x($a->config[$family],$key)) {
unset($a->config[$family][$key]);
}

13
include/Core/PConfig.php

@ -1,5 +1,8 @@
<?php
namespace Friendica\Core;
use dbm;
/**
* @file include/Core/PConfig.php
* @brief contains the class with methods for the management
@ -28,12 +31,12 @@ class PConfig {
* @return void
*/
public static function load($uid, $family) {
global $a;
$a = get_app();
$r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`",
dbesc($family),
intval($uid)
);
if (count($r)) {
if (dbm::is_result($r)) {
foreach ($r as $rr) {
$k = $rr['k'];
$a->config[$uid][$family][$k] = $rr['v'];
@ -65,7 +68,7 @@ class PConfig {
*/
public static function get($uid, $family, $key, $default_value = null, $refresh = false) {
global $a;
$a = get_app();
if (!$refresh) {
// Looking if the whole family isn't set
@ -120,7 +123,7 @@ class PConfig {
*/
public static function set($uid, $family, $key, $value) {
global $a;
$a = get_app();
$stored = self::get($uid, $family, $key);
@ -171,7 +174,7 @@ class PConfig {
*/
public static function delete($uid,$family,$key) {
global $a;
$a = get_app();
if (x($a->config[$uid][$family], $key)) {
unset($a->config[$uid][$family][$key]);

2
include/ForumManager.php

@ -88,7 +88,7 @@ class ForumManager {
$total = count($contacts);
$visible_forums = 10;
if(dbm::is_result($contacts)) {
if (dbm::is_result($contacts)) {
$id = 0;

24
include/NotificationsManager.php

@ -88,7 +88,7 @@ class NotificationsManager {
intval(local_user())
);
if(dbm::is_result($r))
if (dbm::is_result($r))
return $this->_set_extra($r);
return false;
@ -105,7 +105,7 @@ class NotificationsManager {
intval($id),
intval(local_user())
);
if(dbm::is_result($r)) {
if (dbm::is_result($r)) {
return $this->_set_extra($r)[0];
}
return null;
@ -358,7 +358,7 @@ class NotificationsManager {
intval(local_user())
);
if(dbm::is_result($r))
if (dbm::is_result($r))
return $r[0]['total'];
return 0;
@ -401,7 +401,7 @@ class NotificationsManager {
intval($limit)
);
if(dbm::is_result($r))
if (dbm::is_result($r))
$notifs = $this->formatNotifs($r, $ident);
$arr = array (
@ -430,7 +430,7 @@ class NotificationsManager {
intval(local_user())
);
if(dbm::is_result($r))
if (dbm::is_result($r))
return $r[0]['total'];
return 0;
@ -466,7 +466,7 @@ class NotificationsManager {
intval($limit)
);
if(dbm::is_result($r))
if (dbm::is_result($r))
$notifs = $this->formatNotifs($r, $ident);
$arr = array (
@ -520,7 +520,7 @@ class NotificationsManager {
intval(local_user())
);
if(dbm::is_result($r))
if (dbm::is_result($r))
return $r[0]['total'];
return 0;
@ -564,7 +564,7 @@ class NotificationsManager {
intval($limit)
);
if(dbm::is_result($r))
if (dbm::is_result($r))
$notifs = $this->formatNotifs($r, $ident);
$arr = array (
@ -596,7 +596,7 @@ class NotificationsManager {
intval(local_user())
);
if(dbm::is_result($r))
if (dbm::is_result($r))
return $r[0]['total'];
return 0;
@ -638,7 +638,7 @@ class NotificationsManager {
intval($limit)
);
if(dbm::is_result($r))
if (dbm::is_result($r))
$notifs = $this->formatNotifs($r, $ident);
$arr = array (
@ -668,7 +668,7 @@ class NotificationsManager {
intval($_SESSION['uid'])
);
if(dbm::is_result($r))
if (dbm::is_result($r))
return $r[0]['total'];
return 0;
@ -713,7 +713,7 @@ class NotificationsManager {
intval($limit)
);
if(dbm::is_result($r))
if (dbm::is_result($r))
$notifs = $this->formatIntros($r);
$arr = array (

2
include/Probe.php

@ -1084,7 +1084,7 @@ class Probe {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval($uid));
if(count($x) && count($r)) {
if (dbm::is_result($x) && dbm::is_result($r)) {
$mailbox = construct_mailbox_name($r[0]);
$password = '';
openssl_private_decrypt(hex2bin($r[0]['pass']), $password,$x[0]['prvkey']);

12
include/acl_selectors.php

@ -33,7 +33,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
call_hooks($a->module . '_pre_' . $selname, $arr);
if(count($r)) {
if (dbm::is_result($r)) {
foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
@ -144,7 +144,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
call_hooks($a->module . '_pre_' . $selname, $arr);
if(count($r)) {
if (dbm::is_result($r)) {
foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
@ -220,7 +220,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$receiverlist = array();
if(count($r)) {
if (dbm::is_result($r)) {
foreach($r as $rr) {
if((is_array($preselected)) && in_array($rr['id'], $preselected))
$selected = " selected=\"selected\" ";
@ -314,7 +314,7 @@ function populate_acl($user = null, $show_jotnets = false) {
$r = q("SELECT `pubmail` FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
intval(local_user())
);
if(count($r)) {
if (dbm::is_result($r)) {
$mail_enabled = true;
if(intval($r[0]['pubmail']))
$pubmail_enabled = true;
@ -577,7 +577,7 @@ function acl_lookup(&$a, $out_type = 'json') {
$r = array();
if(count($r)) {
if (dbm::is_result($r)) {
foreach($r as $g){
$contacts[] = array(
"type" => "c",
@ -612,7 +612,7 @@ function acl_lookup(&$a, $out_type = 'json') {
dbesc($search),
implode("','", $known_contacts)
);
if (is_array($r) && count($r)){
if (dbm::is_result($r)){
foreach($r as $row) {
// nickname..
$up = parse_url($row['author-link']);

33
include/api.php

@ -208,7 +208,7 @@
dbesc(trim($user)),
dbesc($encrypted)
);
if(count($r))
if (dbm::is_result($r))
$record = $r[0];
}
@ -408,13 +408,13 @@
if (is_null($user_info)) $user_info = api_get_user($a);
$arr['$user'] = $user_info;
$arr['$rss'] = array(
'alternate' => $user_info['url'],
'self' => App::get_baseurl(). "/". $a->query_string,
'base' => App::get_baseurl(),
'updated' => api_date(null),
'alternate' => $user_info['url'],
'self' => App::get_baseurl(). "/". $a->query_string,
'base' => App::get_baseurl(),
'updated' => api_date(null),
'atom_updated' => datetime_convert('UTC','UTC','now',ATOM_TIME),
'language' => $user_info['language'],
'logo' => App::get_baseurl()."/images/friendica-32.png",
'language' => $user_info['language'],
'logo' => App::get_baseurl()."/images/friendica-32.png",
);
return $arr;
@ -1326,10 +1326,10 @@
if (isset($_GET["q"])) {
$r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
if (!count($r))
if (!dbm::is_result($r))
$r = q("SELECT `id` FROM `contact` WHERE `uid` = 0 AND `nick` = '%s'", dbesc($_GET["q"]));
if (count($r)) {
if (dbm::is_result($r)) {
$k = 0;
foreach ($r AS $user) {
$user_info = api_get_user($a, $user["id"], "json");
@ -2755,7 +2755,7 @@
intval(api_user())
);
if(!dbm::is_result($r))
if (!dbm::is_result($r))
return;
$ids = array();
@ -3174,7 +3174,7 @@
intval(api_user())
);
if ((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
if ((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
throw new BadRequestException("Unknown contact");
$cid = $r[0]['id'];
@ -3526,7 +3526,7 @@
intval($uid),
intval($gid));
// error message if specified gid is not in database
if (count($r) == 0)
if (!dbm::is_result($r))
throw new BadRequestException("gid not available");
}
else
@ -3581,7 +3581,7 @@
intval($uid),
intval($gid));
// error message if specified gid is not in database
if (count($r) == 0)
if (!dbm::is_result($r))
throw new BadRequestException('gid not available');
// get data of the specified group id and group name
@ -3919,7 +3919,9 @@
$profile_url = $user_info["url"];
// message if nothing was found
if (count($r) == 0)
if (!dbm::is_result($r))
$success = array('success' => false, 'search_results' => 'problem with query');
else if (count($r) == 0)
$success = array('success' => false, 'search_results' => 'nothing found');
else {
$ret = Array();
@ -3941,7 +3943,6 @@
}
api_register_func('api/friendica/direct_messages_search', 'api_friendica_direct_messages_search', true);
/**
* @brief return data of all the profiles a user has to the client
*
@ -3966,7 +3967,7 @@
intval(api_user()),
intval($profileid));
// error message if specified gid is not in database
if (count($r) == 0)
if (!dbm::is_result($r))
throw new BadRequestException("profile_id not available");
}
else

6
include/auth.php

@ -50,7 +50,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
intval($_SESSION['visitor_id'])
);
if (count($r)) {
if (dbm::is_result($r)) {
$a->contact = $r[0];
}
}
@ -73,7 +73,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
intval($_SESSION['uid'])
);
if (!count($r)) {
if (!dbm::is_result($r)) {
nuke_session();
goaway(z_root());
}
@ -169,7 +169,7 @@ if (isset($_SESSION) && x($_SESSION,'authenticated') && (!x($_POST,'auth-params'
dbesc(trim($_POST['username'])),
dbesc($encrypted)
);
if (count($r))
if (dbm::is_result($r))
$record = $r[0];
}

4
include/auth_ejabberd.php

@ -146,7 +146,7 @@ class exAuth {
* @param array $aCommand The command array
*/
private function isuser($aCommand) {
global $a;
$a = get_app();
// Check if there is a username
if (!isset($aCommand[1])) {
@ -214,7 +214,7 @@ class exAuth {
* @param array $aCommand The command array
*/
private function auth($aCommand) {
global $a;
$a = get_app();
// check user authentication
if (sizeof($aCommand) != 4) {

2
include/contact_selectors.php

@ -12,7 +12,7 @@ function contact_profile_assign($current,$foreign_net) {
$r = q("SELECT `id`, `profile-name` FROM `profile` WHERE `uid` = %d",
intval($_SESSION['uid']));
if(count($r)) {
if (dbm::is_result($r)) {
foreach($r as $rr) {
$selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
$o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile-name']}</option>\r\n";

6
include/contact_widgets.php

@ -93,7 +93,7 @@ function networks_widget($baseurl,$selected = '') {
);
$nets = array();
if(count($r)) {
if (dbm::is_result($r)) {
require_once('include/contact_selectors.php');
foreach($r as $rr) {
if($rr['network'])
@ -204,13 +204,13 @@ function common_friends_visitor_widget($profile_uid) {
dbesc(normalise_link(get_my_url())),
intval($profile_uid)
);
if(count($r))
if (dbm::is_result($r))
$cid = $r[0]['id'];
else {
$r = q("select id from gcontact where nurl = '%s' limit 1",
dbesc(normalise_link(get_my_url()))
);
if(count($r))
if (dbm::is_result($r))
$zcid = $r[0]['id'];
}
}

6
include/conversation.php

@ -109,7 +109,7 @@ function localize_item(&$item){
$r = q("SELECT * from `item`,`contact` WHERE
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
dbesc($item['parent-uri']));
if(count($r)==0) return;
if (!dbm::is_result($r)) return;
$obj=$r[0];
$author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
@ -245,7 +245,7 @@ function localize_item(&$item){
$r = q("SELECT * from `item`,`contact` WHERE
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
dbesc($item['parent-uri']));
if(count($r)==0) return;
if (!dbm::is_result($r)) return;
$obj=$r[0];
$author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
@ -294,7 +294,7 @@ function localize_item(&$item){
dbesc($obj->id),
intval($item['uid'])
);
if(count($r) && $r[0]['plink']) {
if (dbm::is_result($r) && $r[0]['plink']) {
$target = $r[0];
$Bname = $target['author-name'];
$Blink = $target['author-link'];

6
include/cron.php

@ -43,7 +43,7 @@ function cron_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
if (App::maxload_reached())
if ($a->maxload_reached())
return;
if (App::is_already_running('cron', 'include/cron.php', 540))
return;
@ -434,7 +434,7 @@ function cron_repair_diaspora(&$a) {
$r = q("SELECT `id`, `url` FROM `contact`
WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA));
if ($r) {
if (dbm::is_result($r)) {
foreach ($r AS $contact) {
if (poco_reachable($contact["url"])) {
$data = probe_url($contact["url"]);
@ -474,7 +474,7 @@ function cron_repair_database() {
// Update the global contacts for local users
$r = q("SELECT `uid` FROM `user` WHERE `verified` AND NOT `blocked` AND NOT `account_removed` AND NOT `account_expired`");
if ($r)
if (dbm::is_result($r))
foreach ($r AS $user)
update_gcontact_for_user($user["uid"]);

2
include/cronhooks.php

@ -25,7 +25,7 @@ function cronhooks_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run") {
if (App::maxload_reached())
if ($a->maxload_reached())
return;
if (App::is_already_running('cronhooks', 'include/cronhooks.php', 1140))
return;

2
include/datetime.php

@ -552,7 +552,7 @@ function update_contact_birthdays() {
// In-network birthdays are handled within local_delivery
$r = q("SELECT * FROM contact WHERE `bd` != '' AND `bd` != '0000-00-00' AND SUBSTRING(`bd`,1,4) != `bdyear` ");
if(count($r)) {
if (dbm::is_result($r)) {
foreach($r as $rr) {
logger('update_contact_birthday: ' . $rr['bd']);

4
include/dba.php

@ -35,7 +35,7 @@ class dba {
public $error = false;
function __construct($server, $user, $pass, $db, $install = false) {
global $a;
$a = get_app();
$stamp1 = microtime(true);
@ -139,7 +139,7 @@ class dba {
}
public function q($sql, $onlyquery = false) {
global $a;
$a = get_app();
if (!$this->db || !$this->connected) {
return false;

4
include/dba_pdo.php

@ -44,7 +44,7 @@ class dba {
public $error = false;
function __construct($server,$user,$pass,$db,$install = false) {
global $a;
$a = get_app();
# work around, to store the database - configuration in DDDBL
$objDataObjectPool = new \DDDBL\DataObjectPool('Database-Definition');
@ -99,7 +99,7 @@ class dba {
}
public function q($sql, $onlyquery = false) {
global $a;
$a = get_app();
$strHandler = (true === $onlyquery) ? 'PDOStatement' : 'MULTI';

17
include/dbstructure.php

@ -17,6 +17,14 @@ function update_fail($update_id, $error_message){
$admin_mail_list
);
// No valid result?
if (!dbm::is_result($adminlist)) {
logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
// Don't continue
return;
}
// every admin could had different language
foreach ($adminlist as $admin) {
@ -73,7 +81,7 @@ function table_structure($table) {
$fielddata = array();
$indexdata = array();
if (is_array($indexes))
if (dbm::is_result($indexes))
foreach ($indexes AS $index) {
if ($index["Index_type"] == "FULLTEXT")
continue;
@ -93,7 +101,7 @@ function table_structure($table) {
$indexdata[$index["Key_name"]][] = $column;
}
if (is_array($structures)) {
if (dbm::is_result($structures)) {
foreach($structures AS $field) {
$fielddata[$field["Field"]]["type"] = $field["Type"];
if ($field["Null"] == "NO")
@ -151,6 +159,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
foreach ($tables AS $table) {
$table = current($table);
logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
$database[$table] = table_structure($table);
}
@ -179,7 +188,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
$sql3="";
if (!isset($database[$name])) {
$r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']);
if(false === $r) {
if (!dbm::is_result($r)) {
$errors .= t('Errors encountered creating database tables.').$name.EOL;
}
$is_new_table = True;
@ -256,7 +265,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
if ($action) {
$r = @$db->q($sql3);
if(false === $r)
if (dbm::is_result($r))
$errors .= t('Errors encountered performing database changes.').$sql3.EOL;
}
}

16
include/delivery.php

@ -53,11 +53,11 @@ function delivery_run(&$argv, &$argc){
dbesc($item_id),
dbesc($contact_id)
);
if (!count($r)) {
if (!dbm::is_result($r)) {
continue;
}
if (App::maxload_reached())
if ($a->maxload_reached())
return;
// It's ours to deliver. Remove it from the queue.
@ -131,7 +131,7 @@ function delivery_run(&$argv, &$argc){
intval($item_id)
);
if ((!count($r)) || (!intval($r[0]['parent']))) {
if ((!dbm::is_result($r)) || (!intval($r[0]['parent']))) {
continue;
}
@ -184,7 +184,7 @@ function delivery_run(&$argv, &$argc){
intval($uid)
);
if (!count($r))
if (!dbm::is_result($r))
continue;
$owner = $r[0];
@ -254,7 +254,7 @@ function delivery_run(&$argv, &$argc){
intval($contact_id)
);
if (count($r))
if (dbm::is_result($r))
$contact = $r[0];
if ($contact['self'])
@ -423,7 +423,7 @@ function delivery_run(&$argv, &$argc){
intval($argv[2]),
intval($uid)
);
if (count($r))
if (dbm::is_result($r))
$it = $r[0];
}
if (!$it)
@ -478,14 +478,14 @@ function delivery_run(&$argv, &$argc){
dbesc($it['parent-uri']),
intval($uid));
if (count($r) AND ($r[0]['title'] != ''))
if (dbm::is_result($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title'];
else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));
if (count($r) AND ($r[0]['title'] != ''))
if (dbm::is_result($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title'];
}
}

33
include/dfrn.php

@ -105,7 +105,7 @@ class dfrn {
dbesc($owner_nick)
);
if(! count($r))
if(! dbm::is_result($r))
killme();
$owner = $r[0];
@ -139,7 +139,7 @@ class dfrn {
intval($owner_id)
);
if(! count($r))
if(! dbm::is_result($r))
killme();
$contact = $r[0];
@ -1443,6 +1443,7 @@ class dfrn {
* @param array $importer Record of the importer user mixed with contact of the content
*/
private function process_suggestion($xpath, $suggestion, $importer) {
$a = get_app();
logger("Processing suggestions");
@ -1462,7 +1463,7 @@ class dfrn {
dbesc(normalise_link($suggest["url"])),
intval($suggest["uid"])
);
if(count($r))
if (dbm::is_result($r))
return false;
// Do we already have an fcontact record for this person?
@ -1473,7 +1474,7 @@ class dfrn {
dbesc($suggest["name"]),
dbesc($suggest["request"])
);
if(count($r)) {
if (dbm::is_result($r)) {
$fid = $r[0]["id"];
// OK, we do. Do we already have an introduction for this person ?
@ -1481,7 +1482,7 @@ class dfrn {
intval($suggest["uid"]),
intval($fid)
);
if(count($r))
if (dbm::is_result($r))
return false;
}
if(!$fid)
@ -1496,7 +1497,7 @@ class dfrn {
dbesc($suggest["name"]),
dbesc($suggest["request"])
);
if(count($r))
if (dbm::is_result($r))
$fid = $r[0]["id"];
else
// database record did not get created. Quietly give up.
@ -1745,7 +1746,7 @@ class dfrn {
LIMIT 1",
dbesc($item["parent-uri"])
);
if($r && count($r)) {
if (dbm::is_result($r)) {
$r = q("SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s')
@ -1757,7 +1758,7 @@ class dfrn {
dbesc($r[0]["parent-uri"]),
intval($importer["importer_uid"])
);
if($r && count($r))
if (dbm::is_result($r))
$is_a_remote_action = true;
}
@ -1895,7 +1896,7 @@ class dfrn {
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
if($r && count($r))
if (dbm::is_result($r))
return false;
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `author-link` = '%s' AND `verb` = '%s' AND `thr-parent` = '%s' AND NOT `deleted` LIMIT 1",
@ -1904,7 +1905,7 @@ class dfrn {
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
if($r && count($r))
if (dbm::is_result($r))
return false;
} else
$is_like = false;
@ -1920,7 +1921,7 @@ class dfrn {
intval($importer["importer_uid"])
);
if(!count($r))
if (!dbm::is_result($r))
return false;
// extract tag, if not duplicate, add to parent item
@ -2192,7 +2193,7 @@ class dfrn {
dbesc($item["uri"]),
intval($importer["uid"])
);
if(count($r))
if (dbm::is_result($r))
$ev["id"] = $r[0]["id"];
$event_id = event_store($ev);
@ -2213,7 +2214,7 @@ class dfrn {
}
// Update content if 'updated' changes
if(count($r)) {
if (dbm::is_result($r)) {
if (self::update_content($r[0], $item, $importer, $entrytype))
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
else
@ -2235,7 +2236,7 @@ class dfrn {
intval($posted_id),
intval($importer["importer_uid"])
);
if(count($r)) {
if (dbm::is_result($r)) {
$parent = $r[0]["parent"];
$parent_uri = $r[0]["parent-uri"];
}
@ -2323,7 +2324,7 @@ class dfrn {
intval($importer["uid"]),
intval($importer["id"])
);
if(!count($r)) {
if (!dbm::is_result($r)) {
logger("Item with uri ".$uri." from contact ".$importer["id"]." for user ".$importer["uid"]." wasn't found.", LOGGER_DEBUG);
return;
} else {
@ -2417,7 +2418,7 @@ class dfrn {
dbesc($item["parent-uri"]),
intval($importer["uid"])
);
if(count($r)) {
if (dbm::is_result($r)) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
intval($r[0]["id"])
);

8
include/diaspora.php

@ -1278,7 +1278,7 @@ class diaspora {
$r = q("SELECT `id` FROM `mail` WHERE `uri` = '%s' LIMIT 1",
dbesc($message_uri)
);
if($r) {
if (dbm::is_result($r)) {
logger("duplicate message already delivered.", LOGGER_DEBUG);
return false;
}
@ -2925,7 +2925,7 @@ class diaspora {
$p = q("SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($item["thr-parent"]));
if(!$p)
if (!dbm::is_result($p))
return false;
$parent = $p[0];
@ -2956,7 +2956,7 @@ class diaspora {
intval($item["parent"])
);
if (!$p)
if (!dbm::is_result($p))
return false;
$parent = $p[0];
@ -3170,7 +3170,7 @@ class diaspora {
intval($item["uid"])
);
if (!$r) {
if (!dbm::is_result($r)) {
logger("conversation not found.");
return;
}

2
include/discover_poco.php

@ -26,7 +26,7 @@ function discover_poco_run(&$argv, &$argc){
// Don't check this stuff if the function is called by the poller
if (App::callstack() != "poller_run")
if (App::maxload_reached())
if ($a->maxload_reached())
return;
if(($argc > 2) && ($argv[1] == "dirsearch")) {

11
include/enotify.php

@ -411,7 +411,7 @@ function notification($params) {
$hash = random_string();
$r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1",
dbesc($hash));
if (count($r))
if (dbm::is_result($r))
$dups = true;
} while($dups == true);
@ -648,6 +648,7 @@ function notification($params) {
* @param str $defaulttype (Optional) Forces a notification with this type.
*/
function check_item_notification($itemid, $uid, $defaulttype = "") {
$a = get_app();
$notification_data = array("uid" => $uid, "profiles" => array());
call_hooks('check_item_notification', $notification_data);
@ -666,7 +667,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
$profiles[] = $owner[0]["url"];
// Notifications from Diaspora are often with an URL in the Diaspora format
$profiles[] = App::get_baseurl()."/u/".$user[0]["nickname"];
$profiles[] = $a->get_baseurl()."/u/".$user[0]["nickname"];
$profiles2 = array();
@ -732,17 +733,17 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
intval($item[0]['contact-id']),
intval($uid)
);
$send_notification = count($r);
$send_notification = dbm::is_result($r);
if (!$send_notification) {
$tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
intval(TERM_OBJ_POST), intval($itemid), intval(TERM_MENTION), intval($uid));
if (count($tags)) {
if (dbm::is_result($tags)) {
foreach ($tags AS $tag) {
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
normalise_link($tag["url"]), intval($uid));
if (count($r))
if (dbm::is_result($r))
$send_notification = true;
}
}

18
include/event.php

@ -271,7 +271,7 @@ function event_store($arr) {
intval($arr['id']),
intval($arr['uid'])
);
if((! count($r)) || ($r[0]['edited'] === $arr['edited'])) {
if((! dbm::is_result($r)) || ($r[0]['edited'] === $arr['edited'])) {
// Nothing has changed. Grab the item id to return.
@ -279,7 +279,7 @@ function event_store($arr) {
intval($arr['id']),
intval($arr['uid'])
);
return((count($r)) ? $r[0]['id'] : 0);
return((dbm::is_result($r)) ? $r[0]['id'] : 0);
}
// The event changed. Update it.
@ -312,7 +312,7 @@ function event_store($arr) {
intval($arr['id']),
intval($arr['uid'])
);
if(count($r)) {
if (dbm::is_result($r)) {
$object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>';
$object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>';
$object .= '</object>' . "\n";
@ -365,7 +365,7 @@ function event_store($arr) {
dbesc($arr['uri']),
intval($arr['uid'])
);
if(count($r))
if (dbm::is_result($r))
$event = $r[0];
$item_arr = array();
@ -407,7 +407,7 @@ function event_store($arr) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($arr['uid'])
);
//if(count($r))
//if (dbm::is_result($r))
// $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id;
@ -515,7 +515,7 @@ function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
intval($event_params["event_id"])
);
if(count($r))
if (dbm::is_result($r))
return $r;
}
@ -557,7 +557,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
dbesc($event_params["adjust_finish"])
);