Why didn't a missing class file throw a PHP error? - php

Sorted out this issue. Problem was the class file (and the folder, actually) was missing. Puzzled why with display_errors = On and E_ALL | E_STRICT defined (and Apache restarted), this would throw a white screen of death and not an error.
phpinfo() shows that the master value and the local value are the same, so I'm assuming that the error settings are not being overwritten somewhere in the code base (in an .htaccess or ini_set() call).
EDIT
The new object instantiation is here:
$type['content_object'] = new $type['handler_class']();
I also tried instantiating it without the variable, i.e. new Foo(); but still gave WSOD.

There might be an alternative error handler activated. Call restore_error_handler() prior to the line with the error (possibly multiple times) to reactivate PHP's default error handler.

Related

Hide PHP errors in ExpressionEngine

I recently switched hosts with a new PHP version. I'm getting an error from a plugin (Calendar) that just won't go away. It's a non-static method error that is causing 0 issues and it can't be fixed without trying a different plugin. I'm at the point where I just need it gone so this ugly message isn't showing on every page and I'll debug it later. I have tried disabling errors, setting every debug setting I can find to 0, but this error message won't go away! It's showing to everyone. What setting am I missing???
I've set the index.php debug=0
I've set the config.php $config['debug'] = 0;
I've added in an extra ini_set for display_errors and error_reporting to 0
I've double checked that the settings in the config file editor and output and debugging pages are showing 0
Why aren't any of these settings working? I'm using EE 2.5.5
What you are looking for is error suppression, you can find more info on it here
Code example
class foo {
public function bar() {
echo 1;
}
}
foo::bar(); // Strict standards: Non-static method foo::bar() should not be called statically
#foo::bar(); // no warning
The # symbol will suppress any error resulting in the fopen.

PHP doesn't display any error

I don't get any PHP error, just get a white page on Firefox, and
Server error
The website encountered an error while retrieving http://example.com/pruebas/prov.php. It may be down for maintenance or configured incorrectly
on Chrome.
This is the code:
if (!ini_get('display_errors')) {
ini_set('display_errors', 1);
}
echo "hola"
echo "hola2";
I intentionally made mistake in the echo "hola" (there's no ';').
I also tried adding to the end of my .htaccess file -> suPHP_ConfigPath /home/username/public_html replacing username with my current username, and then I created a php.ini in public_html with "display_errors = on;". But I'm still not able to get any PHP error.
Your script is dying due to the syntax error before it ever executes, so the ini_set() call is never executed and never takes effect. You'd have to change the setting in the appropriate php.ini.
The actual error message may be in a log file somewhere. Try Apache's error_log, or see if PHP's logging somewhere else.
Make sure that you also have the appropriate error_reporting ini value set as well. You can find more information on PHP.net
Set the error reporting level. The parameter is either an integer representing a bit field, or named constants. The error_reporting levels and constants are described in Predefined Constants, and in php.ini. To set at runtime, use the error_reporting() function. See also the display_errors directive.
In PHP 4 and PHP 5 the default value is E_ALL & ~E_NOTICE. This setting does not show E_NOTICE level errors. You may want to show them during development.
Source
Make sure the display_errors is set to on on your php.ini file.

Can't suppress deprecated warnings in php v5.3

I've seemingly tried about every different suggestion provided through a couple hours of Google and stackoverflow searching to no avail, and I cannot seem to suppress a large sum of "Deprecated: Assigning the return value of new by reference is deprecated in " errors presented at the top of my application, as well as Many "Warning: the magic method __get() (and __set()) must have public visibility and cannot be static in . Thus far, I have added the following line and many different variations of it to my php.ini file:
error_reporting = E_ALL & ~E_DEPRECATED
error_reporting = E_ALL ^ E_DEPRECATED
I've also attempted a straight suppression of every single error:
error_reporting = ~E_ALL
To no avail either. I've confirmed that it is correctly reading the php.ini file by adjusting other settings successfully.
I've also applied the error_reporting() function (with all different variations of what's provided above) within my scripts with no more luck. Does the location of the reporting have anything to do with the suppression? I've tried posting it at the top of the first file being loaded, also at the top of a required file that is getting called immediately upon executing the main script, no where does it seem to take it.
Try it with a number: http://www.php.net/manual/en/errorfunc.constants.php
Everything but the two deprecateds would be 8191.
PS. It's possible the app/framework/website you're watching/editing/creating sets the error reporting level to E_ALL. If so, it doesn't matter what you set in php.ini, because it's overridden later.

E_STRICT messages thrown though not set

Since updating my testing server to PHP 5.3.3 (Debian Squeeze) I encountered strange behaviour regarding the error reporting in PHP.
I set error_reporting like this:
error_reporting(E_ALL);
and checked the setting via
echo error_reporting();
which echoes 30719. According to php.net this means "All errors and warnings, as supported, except of level E_STRICT.".
But in the very next line (a class definition abstract class formInputContainer extends formContainer implements formElementValueable { ... }) this results in the message:
Strict (2048): Declaration of formInputContainer::addElement() should be compatible with that of formContainer::addElement()
Why is the E_STRICT message echoed though it's not set? Even changing to E_ALL & ~E_STRICT does not help.
The reason you're seeing them even though they are not set, is that these are thrown at compile time (well, parse time). That means the errors are triggered before your error_reporting() call is made. The real fix is to change the php.ini setting to remove E_STRICT from the definition. To make sure you're editing the correct file, check phpinfo().
If this is a custom error handler (set via set_error_handler()), you'll have to check the current error_reporting level by yourself. A custom error handler gets all error messages:
The manual says:
It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately.

How to see why a Smarty template fails silently?

I'm using Smarty templates which call object methods. I've put the code on a new server, but it silently doesn't work correctly. The template is being output, but is cut off at a certain point, probably because of an error.
error_reporting is set to E_ALL. Even with $smarty->error_reporting = E_ALL and $smarty->debugging = TRUE, no error is displayed.
How can I see why the template is failing?
Check the PHP error log on your webserver usually stored in /var/log/apache/php.errors on a linux distro.
I'm guessing that the php.ini option for 'display_startup_errors' is off, therefore it fails silently on attempting to load the missing extension without displaying/logging anything.
It does default to off since php 4.0.3, too.

Categories