aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-12-03 22:30:15 +0100
committerGravatar GitHub <noreply@github.com> 2023-12-03 22:30:15 +0100
commit133892a89e065cd98635c21bf5a886cfed08aeb8 (patch)
tree8ff2625800ea8584ae78536f471678252ed3c68c /lib
parentf0d4f2762d2b74eeadf2fb64ff83039b5cc16c26 (diff)
Better debug SQL error (#5916)
* Better debug SQL error * Fix check
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ModelPdo.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index c78f44f2e..69b2357d2 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -196,9 +196,17 @@ class Minz_ModelPdo {
}
}
- $callingFunction = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'] ?? '??';
+ $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);
+ $calling = '';
+ for ($i = 2; $i < 6; $i++) {
+ if (empty($backtrace[$i]['function'])) {
+ break;
+ }
+ $calling .= '|' . $backtrace[$i]['function'];
+ }
+ $calling = trim($calling, '|');
$info = $stm == null ? $this->pdo->errorInfo() : $stm->errorInfo();
- Minz_Log::error('SQL error ' . $callingFunction . ' ' . json_encode($info));
+ Minz_Log::error('SQL error ' . $calling . ' ' . json_encode($info));
return null;
}