Error/Exception handling failure, if using CLI and throw a notice early in bootstrap

Created on 7 December 2015, over 8 years ago
Updated 31 March 2024, 3 months ago

I was stupid, and had a specific notice issue in my sites.php for an array key that does not exists. If I run a CLI based app (in my case Drupal console) then I get the following

Error: Cannot use object of type Drupal\Console\Config as array in /app/project/repository/web/core/includes/errors.inc on line 319
Error: Cannot use object of type Drupal\Console\Config as array in _drupal_get_error_level() (line 319 of /app/project/repository/web/core/includes/errors.inc).

That line contains:

    $error_level = isset($GLOBALS['config']['system.logging']['error_level']) ? $GLOBALS['config']['system.logging']['error_level'] : ERROR_REPORTING_HIDE;

In my case, the Config object exists (is not an array) but the error has occured before container initialization (I think) so I get the above error.

If that error_level line is a bit more picky:

$error_level = (is_array($GLOBALS['config']) || ($GLOBALS['config'] instanceof ArrayAccess)) && isset($GLOBALS['config']['system.logging']['error_level']) ? $GLOBALS['config']['system.logging']['error_level'] : ERROR_REPORTING_HIDE;

Then I get the proper notice that I've put some garbage into my sites.php.

In my case I had some code that made sense in the FPM case, but not in the CLI case (I was accessing $_SERVER['HTTP_HOST'])

πŸ› Bug report
Status

Closed: works as designed

Version

11.0 πŸ”₯

Component
BootstrapΒ  β†’

Last updated 9 days ago

No maintainer
Created by

πŸ‡¨πŸ‡¦Canada jaxxed

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    This issue is being triaged as part of the daily Bug Smash Initiative triage.

    It has been over 7 years since the original author posted this with no follow up after #3 which sounded like it could be a specific issue with some custom code.

    I'm inclined to close this but will but it in PMNMI for now.

  • Status changed to Closed: works as designed 3 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    It is has another year and there is no discussion or followup to #3. Therefor I am closing this now.

Production build 0.69.0 2024