Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error_reporting level cannot be changed in the fpm image #1557

Open
przemub opened this issue Dec 16, 2024 · 4 comments
Open

error_reporting level cannot be changed in the fpm image #1557

przemub opened this issue Dec 16, 2024 · 4 comments

Comments

@przemub
Copy link

przemub commented Dec 16, 2024

Hi,

I'm very happily using [email protected] image for hosting a Wordpress website.

An issue is my logs are polluted with E_NOTICE messages that I'd like to turn off. This is what they look like:

root-1  | NOTICE: PHP message: All-in-One Event Calendar: Twig_Parser::addImportedSymbol(): Implicitly marking parameter $node as nullable is deprecated, the explicit nullable type must be used instead @ /root/wp-content/plugins/all-in-one-event-calendar/vendor/twig/Parser.php:289 #8192
root-1  | NOTICE: PHP message: All-in-One Event Calendar: Using ${var} in strings is deprecated, use {$var} instead @ /root/wp-content/plugins/all-in-one-event-calendar/vendor/lessphp/lessc.inc.php:1215 #8192
root-1  | NOTICE: PHP message: All-in-One Event Calendar: Using ${var} in strings is deprecated, use {$var} instead @ /root/wp-content/plugins/all-in-one-event-calendar/vendor/lessphp/lessc.inc.php:1560 #8192
root-1  | NOTICE: PHP message: PHP Warning:  Cannot modify header information - headers already sent in /root/wp-content/plugins/membership/app/controller/class-ms-controller-plugin.php on line 99

I made a child image with a Dockerfile like this:

FROM php:8-fpm

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
    install-php-extensions gd mysqli pdo pdo_mysql

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN echo "cgi.fix_pathinfo=0;" >> $PHP_INI_DIR/conf.d/szkolaszermierki.conf
RUN sed -i 's/^error_reporting = .*$/error_reporting = E_ALL \& ~E_NOTICE \& ~E_DEPRECATED \& ~E_STRICT/' "$PHP_INI_DIR/php.ini"

error_reporting seems to be correctly set as phpinfo() outputs error_reporting = 22519, which is equal to E_ALL \& ~E_NOTICE \& ~E_DEPRECATED \& ~E_STRICT when checked in the shell. Nevertheless I still get the messages. Any idea why?

PHP version is 8.4.1, host is Ubuntu 22.04, Docker engine is 27.4.0.

@przemub przemub changed the title I cannot seem to turn off E_NOTICE logging E_NOTICE logging cannot be turned off in the fpm image Dec 16, 2024
@LaurentGoderre
Copy link
Member

Looks like these notices are not E_NOTICE but rather warning and user_deprecated

@przemub
Copy link
Author

przemub commented Dec 16, 2024

Hi @LaurentGoderre, thanks for the suggestion!

I tried turning off everything with error_reporting = 0 but interestingly, it changed nothing as well. I noticed that all messages are logged with NOTICE: as well:

[16-Dec-2024 20:17:29] NOTICE: fpm is running, pid 1
[16-Dec-2024 20:17:29] NOTICE: ready to handle connections
NOTICE: PHP message: All-in-One Event Calendar: Ai1ec_Loader::_cache(): Implicitly marking parameter $entries as nullable is deprecated, the explicit nullable type must be used instead @ /root/wp-content/plugins/all-in-one-event-calendar/lib/bootstrap/loader.php:123 #8192

I suppose error_reporting is overridden by something somewhere? I checked php-fpm config files but I found nothing interesting there.

@przemub przemub changed the title E_NOTICE logging cannot be turned off in the fpm image error_reporting level cannot be changed in the fpm image Dec 16, 2024
@przemub
Copy link
Author

przemub commented Dec 16, 2024

I raised log_level to error in /usr/local/etc/php-fpm.conf while keeping error_reporting at 0. Deprecation PHP messages remained but without NOTICE prefix.

@tianon
Copy link
Member

tianon commented Jan 6, 2025

WordPress does modify error_reporting at runtime, but I'm not sure if any of it is related:

https://github.com/search?q=repo%3AWordPress%2FWordPress%20error_reporting&type=code

(perhaps that plugin / some other plugin does also?)

That being said, this isn't really an issue with the PHP image we maintain. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants