summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernando da Silva Sousa <wild.nando@gmail.com>2020-10-22 14:44:33 -0300
committerFernando da Silva Sousa <wild.nando@gmail.com>2020-10-22 14:44:33 -0300
commitb1aed042d7cd27bd8705d5524ec0c0a930d546fd (patch)
tree42ea173eb012286c55e911366ec1dbab7b37ad78
parent697e0eb466aa474ff054d7e6908ab873d77dcdcf (diff)
downloadphp7-mysql-shim-b1aed042d7cd27bd8705d5524ec0c0a930d546fd.zip
php7-mysql-shim-b1aed042d7cd27bd8705d5524ec0c0a930d546fd.tar.gz
php7-mysql-shim-b1aed042d7cd27bd8705d5524ec0c0a930d546fd.tar.bz2
Adds backtrace for illegal arguments supplied
-rw-r--r--lib/mysql.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/mysql.php b/lib/mysql.php
index a0ebb5a..6473868 100644
--- a/lib/mysql.php
+++ b/lib/mysql.php
@@ -734,16 +734,24 @@ namespace Dshafik {
public static function checkValidResult($result, $function)
{
if (!($result instanceof \mysqli_result)) {
+ $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'];
+ }
+
if ($function !== 'mysql_fetch_object') {
trigger_error(
- $function . '() expects parameter 1 to be resource, ' . strtolower(gettype($result)) . ' given',
+ "$function() expects parameter 1 to be resource, $type given on $file",
E_USER_WARNING
);
}
if ($function === 'mysql_fetch_object') {
trigger_error(
- $function . '(): supplied argument is not a valid MySQL result resource',
+ "$function(): supplied argument is not a valid MySQL result resource on $file",
E_USER_WARNING
);
}