mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-02 09:24:28 +02:00
muteUndefinedOrNullWarnings() now also mutes PHP8 warnings for undefined properties (#891)
This commit is contained in:
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `$smarty->muteUndefinedOrNullWarnings()` now also mutes PHP8 warnings for undefined properties
|
||||||
|
|
||||||
## [4.3.1] - 2023-03-28
|
## [4.3.1] - 2023-03-28
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
@@ -17,6 +17,12 @@ class Smarty_Internal_ErrorHandler
|
|||||||
*/
|
*/
|
||||||
public $allowUndefinedVars = true;
|
public $allowUndefinedVars = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows {$foo->propName} where propName is undefined.
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $allowUndefinedProperties = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows {$foo.bar} where bar is unset and {$foo.bar1.bar2} where either bar1 or bar2 is unset.
|
* Allows {$foo.bar} where bar is unset and {$foo.bar1.bar2} where either bar1 or bar2 is unset.
|
||||||
* @var bool
|
* @var bool
|
||||||
@@ -80,6 +86,13 @@ class Smarty_Internal_ErrorHandler
|
|||||||
return; // suppresses this error
|
return; // suppresses this error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->allowUndefinedProperties && preg_match(
|
||||||
|
'/^(Undefined property)/',
|
||||||
|
$errstr
|
||||||
|
)) {
|
||||||
|
return; // suppresses this error
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->allowUndefinedArrayKeys && preg_match(
|
if ($this->allowUndefinedArrayKeys && preg_match(
|
||||||
'/^(Undefined index|Undefined array key|Trying to access array offset on value of type)/',
|
'/^(Undefined index|Undefined array key|Trying to access array offset on value of type)/',
|
||||||
$errstr
|
$errstr
|
||||||
|
Reference in New Issue
Block a user