]> git.mxchange.org Git - friendica.git/commitdiff
database logging now works for database errors
authorMichael <heluecht@pirati.ca>
Tue, 11 Jul 2017 19:14:49 +0000 (19:14 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 11 Jul 2017 19:14:49 +0000 (19:14 +0000)
include/Contact.php
include/dba.php

index a1597cf304bbd1cc9e1fb527fb6c0e09be5b3388..fea4a2aaf1537c35e2d3e3a4bd26225a415ee832 100644 (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"])),
index e39e6f136e6bf5b0964fa047d10036d46c44a8c9..49ec9564533ae6061af96212294551e491e3fa8e 100644 (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;