Welcome Guest, Not a member yet? Register   Sign In
Debug Exception crashing the app
#1

(This post was last modified: 11-03-2021, 02:32 AM by tomasoma.)

Hello,
i have too often issues with the Debug\Exception, and i really wish we could easily turn it off even in development mode on.

this time, in development mode, i have a controller and a view that works fine, and i add comments : like 50 lines of commented mixed php/html code in my view

PHP Code:
<?php /*

[50 lines of mixed html & php code]

*/ 
?>


and then the app crash with this in the log and the Debug\Exception display that goes with

Code:
CRITICAL - 2021-11-03 10:10:23 --> Allowed memory size of 134217728 bytes exhausted (tried to allocate 18788264 bytes)
#0 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
#1 {main}

i comment the CI_ENVIRONMENT = development in the .env file and then it works fine, not even an error in the logs...

This is way too often that the Debug\Exception code crash the app requesting more memory, and not displaying the real error, when there is one.
This time there is not even an error in my code : the app crashs on PHP comments.
Reply
#2

(This post was last modified: 11-03-2021, 06:03 AM by John_Betong.)

Check the error_reporting(); setting in the following file:

./app/Config/Boot/production.php

I don’t know and cannot check on my tablet if CodeIgniter4 redirects the error log file but it should show on phpinfo(); otherwise try the following:

PHP Code:
//Use ini_get to get the error_log directive.
$errorLogLocation ini_get('error_log');

//Print out the location of the error log.
echo 'Your error log is located at: ' $errorLogLocation

The error_log location can easily be modified by using the following:
PHP Code:
$newLog ini_set(‘error_log’“NEW-LOCATION.log’);
// BEWARE:
// $newLog may return a bool FALSE value if the file cannot be written 
Reply
#3

(11-03-2021, 05:50 AM)John_Betong Wrote: Check the error_reporting(); setting in the following file:

./app/Config/Boot/production.php

I don’t know and cannot check on my tablet if  CodeIgniter4 redirects the error log file but it should show on phpinfo(); otherwise try the following:

PHP Code:
//Use ini_get to get the error_log directive.
$errorLogLocation ini_get('error_log');

//Print out the location of the error log.
echo 'Your error log is located at: ' $errorLogLocation

The error_log location can easily be modified by using the following:
PHP Code:
$newLog ini_set(‘error_log’“NEW-LOCATION.log’);
// BEWARE:
// $newLog may return a bool FALSE value if the file cannot be written 

thank you for reply,
I'm sorry but i don't understand why i should make any change in the production config file while everything works fine in production mode ??? ... what i wish to do is to disable the Debug\Exception() thing in the development mode, but from what i've read so far it is not possible for the moment.
Reply
#4

> The toolbar itself is displayed as an After Filter. You can stop it from ever running by removing it from the $globals property of app/Config/Filters.php.
https://codeigniter4.github.io/CodeIgnit...he-toolbar
Reply
#5

(This post was last modified: 11-05-2021, 12:13 AM by John_Betong. Edit Reason: Forgot to mention the php.ini )

Quote:@tomasoma,
what i wish to do is to disable the Debug\Exception() thing in the development mode, but from what i've read so far it is not possible for the moment.

Try this:
// File: ./system/Debug/Exceptions.php
// around line: 81
PHP Code:
public function initialize()
    {
      // MAYBE DISABLE KINT ERROR-HANDLING  
      if(CI_DEBUG) :  
        set_exception_handler
([$this'exceptionHandler']);
        set_error_handler([$this'errorHandler']);
      # else:  
        # PHP ERROR HANDLING
        register_shutdown_function([$this'shutdownHandler']);
      endif;  
    


Edit:
I forgot to mention about my php.ini settings
Code:
error_prepend_string = "
    <pre
        style='
            background-color: RED; color: YELLOW;
            border: dotted 1px RED;
            font-weight: 700;
            width: 88%;
            margin:  0.42em auto;
            padding: 0 0.21em;
            line-height: 1.42em;
            white-space: pre-wrap;
        '
    >"
error_append_string = "</pre>"
Reply




Theme © iAndrew 2016 - Forum software by © MyBB