Welcome Guest, Not a member yet? Register   Sign In
Error view exception is not showing the source code in PHP8.3 - Codeigniter v4.4.4
#1

I have problem here, when I run PHP 8.3 the error view like this :
[Image: Screenshot-3.jpg]





File : vendor\codeigniter4\framework\system\Debug\BaseExceptionHandler.php
Line : 185

PHP Code:
if ( version_compare(PHP_VERSION'8.3.0''<') ) {
  $source str_replace('<br />'"\n"$source[1]);
  $source explode("\n"str_replace("\r\n""\n"$source));


I update the code like that and works to PHP 7 or  PHP 8.3.
So, why like that ?
Reply
#2

Probably a bug. Same error here. And also it displays this error page only when I set display_errors to 1, not in development.php but interestingly in production.php under app/Config/Boot/. Otherwise I get the Whoops! page. I can't see the error page (even though my .env is set to development).

Additionally,  in the error page it detects the environment as production, not development.
Reply
#3

(This post was last modified: 01-05-2024, 02:10 AM by davis.lasis.)

Same here.
CodeIgniter 4.4.4
PHP 8.3.1

ErrorException has empty <pre><code></code></pre>

Although i have no issues with dev or prod mode.

[Image: fnPD6Kp]

Not sure whats about attaching images, bet there is direct link
https://ibb.co/fnPD6Kp

So, i did some tests and debugging.
I found out that empty code appears in PHP 8.1 as well.
Maybe something related to apache, as yesterday i changed my Laragon setup 
- apache - http-2.4.54 to http-2.5.8
- php - 8.1 to 8.3.1

Quick system fix is to disable 2 lines
/system/Debug/BaseExceptionHandler.php
line 185 //$source = str_replace('<br />', "\n", $source[1]);
line 186 //$source = explode("\n", $source);

With those commented out errors shows as intended
I havent dig entirely through, and because of lack of time, i am not ready to provide pull request or a proper fix at this moment
[Image: j4ybfBm]

https://ibb.co/j4ybfBm
Reply
#4

yes, line 185 and 186. I disabled it before, but when I back to PHP 7 or 8.1 it become empty again because PHP versions lower than 8.3.0 require those two lines of code.
So, I check the PHP version first before I disable that lines, like this :
PHP Code:
if ( version_compare(PHP_VERSION'8.3.0''<') ) {
  $source str_replace('<br />'"\n"$source[1]);
  $source explode("\n"str_replace("\r\n""\n"$source));


Aafter I change the code in BaseExceptionHandler.php and I update codeigniter using composer it will be back to original again.
Reply
#5

This bug has been fixed in develop branch.
https://github.com/codeigniter4/CodeIgniter4/pull/8401

And will be fixed in v4.4.5.
Reply
#6
Heart 

(01-07-2024, 07:40 PM)kenjis Wrote: This bug has been fixed in develop branch.
https://github.com/codeigniter4/CodeIgniter4/pull/8401

And will be fixed in v4.4.5.

Great job. 
so, when can we download version 4.4.5? Smile
Reply
#7

We do not have time-based release. So nobody can't say when.
But you can see the past release dates.
https://github.com/codeigniter4/CodeIgni...ANGELOG.md
Reply




Theme © iAndrew 2016 - Forum software by © MyBB