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"];
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"],
'nurl' => normalise_link($data["url"]), 'addr' => $data["addr"],
'alias' => $data["alias"], 'notify' => $data["notify"], 'poll' => $data["poll"],
'name' => $data["name"], 'nick' => $data["nick"], 'photo' => $data["photo"],
'network' => $data["network"], 'pubkey' => $data["pubkey"],
'rel' => CONTACT_IS_SHARING, 'priority' => $data["priority"],
'batch' => $data["batch"], 'request' => $data["request"], 'confirm' => $data["confirm"],
'poco' => $data["poco"], 'name-date' => datetime_convert(),
'uri-date' => datetime_convert(), 'avatar-date' => datetime_convert(),
'writable' => 1, 'blocked' => 0, 'readonly' => 0, 'pending' => 0));
'batch' => $data["batch"], 'request' => $data["request"],
'confirm' => $data["confirm"], 'poco' => $data["poco"],
'name-date' => datetime_convert(), 'uri-date' => datetime_convert(),
'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",
dbesc(normalise_link($data["url"])),

View file

@ -647,8 +647,11 @@ class dba {
$error = self::$dbo->error;
$errorno = self::$dbo->errorno;
$sql = $args[0];
array_shift($args);
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->errorno = $errorno;
@ -711,8 +714,11 @@ class dba {
$error = self::$dbo->error;
$errorno = self::$dbo->errorno;
$sql = $args[0];
array_shift($args);
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->errorno = $errorno;