Tried everything and couldn't disable bugs in CakePHP

I've tried everything I can think of to prevent errors from rendering in CakePHP. I checked out the CakePHP manual and searched the internet and stackoverflow for phrases such as "disable error reporting in CakePHP" and "disable debug mode in CakePHP". Here's a description of the errors that are still showing and what I've tried to hide these errors in CakePHP:

Errors I still get

  • Error: I have deliberately declared a variable incorrectly in one of my controller classes to check if errors are displayed and received "Parse error: syntax error, unexpected T_VARIABLE awaiting T_FUNCTION in (file paths and line number)"

  • Error two: I tried to type a bunch of gibberish in the URL how to check if the error is displayed. I am getting "Missing Controller" from Cake.

Things I've tried to stop display errors

  • Configure :: write ('debug', 0); (edited to zero) in \ app \ Core.php

  • error_reporting (0); (line added) to \ app \ Config \ bootstrap.php

  • Customize :: write has a level key in the array at \ app \ Core.php, so I changed it from "E_ALL and E_DEPRECATED" to 0. Then I tried to disable it.

  • Added php.ini file to public_html containing a whole bunch of commands to disable errors. I also deleted this file to make sure it still didn't get in the way.

  • The commented out ___ construct () sections in \ lib \ Cake \ Utility \ Debugger.php (these are the removed error messages from the page title tags that appear when the pill is typed into the url, but not the absence of a controller error). By the way, error messages were put in HTML headers. This is strange.

  • Commented out echo $ self-> outputError ($ data); at showError in \ lib \ Cake \ Utility \ Debugger.php

  • Double check the manually Deploy page where I referenced the Debug page. This page discussed the "Configure :: debug" setting, which is written slightly differently than "Configure :: write ('debug', 0); so I tried the options.

  • I searched all the directories containing php for the phrases "error_reporting (" and "ini_set (") to ensure that I didn't include errors somewhere and forgot.

If anyone knows why they are still showing despite everything I've tried or what can be done to turn them off, I'd really appreciate it.

Thank.

+3


source to share


2 answers


I tried Mark's suggestion which worked. When I searched my entire Cake install for "Configure :: write (" debug ") I found many lines to debug, although most of them were in the source files downloaded from the CakePHP official site. As an experiment, I made a copy of my install Cake changed all the instances that set debug to above 0. Then, assuming some of them should be there, and not sure which ones should be there, I decided to completely uninstall CakePHP, download a new copy, and replace her.

After I configured the new core.php, the missing controller error was replaced with a not found error, and the parsing error I intentionally caused for testing purposes was replaced with an internal server error. I'm not sure if showing an internal server error is what it is supposed to do ... but the behavior changed after editing the debug setting and no longer exposes file paths. So, I think it behaves as it should.



I would like to give Mark credit for helping me with this issue, but he only posted a comment.

+2


source


I think there are several options for u:

  • Customize your mistakes

    here you go app / Config / core.php

    Configure::write('Error', array( 'handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, 'trace' => true ));

    When configuring error handlers, you have 5 built-in options:

handler - callback - callback to handle errors. You can set this to any callable type, including anonymous functions.

level - int - level of errors that you are interested in capturing. Use php's built-in error constants and bitmasks to choose the error level you are interested in.

trace - boolean - enable stack traces for errors in log files. The stack trace will be included in the log after every error. This is useful for finding where / when errors occur.

consoleHandler - Callback - A callback used to handle startup errors in the console. If undefined, CakePHPs default handlers are used.

  • create an error handler as your own

    // in app / Config / core.php

    Configure::write('Error.handler', 'AppError::handleError');



// in app / Config / bootstrap.php

`App::uses('AppError', 'Lib');`

      

// in the application /Lib/AppError.php

class AppError { public static function handleError($code, $description, $file = null, $line = null, $context = null) { echo 'There has been an error!'; } }

This class / method will print "An error occurred! Every time an error occurs. Since you can define an error handler to be any type of callback, you can use an anonymous function if you are using PHP5.3 or higher .:

Configure::write('Error.handler', function($code, $description, $file = null, $line = null, $context = null) {
    echo 'Oh no something bad happened';
});

      

also you can see here for more help

+1


source







All Articles