summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorSimon Wisselink <wisskid@users.noreply.github.com>2022-11-24 09:43:51 +0100
committerGitHub <noreply@github.com>2022-11-24 09:43:51 +0100
commitc0a6b641bf9344968040b940f5d2aeae6a719a39 (patch)
tree450c3d6ba723f0d0cc71cd663fd65212bec613ac /libs
parent044647bd71cd101d214e16e9aee435a1ed8d0d1e (diff)
downloadsmarty-c0a6b641bf9344968040b940f5d2aeae6a719a39.tar.gz
smarty-c0a6b641bf9344968040b940f5d2aeae6a719a39.tar.bz2
smarty-c0a6b641bf9344968040b940f5d2aeae6a719a39.zip
Treat undefined vars and array access of a null or false variables equivalent across all supported PHP versions (#830)
* Added test to see what changed exactly * Treat undefined vars and array access of a null or false variables equivalent across all supported PHP versions * Removed 2 tests that produce inconsistent results between PHP7.x versions. * Fix regex matching for slightly different error message for php7.1
Diffstat (limited to 'libs')
-rw-r--r--libs/sysplugins/smarty_internal_errorhandler.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/libs/sysplugins/smarty_internal_errorhandler.php b/libs/sysplugins/smarty_internal_errorhandler.php
index f5abbf28..cb19070d 100644
--- a/libs/sysplugins/smarty_internal_errorhandler.php
+++ b/libs/sysplugins/smarty_internal_errorhandler.php
@@ -66,12 +66,16 @@ class Smarty_Internal_ErrorHandler
*/
public function handleError($errno, $errstr, $errfile, $errline, $errcontext = [])
{
- if ($this->allowUndefinedVars && $errstr == 'Attempt to read property "value" on null') {
+
+ if ($this->allowUndefinedVars && preg_match(
+ '/^(Attempt to read property "value" on null|Trying to get property (\'value\' )?of non-object)/',
+ $errstr
+ )) {
return; // suppresses this error
}
if ($this->allowUndefinedArrayKeys && preg_match(
- '/^(Undefined index|Undefined array key|Trying to access array offset on value of type null)/',
+ '/^(Undefined index|Undefined array key|Trying to access array offset on value of type (null|bool))/',
$errstr
)) {
return; // suppresses this error