mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 09:54:27 +02:00
Also mute php7 notices for undefined array indexes when muteUndefinedOrNullWarnings is activated. (#829)
Fixes #736
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 PHP7 notices for undefined array indexes [#736](https://github.com/smarty-php/smarty/issues/736)
|
||||||
|
|
||||||
## [4.3.0] - 2022-11-22
|
## [4.3.0] - 2022-11-22
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@@ -1386,8 +1386,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activates PHP7 compatibility mode:
|
* Mutes errors for "undefined index", "undefined array key" and "trying to read property of null".
|
||||||
* - converts E_WARNINGS for "undefined array key" and "trying to read property of null" errors to E_NOTICE
|
|
||||||
*
|
*
|
||||||
* @void
|
* @void
|
||||||
*/
|
*/
|
||||||
@@ -1396,7 +1395,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if PHP7 compatibility mode is set.
|
* Indicates if Smarty will mute errors for "undefined index", "undefined array key" and "trying to read property of null".
|
||||||
* @bool
|
* @bool
|
||||||
*/
|
*/
|
||||||
public function isMutingUndefinedOrNullWarnings(): bool {
|
public function isMutingUndefinedOrNullWarnings(): bool {
|
||||||
|
@@ -71,7 +71,7 @@ class Smarty_Internal_ErrorHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->allowUndefinedArrayKeys && preg_match(
|
if ($this->allowUndefinedArrayKeys && preg_match(
|
||||||
'/^(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)/',
|
||||||
$errstr
|
$errstr
|
||||||
)) {
|
)) {
|
||||||
return; // suppresses this error
|
return; // suppresses this error
|
||||||
|
Reference in New Issue
Block a user