[Bedrock] Can't disable PHP notices/warnings

Although I set everything to false/0 in the development.php,
the PHP notices and warnings are still shown, preventing the proper use of the site.
How can I disable it for latest Bedrock?

Example notice:

ErrorException: Undefined index: default_attributes_xpath in file /srv/www/web/app/plugins/woocommerce-xml-csv-product-import/views/admin/import/product/_tabs/_variations.php on line 855

Although the script execution doesn’t stop at that point,
the page is rendered unusable by the unexpected markup.

Edit: ErrorException is handled by Illuminate\Bootstrap\HandleExceptions:

Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()

The underlying issue is apparently in the Illuminate/Foundation package in the exceptions handler
(vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:68).

    /**
     * Convert PHP errors to ErrorException instances.
     *
     * @param  int  $level
     * @param  string  $message
     * @param  string  $file
     * @param  int  $line
     * @param  array  $context
     * @return void
     *
     * @throws \ErrorException
     */
    public function handleError($level, $message, $file = '', $line = 0, $context = [])
    {
        if (error_reporting() & $level) {
            throw new ErrorException($message, 0, $level, $file, $line);
        }
    }

The bitwise comparison error_reporting() & $level doesn’t work with -1 for error_reporting() in order to disable all PHP errors, warnings and notices.
For example, E_NOTICE got value 8 and -1 & 8 results in true.

I also noticed that the illuminate/foundation package used by acorn is abandoned and its GitHub repository removed:

This package is abandoned and no longer maintained. No replacement package was suggested.

Edit: error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE); doesn’t work either.

1 Like

Are you saying you’re passing -1 with the intent to disable all error reporting? The PHP docs for error_reporting() indicate the a value of -1 enables all error reporting.

Hm you are right. But with error_reporting(0) there is no difference.

Related issue:

This topic was automatically closed after 42 days. New replies are no longer allowed.