Disable deprecation warnings unless ICINGAWEB_ENVIRONMENT is set to "dev" (#5359)

in ApplicationBootstrap#setupErrorHandling(). In webrouter.php disable
them unconditionally (until ApplicationBootstrap#setupErrorHandling())
not to duplicate the check. ApplicationBootstrap#setupErrorHandling())
is called pretty early, so we won't miss much.

fixes #5117

* In addition, this provides #5269 and mitigates #5152 in production
where ICINGAWEB_ENVIRONMENT isn't set.

(cherry picked from commit 5333f2deb71597b2907d77f6eb06ff6636560218)
This commit is contained in:
Alexander Aleksandrovič Klimov 2025-05-05 17:58:28 +02:00 committed by Johannes Meyer
parent 879211df2e
commit 67ff0546c0
3 changed files with 3 additions and 5 deletions

View File

@ -568,7 +568,7 @@ abstract class ApplicationBootstrap
*/
protected function setupErrorHandling()
{
error_reporting(E_ALL | E_STRICT);
error_reporting(getenv('ICINGAWEB_ENVIRONMENT') === 'dev' ? E_ALL : E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
@ -579,7 +579,6 @@ abstract class ApplicationBootstrap
switch ($errno) {
case E_NOTICE:
case E_WARNING:
case E_STRICT:
case E_RECOVERABLE_ERROR:
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

View File

@ -8,7 +8,7 @@ use Icinga\Web\Controller\StaticController;
use Icinga\Web\JavaScript;
use Icinga\Web\StyleSheet;
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
if (isset($_SERVER['REQUEST_URI'])) {
$ruri = $_SERVER['REQUEST_URI'];

View File

@ -21,7 +21,7 @@ class LocalFileStorageTest extends BaseTestCase
parent::__construct($name, $data, $dataName);
$this->oldErrorReportingLevel = error_reporting();
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
if (error_reporting() === 0) {
@ -32,7 +32,6 @@ class LocalFileStorageTest extends BaseTestCase
switch ($errno) {
case E_NOTICE:
case E_WARNING:
case E_STRICT:
case E_RECOVERABLE_ERROR:
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}