1
0
Fork 0

database logging now works for database errors

This commit is contained in:
Michael 2017-07-11 19:14:49 +00:00
parent 8ec7f1de56
commit 35b3723c4a
2 changed files with 19 additions and 6 deletions

View file

@ -577,16 +577,23 @@ function get_contact($url, $uid = 0, $no_update = false) {
$url = $data["url"]; $url = $data["url"];
if (!$contact_id) { if (!$contact_id) {
if (!isset($data['priority'])) {
$data['priority'] = 0;
}
if (!isset($data['batch'])) {
$data['batch'] = '';
}
dba::insert('contact', array('uid' => $uid, 'created' => datetime_convert(), 'url' => $data["url"], dba::insert('contact', array('uid' => $uid, 'created' => datetime_convert(), 'url' => $data["url"],
'nurl' => normalise_link($data["url"]), 'addr' => $data["addr"], 'nurl' => normalise_link($data["url"]), 'addr' => $data["addr"],
'alias' => $data["alias"], 'notify' => $data["notify"], 'poll' => $data["poll"], 'alias' => $data["alias"], 'notify' => $data["notify"], 'poll' => $data["poll"],
'name' => $data["name"], 'nick' => $data["nick"], 'photo' => $data["photo"], 'name' => $data["name"], 'nick' => $data["nick"], 'photo' => $data["photo"],
'network' => $data["network"], 'pubkey' => $data["pubkey"], 'network' => $data["network"], 'pubkey' => $data["pubkey"],
'rel' => CONTACT_IS_SHARING, 'priority' => $data["priority"], 'rel' => CONTACT_IS_SHARING, 'priority' => $data["priority"],
'batch' => $data["batch"], 'request' => $data["request"], 'confirm' => $data["confirm"], 'batch' => $data["batch"], 'request' => $data["request"],
'poco' => $data["poco"], 'name-date' => datetime_convert(), 'confirm' => $data["confirm"], 'poco' => $data["poco"],
'uri-date' => datetime_convert(), 'avatar-date' => datetime_convert(), 'name-date' => datetime_convert(), 'uri-date' => datetime_convert(),
'writable' => 1, 'blocked' => 0, 'readonly' => 0, 'pending' => 0)); 'avatar-date' => datetime_convert(), 'writable' => 1, 'blocked' => 0,
'readonly' => 0, 'pending' => 0));
$contacts = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2", $contacts = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d ORDER BY `id` LIMIT 2",
dbesc(normalise_link($data["url"])), dbesc(normalise_link($data["url"])),

View file

@ -647,8 +647,11 @@ class dba {
$error = self::$dbo->error; $error = self::$dbo->error;
$errorno = self::$dbo->errorno; $errorno = self::$dbo->errorno;
$sql = $args[0];
array_shift($args);
logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n". logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n".
$a->callstack(8))."\n".self::replace_parameters($sql, $args); $a->callstack(8)."\n".self::replace_parameters($sql, $args));
self::$dbo->error = $error; self::$dbo->error = $error;
self::$dbo->errorno = $errorno; self::$dbo->errorno = $errorno;
@ -711,8 +714,11 @@ class dba {
$error = self::$dbo->error; $error = self::$dbo->error;
$errorno = self::$dbo->errorno; $errorno = self::$dbo->errorno;
$sql = $args[0];
array_shift($args);
logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n". logger('DB Error '.self::$dbo->errorno.': '.self::$dbo->error."\n".
$a->callstack(8))."\n".self::replace_parameters($sql, $args); $a->callstack(8)."\n".self::replace_parameters($sql, $args));
self::$dbo->error = $error; self::$dbo->error = $error;
self::$dbo->errorno = $errorno; self::$dbo->errorno = $errorno;