samsonasik / ErrorHeroModule

:gem: A Hero for your Zend Framework/Laminas, and Expressive/Mezzio application to log ( DB and Mail ) and handle php errors & exceptions during Mvc process/between request and response
MIT License
50 stars 6 forks source link

excluded errors are not excluded #96

Closed pschelte-extec closed 1 year ago

pschelte-extec commented 1 year ago

What ZF/Expressive/Laminas/Mezzio application I'm using when issue happen ?

What PHP version you're using?

What ErrorHeroModule version you're using?

What Database you're using?

Expected behavior

I have added \E_DEPRECATED error as a value of the array 'exclude-php-errors' in the config file so E_DEPRACATED errors should be ignored.

Actual behavior

E_DEPRECATED errors are still catched even if I have added \E_DEPRECATED error as a value of the array 'exclude-php-errors' in the config file.

Steps/Codes to reproduce the behavior

in \config\autoload\error-hero-module.global.php

        'exclude-php-errors' => [
            \E_USER_DEPRECATED,
            \E_DEPRECATED, // <--- add this
        ],

in index.php add this at the first beginning :

<?php $a = false; $a[] = 1;

execute index.php within your app in your browser.

the E_DEPRECATED error is catched by ErrorHeroModule.

samsonasik commented 1 year ago

That's expected as in index.php early line, the service is not loaded yet. This works on module level, you should not touch index.php with custom logic.

pschelte-extec commented 1 year ago

You are probably right, but how can you explain that the deprecated error is logged in the DB by ErrorHeroModule and that the user friendly message provided by ErrorHeroModule is displayed instead of the usual basic PHP error ?

here is the message I have in my DB reported by ErrorHeroModule :

Automatic conversion of false to array is deprecated /ec/prod/app/webroot/home/food/safety/food_waste/eu-food-loss-waste-prevention-hub/index.php 10 E_DEPRECATED

samsonasik commented 1 year ago

That's out of this module scope, again, this is on module level, index.php consume the module on this execution:

https://github.com/laminas/laminas-mvc-skeleton/blob/e4bfbffdd5c52b680f515fa4853efefd0bc6d7fa/public/index.php#L35-L36

this module doesn't covert error to message, it is for logging and trap purpose.