summaryrefslogtreecommitdiffstats
path: root/lib/mysql.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mysql.php')
-rw-r--r--lib/mysql.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/mysql.php b/lib/mysql.php
index 6473868..1ebc5e5 100644
--- a/lib/mysql.php
+++ b/lib/mysql.php
@@ -737,10 +737,20 @@ namespace Dshafik {
$type = strtolower(gettype($result));
$file = "";
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
- if (isset($backtrace[1], $backtrace[1]['file'], $backtrace[1]['line'])) {
- $caller = $backtrace[1];
- $file = $caller['file'] . ':' . $caller['line'];
- }
+ $backtraceIndex = 0;
+
+ /**
+ * Iterate through backtrace until find an backtrace with origin
+ * Some methods may not leave file and line metadata like call_user_func_array and __call
+ */
+ do {
+ $currentBacktrace = $backtrace[$backtraceIndex];
+ $callerHasFileAndLine = isset($currentBacktrace['file'], $currentBacktrace['line']);
+
+ if ($callerHasFileAndLine && $currentBacktrace['file'] != __FILE__) {
+ $file = $currentBacktrace['file'] . ':' . $currentBacktrace['line'];
+ }
+ } while ($backtraceIndex++ < count($backtrace) && $file == "");
if ($function !== 'mysql_fetch_object') {
trigger_error(