CodeIgniter Forums
_shutdown_handler() getting called - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: _shutdown_handler() getting called (/thread-69415.html)

_shutdown_handler() getting called - richb201 - 11-18-2017

I am having a problem where _shutdown_handler() in common.php is getting called whenever I start up my program under xdebug. I need to know why? There is a call to error_get_last() at the top of it, but the $last_error is null. 

function _shutdown_handler()
   $last_error = error_get_last();
   if (isset($last_error) &&
       _error_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']);

My current theory is that the reason is that some index (such as in $_POST) is not being initialized, but I can't point to a really good reason. I figure that shutdown_handler is a callback that is being triggered by some event, but what? How can I figure out why shutdown_handler is being called?

thx for your help. 

RE: _shutdown_handler() getting called - richb201 - 11-18-2017

I did some more research and found this post:

I am starting to think that it is an error that is causing this. I figure I have two choices; either to downgrade to php 5.4 from php 5.6.28 OR change the error_reporting level. This second choice seems a little scary to me. I hope to eventually host this thing on Goggle cloud. Do they support older versions of PHP? If not, perhaps I am better modifying the error_reporting level. Where is the proper place in CI to do that mod? Or are their any instructs on downgrading to php 5.4?

additional information:
$message= ini_set(): Use of mbstring.internal_encoding is deprecated
line 252

And here is the code from codeigniter.php that is causing it:

ini_set('default_charset', $charset);

if (extension_loaded('mbstring'))
  define('MB_ENABLED', TRUE);
  // mbstring.internal_encoding is deprecated starting with PHP 5.6
  // and it's usage triggers E_DEPRECATED messages.
  @ini_set('mbstring.internal_encoding', $charset);
  // This is required for mb_convert_encoding() to strip invalid characters.
  // That's utilized by CI_Utf8, but it's also done for consistency with iconv.

I am not sure how I should handle this. I have no idea what mbstring.internal encoding is. Perhaops the Codexworlds login system wasn't meant to be used with php 5.6? There is a comment directly above the problem in codeigniter.php but I don't understand it:

* ------------------------------------------------------
* Important charset-related stuff
* ------------------------------------------------------
* Configure mbstring and/or iconv if they are enabled
* and set MB_ENABLED and ICONV_ENABLED constants, so
* that we don't repeatedly do extension_loaded() or
* function_exists() calls.
* Note: UTF-8 class depends on this. It used to be done
* in it's constructor, but it's _not_ class-specific.

RE: _shutdown_handler() getting called - dave friend - 11-18-2017

_shutdown_handler() is always called as the framework completes running. It is part of the normal execution flow.
Look at line 140 in CodeIgniter.php where PHP is told to use _shutdown_handler().

PHP Code:

Read about register_shutdown_function() HERE.

The shutdown handler will always be called when script execution ends, whether the end is graceful or not.

I don't think error_get_last() will return anything if the problem is an uncaught exception. Got any log or error messages about those?

Severity=8192 means that an E_DEPRECATED error was issued, which is just a warning, not fatal. Execution will continue. That tends to indicate that mbstring.internal_encoding is not the issue.