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

PHP 8 throws Fatal Error in Logging.php when loading a Mezzio page via AJAX #78

Closed dennis-fedco closed 3 years ago

dennis-fedco commented 3 years 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

no errors are thrown when loading a Mezzio page via AJAX

Actual behavior

PHP Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, Laminas\Diactoros\PhpInputStream given in vendor\samsonasik\error-hero-module\src\Handler\Logging.php:120 Stack trace:

0 vendor\samsonasik\error-hero-module\src\Handler\Logging.php(120): str_replace('\r\n', '', Object(Laminas\Diactoros\PhpInputStream))

1 vendor\samsonasik\error-hero-module\src\Handler\Logging.php(192): ErrorHeroModule\Handler\Logging->getRequestData(Object(Laminas\Psr7Bridge\Laminas\Request))

2 vendor\samsonasik\error-hero-module\src\Handler\Logging.php(227): ErrorHeroModule\Handler\Logging->collectErrorExceptionExtraData(Array, Object(Laminas\Psr7Bridge\Laminas\Request))

3 vendor\samsonasik\error-hero-module\src\Middleware\Mezzio.php(78): ErrorHeroModule\Handler\Logging->handleErrorException(Object(ErrorException), Object(Laminas\Psr7Bridge\Laminas\Request))

4 vendor\samsonasik\error-hero-module\src\HeroTrait.php(107): ErrorHeroModule\Middleware\Mezzio->exceptionError(Object(ErrorException))

5 [internal function]: ErrorHeroModule\Middleware\Mezzio->execOnShutdown()

6 {main}

thrown in vendor\samsonasik\error-hero-module\src\Handler\Logging.php on line 120

Steps/Codes to reproduce the behavior

With PHP 8.0.3 I used AJAX loading method My code has this: <a href="#" onclick="$('#div_id').load('/proposal/form');">Load Form</a>

Note - going to /proposal/form URL directly loads the form just fine. The error only happens when I use AJAX link to load the form. I am not sure if the error is related to AJAX specifically, but that is what I am observing at this time.

samsonasik commented 3 years ago

This module is not support php 8 yet, see https://github.com/samsonasik/ErrorHeroModule/blob/aabe0bb10ecd079778e4ca7826ee096fddf1fdba/composer.json#L41

samsonasik commented 3 years ago

Please check if https://github.com/samsonasik/ErrorHeroModule/pull/79 fix the issue.

Otherwise, there are an ongoing works for php 8 compatible https://github.com/samsonasik/ErrorHeroModule/pull/77 , just not sure when I will have a chance to implement it.

samsonasik commented 3 years ago

I just released version 4 which support php 8 https://github.com/samsonasik/ErrorHeroModule/releases/tag/4.0.0