Jump to content

Fix for unusable PHP debug in Blesta 5.6.0 with PHP 8.1


John Heenan

Recommended Posts

Setting PHP debug in Blesta 5.6.0 editing config/blesta.php to below

// PHP error_reporting. 0 to disable error reporting, -1 to to show all errors                                                          
// Consult php's documentation for additional options
Configure::errorReporting(-1);
// Override minPHP's debugging setting. true to enable debugging, false to disable it
Configure::set('System.debug', true);

 

always results in error message starting with below in browser, making Blesta unsuable with PHP debug. 

Something went wrong.
Return type of Minphp\Session\Handlers\PdoHandler::open($savePath, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice.

Return type of Minphp\Session\Handlers\PdoHandler::open($savePath, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice on line 65 in 
...../blesta/vendors/minphp/session/src/Handlers/PdoHandler.php
UnknownException::setErrorHandler
Line 232
...../blesta/vendors/monolog/monolog/src/Monolog/ErrorHandler.php

Monolog\ErrorHandler->handleError
Line 10

 

Link to comment
Share on other sites

  • John Heenan changed the title to PHP debug in Blesta 5.6.0 is unusable due to session bug

This problem was originally reported for Blesta beta version 5.6.0-b2. Blesta 5.6.0 has now been released. I upgraded to 5.6.0 as per recommended for a new release (overwrite all files).

The problem and reporting remain the same. PHP debug is unusable because Minphp reports a type error. I assume this is due to tightening up with PHP 8.

Hence I have edited the topic and contents to remove the '-b2' beta suffix.

 

 

Link to comment
Share on other sites

I have found a global fix for this bug. The fix implies Blesta 5.6.0, when used with PHP 8.1, is using deprecated code. This is not surprising and is considered normal for large projects. There is no urgency about fixing this.

Here is the fix that enables PHP debug to be used with Blesta 5.6.0 and PHP 8.1

edit config/blesta.php and use 

Configure::errorReporting(E_ALL & ~E_DEPRECATED); 

instead of the current recomendation of

Configure::errorReporting(-1);

Note the spelling of E_DEPRECATED is correct

Link to comment
Share on other sites

  • John Heenan changed the title to Fix for unusable PHP debug in Blesta 5.6.0 with PHP 8.1

Below is in a php.ini file for my server that I dd not alter. 

; Default Value: E_ALL                                                                 
; Development Value: E_ALL                                                             
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT                                  
; https://php.net/error-reporting                                                      │
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT     

What it means is that if you want to use the last configured error_reporting php.ini value then you need to comment out the following lines in conf/blesta.php

Configure::errorReporting(0);

E_ALL is equivalent to -1

Link to comment
Share on other sites

Some more information about error reporting with Blesta. This clears up confusion for me.

  • Errors are reported to screen, even with display_errors set to off, as errors are trapped by file app/views/errors/error.pdt
  • The boolean internal variable System.Debug decides whether error.pdt includes a stack trace or not
  • To make sure no errors are visible error_reporting must be set to 0, such as by using Configure::errorReporting(0);
  • Errrors are also logged to various files in logs_blesta directory

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 7 months later...
On 12/23/2022 at 4:31 AM, johnhe said:

I have found a global fix for this bug. The fix implies Blesta 5.6.0, when used with PHP 8.1, is using deprecated code. This is not surprising and is considered normal for large projects. There is no urgency about fixing this.

Here is the fix that enables PHP debug to be used with Blesta 5.6.0 and PHP 8.1

edit config/blesta.php and use 

Configure::errorReporting(E_ALL & ~E_DEPRECATED); 

instead of the current recomendation of

Configure::errorReporting(-1);

Note the spelling of E_DEPRECATED is correct

you save me ❤️

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...