In #291026: change E_NOTICE to warning and allow selection of error level, webchick requested that this be made a new issue.

As it happens, Drupal 7 includes a rather unfortunate change, that forces PHPs error_reporting setting to E_ALL or higher, overriding the system configuration.

This incurs a significant performance overhead for error handling whenever a notice occurs, as well as a lot of useless noise in Drupal's watchdog log (and even on screen if error logging to screen has not been disabled), and given that these are mostly coding style issues and not indicative of any real problem.

Drupal should not change system configuration unnecessarily in ways that requires hacking core to undo. This is probably a well-intentioned attempt at getting developers to fix notices in their own modules. However, this is the wrong approach. System settings are not for user-space applications to thumb their nose at, and as a system administrator, I was appalled to learn that Drupal thinks it knows better how to configure my server.

If anything, we could introduce error_reporting as one of the settings in default.settings.php, but for now, the attached patch removes the line in question from bootstrap.inc.

Issue fork drupal-1267246

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikl’s picture

Status: Active » Needs review

This should be mergeable as is…

NikLP’s picture

Sub (I need to know more about this stuff in any case)

DamienMcKenna’s picture

Subscribe.

droplet’s picture

I was started a similar issue #1138464: Error reporting slow down drupal

Michael-IDA’s picture

Would someone please commit this !

this is the wrong approach. System settings are not for user-space applications to thumb their nose at, and as a system administrator, I was appalled to learn that Drupal thinks it knows better how to configure my server.

Goes double for me.

f-ing annoying as hell to not be able to change this in the proper place,

orendain’s picture

Has this not yet been committed? It's a pain having to go in and fix this (let alone remember to) manually every time.

Michael-IDA’s picture

Status: Needs review » Reviewed & tested by the community

edeloa,

Maybe we're not using the issue queue correctly?

Changed status to tested and reviewed.

xjm’s picture

Hmmm, I think it would be preferable to add it to default.settings.php. Removing the forced setting might be appropriate, though; let's see if I can find the original issue where this was added...
Edit: See #348448: Always report E_STRICT errors. We'd be reverting that issue, so would need to justify that, or at a minimum bump the error reporting during simpletest execution.

xjm’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs backport to D7

Also, this should go into D8 first. Thanks!

nd987’s picture

For those looking for a quick fix to this, just add ini_set('error_reporting', E_ERROR); to the top of one of your module files. No hacking core required.

Michael-IDA’s picture

Hi Jess,

I can't believe that the original intent is to force, against a user's will and server settings, anything. Much less something that near cripples a large module site.

Should we re-open #348448: Always report E_STRICT errors as a bugged resolution to that problem?

Best,

PS: Thanks Nick, that's a bit easier, safer, and more permanent.

RoloDMonkey’s picture

For those of you who are trying to override this without hacking core, or other versioned code, I think I have found a solution. Just add a line like this to settings.php:


error_reporting(E_ALL & ~E_NOTICE);

If I am reading the code correctly, the settings.php file is included after the call to error_reporting() in bootstrap.php. I have tried this on one of my sites and it seems to be working.

Of course, you can set the actual error reporting value to whatever you need for your server.

Damien Tournoud’s picture

Can someone explain in precisely which cases it makes sense to hide errors under the carpet?

Michael-IDA’s picture

When said errors are known to be useless and are causing performance problems.

stockliasteroid’s picture

The issue is that this is a configuration setting that's being made in a non-configurable location (i.e. core). It doesn't matter what it is, it simply shouldn't be hard-coded. There's already a number of ini_set calls that are in settings.php, if it's the strongly held opinion of core maintainers that E_ALL be the default, then that should be put into the default settings.php just like any other php.ini override. At least then people know where to look for it, and expect Drupal to override any previously defined settings in .htaccess or php.ini. In my case I had to grep core to figure out what was going on, which led me to this issue.

So no, it's not about "hiding errors under the carpet", it's about overriding ANY php settings in a non-obvious way. This is configuration, and should be handled in the same way as any other configuration.

stockliasteroid’s picture

Issue summary: View changes

Added “unnecessarily”/

lica.dunca’s picture

Issue summary: View changes

Subscribe.
I was unable to remove E_DEPRECATED error messages because ((E_ALL & ~E_DEPRECATED) | E_ALL) == E_ALL,

mgifford’s picture

Version: 8.0.x-dev » 7.x-dev

I'm moving this back to D7 as it no longer seems to be done this way in D8.

eporama’s picture

Version: 7.x-dev » 8.0.x-dev

resetting to 8.0.x-dev as it actually does still happen.

Now we are setting it in core/lib/Drupal/Core/DrupalKernel.php

    // Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
    error_reporting(E_STRICT | E_ALL);

Since we are now requiring php-5.5.9+ and E_STRICT has been part of E_ALL since 5.4.0

turns out that error_reporting(E_STRICT | E_ALL); is exactly the same as error_reporting(E_ALL); in php-5.4.0+

We should simply remove this and allow folks to set error_reporting in php.ini when they can. Setting it in settings.php will still work for those who do not have access to their php.ini files.

JamesOakley’s picture

Setting it in settings.php will still work for those who do not have access to their php.ini files

Is it worth, then, including

# error_reporting(E_ALL)

in default.settings.php (commented out) so that people can quickly find it, and help them get the syntax correct?

eporama’s picture

I worry that there are a number of php ini settings that we could have commented in settings.php to teach people about good php settings, but it's a slippery slope to determine which ones are worth calling out specifically.

I think we could definitely add it to settings.php but would prefer the PHP default as the starting point which is actually:

PHP 5.3 or later, the default value is E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED. This setting does not show E_NOTICE, E_STRICT and E_DEPRECATED level errors.

http://php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

E_ALL seems like quite a bit of verbosity for the default.

eporama’s picture

Status: Needs work » Needs review
FileSize
729 bytes

Adding a patch to remove these.

JamesOakley’s picture

+1

The point in including this here would not be to teach people good PHP settings. (And, I quite agree, that E_ALL is not a good setting - in fact, the reason I'm following this issue is because I have started patching every D7 installation I manage to remove that line from the bootstrap, because I don't want every Drush call filling up my PHP error log).

Rather, the issue here is that this would be a change of behaviour. We'd simply be showing people how to get their site to behave how previous newly configured Drupal sites used to behave.

Michael-IDA’s picture

+1 (sorta)

Like James (JamesOakley) I've been following this for years as it's a pita.

And like Erik (eporama) I would like to see a proper instructional version of this "commented in settings.php to teach people about good php settings."

# # #

Erik, would you mind adding a corresponding comment patch for settings.php? If it's not done now, I'm pretty sure it'll never get done. :(

Best All,
Michael

"but it's a slippery slope to determine which ones are worth calling out specifically."

Not really the point of this particular Issue, but it'd be nice if there were an entire dedicated section, either inside settings.php or in its own settings companion file, for just these types of informational 'real world' good php settings. (Yes there are a bunch already there, but it seems haphazardly scattered throughout, intermixed with must have settings like $databases and default turned on things like 404_fast_paths)

JamesOakley’s picture

What made this issue higher priority for me is the (imminent) introduction of PHP 7 (See https://www.drupal.org/node/2454439) which moves a whole load of new pieces of syntax into deprecated / warning status. The most common one is the planned change that PHP classes will not automatically interpret as a constructor any method whose name matches its class. Lots of modules seem to trigger that warning ... but I don't want an error log full of those. It took a lot of debugging to realise, finally, that the changes I was making to php.ini was having no effect because Drupal stamps on my virtual host / server settings.

But that's just an aside. Technically, I think I've already expressed my view on this.

eporama’s picture

I have written a small section for default.settings.php (including here just for easier reading/commenting)

/**
 * During development, it is recommended to increase the level of PHP's error
 * reporting. Drupal will respect the value for error_reporting set by the
 * php.ini configuration or by overrides in the webserver configuration or
 * .htaccess. To enable the maximum verbosity in PHP logging, uncomment the
 * line below.
 *
 * Note: This setting can cause a performance impact if set too verbose.
 * See https://www.drupal.org/node/1267246 for more information.
 */
# ini_set('error_reporting', E_ALL);
Michael-IDA’s picture

Visual inspection only: +1

No D8 to patch on :(

Thank you Erik for adding the info section, perfect blend of easy instructions in settings with a details link for the whole issue.

Best,
Michael

eporama’s picture

Well, now that I look for it, we do have a handbook page for "PHP Configuration Settings". This would be more appropriate place than linking to a bug/issue. We would need to change this part:

error_reporting set to E_ALL & ~E_NOTICE. Work is ongoing to change this to E_ALL for Drupal 6 and Drupal 7.

As a) E_ALL is not ongoing work, but already done and b) we're trying to undo that work ;-).

However, we can't change that page unless we actually commit this patch, so we should discuss what the wording should be. The line above is from a section of "PHP needs the following configuration directives for Drupal to work" which is patently false for the "error_reporting" value, I'm not sure why it was deemed necessary.

In the next section "Recommended PHP configuration settings", I would suggest we use a variation on the small section I had put in for inclusion in the default.settings.php:

Error Reporting

During development, it is recommended to increase the level of PHP's error reporting. The default value of "E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED" does not show E_NOTICE, E_STRICT and E_DEPRECATED level errors. However, this can cause a performance impact if set too verbose.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

marvil07’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +Performance, +Regression

The reasoning makes sense.

About testing environment, I guess it is not necessary to have it set from drupal core, i.e. testbots instructions should mention to configure php with E_ALL, and that should be enough.

The patch here needs a re-roll, hence marking as NW.

BTW not sure the right component here is "base system" or "bootstrap system".

eporama’s picture

Status: Needs work » Needs review
FileSize
1.67 KB

Applying a new patch that is a reroll. Only the line numbers really changed, so no interdiff for that.

mikl’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, still looks good.

anish.a’s picture

Issue tags: -Needs reroll
catch’s picture

Title: Performance regression: Drupal overriding error_reporting setting in php.ini » Drupal overriding error_reporting setting in php.ini
Version: 8.2.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: -Performance, -Regression

The patch should not link back to this issue, it should link to a documentation page on Drupal.org

I don't think we should change this in a patch release, so moving to 8.3.x

Agreed with making this configurable, but the default for both new sites and if possible existing sites should remain the same as now.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Michael-IDA’s picture

Catch,

Can we at least get D7 patched? Do what you want with 8, but 6 years man....

DamienMcKenna’s picture

@Michael-IDA: D8 has to be fixed first, then the change can be backported.

DamienMcKenna’s picture

@catch: I don't know how existing sites could be handled besides a note in the changelog and maybe a change notice?

droplet’s picture

I cannot find the docs. But I think that's no more "Do in D8 first and then backported". Now, we can create a separate issue for D7.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

millenniumtree’s picture

How in holy heck is this not done yet?
I just woke up to a 14GB syslog!
I'll be handling it module-side, but seriously, this is creating over 50GB of disk writes every day from notices alone, on just 10 sites.
Don't override my php.ini!!

mikl’s picture

Issue tags: +held up by bureaucracy

#42: As long as the ticket is marked as “Needs work”, nothing will happen. And since catch has laid down the law, someone will have to spend their time writing further documentation of this change before it will be merged.

marvil07’s picture

Status: Needs work » Needs review
FileSize
1.62 KB
1.18 KB

I have already forgotten about this!

I agree that this is definitely useful in development, but not sure if we want that by default.
In any case, having the ability to modify the setting is at least a first step, so I went ahead with the suggestions at #34, and instead of reverting current behavior, I am keeping it.

I could not find a d8 equivalent of Required PHP configuration settings section on Drupal 7 PHP requirements, but I found a php configuration section on Drupal 8 PHP requirements.

We can always change that documentation page, so I linked https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requireme... on the patch.

millenniumtree’s picture

One simple solution would be to create a new checkbox on the performance tab.
Check the box to use the php.ini value, uncheck to override (default config).
Existing functionality untouched, easily configurable.
I've been modifying the php.ini value for YEARS, not realizing it did nothing in 7 and 8.

We just launched a new suite of sites that are very ajax-heavy, and suddenly my syslog and messages are 14GB/day each.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

neclimdul’s picture

Version: 9.5.x-dev » 10.0.x-dev
FileSize
2.35 KB
1.45 KB

Don't think it matters but this was broken by #3151118: Include bootstrap.inc using composer so here's a reroll.

I think this is worth resurfacing because best I can tell it blocks disabling deprecation logging in a production environment. At a minimum its a weird WTF that your PHP configuration for error logging doesn't actually affect your error logging.

Blocking controlling deprecation logging in production can be problematic in 8.1 since deprecation messages can be brutal with the null string deprecation popping up out of the blue. I recently had a scan find a deprecation in a vendor library which would have been great if it hadn't found it by triggering 10G of logs since this bypassed my ini setting. Also,we're on track to have some serious deprecation message spam in 8.2 with the dynamic property deprecation.

Reroll updates the documentation link and format. Also copies changes to scaffold. See the interdiff.

mxr576’s picture

#54 +1

I have started some new tests on patch #54. Fingers crossed...

Status: Needs review » Needs work

The last submitted patch, 54: 1267246-54.patch, failed testing. View results

mxr576’s picture

Status: Needs work » Needs review

Test passed, back to needs review

longwave’s picture

Version: 10.0.x-dev » 10.1.x-dev

As noted in #54 I've run into this issue as I wanted to disable PHP 8.1 deprecation notices in production.

Do we have to consider backward compatibility here? I think this is too late for 10.0.0, but is this OK to change in 10.1.0 as long as we document it in the release notes? Or should we add some kind of BC notice inside DrupalKernel::bootEnvironment() if the error level is not set sufficiently high?

andypost’s picture

As a bug it perfectly backportable, more interesting effect happens when error_reporting is added to disabled functions

longwave’s picture

@andypost I consider this disruptive if it requires site owners to add something to settings.php, we can only do that in a major/minor and not a patch release. If we can figure out how to do this without requiring it in settings.php yet, then perhaps it can be backported.

mxr576’s picture

Settings are initialized after bootEnvironment() is called

  public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = TRUE, $app_root = NULL) {
    $kernel = new static($environment, $class_loader, $allow_dumping, $app_root);
    static::bootEnvironment($app_root);
    $kernel->initializeSettings($request);
    return $kernel;
  }

(just thinking aloud) but how about creating a file in project root via an update hook that MUST BE committed to VCS. By using that file bootEnvironment() could enable a BC mode and if developers want the "latest" behavior they just need to remove it. Reading the file content at this stage of the request should have the same cost (or even less) than fetching a setting from Settings.

longwave’s picture

@mxr576 while that might work it's probably more effort for both core developers and end users, than documenting a change in settings.php that (likely) won't affect most people anyway.

The worst case scenario I can see is that someone's php.ini error_reporting level is set to something much lower than E_ALL, which means that if we just remove the code from the kernel and they don't update settings.php, they will see less errors than they did before. This isn't actually disruptive to end users, and while it may be disruptive to developers, we can document it in the release notes and all they have to do is change their php.ini or add a line to settings.php?

One other option is add a warning to the status report if error_reporting is not set to E_ALL?

mxr576’s picture

One other option is to add a warning to the status report if error_reporting is not set to E_ALL?

And an update hook could also warn meanwhile deployment if the current error_reporting settings is lower than E_ALL...

neclimdul’s picture

I'm not really concerned about when it happens if we can move it forward because its quite frustrating. Is there anything blocking this from going into 10.1 and then we can discuss backporting?

As far as being disruptive, it feels a little weird to consider loosening the requirements around error_reporting disruptive but I guess maybe like you said there is an argument a CI pipeline that expects specific error reporting. Sounds like a fragile pipeline but an easy mistake to make I guess.

One other option is to add a warning to the status report if error_reporting is not set to E_ALL?

Core doing this sounds like a bad idea because we'd incorrectly warn people in production environments that honestly should _not_ be running E_ALL. Sounds like a devel.module feature?

solideogloria’s picture

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs change record

Change like this seems like it would 100% need a change record maybe even release notes?

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.