docker-library / php

Docker Official Image packaging for PHP
https://php.net
MIT License
3.84k stars 2.01k forks source link

Interpreter does not resolve builtin functions when provide nonexistente file to opcache.preload option #1501

Open tsantos84 opened 8 months ago

tsantos84 commented 8 months ago

The problem

I'm using https://github.com/dunglas/symfony-docker to setup a new Symfony project. When I provide a wrong filename to opcache.preload option, the PHP interpreter does not found builtin function like dirname(). This problem happens only on production environment.

I've tried to reproduce with minimum complexity layer in this stack but I could found the problem, so you need to follow the following steps to reproduce the isse.

The step 3 is the offender.

Steps to reproduce

  1. Install a fresh Symfony app following the dunglas/symfony-docker instructions and run the app on dev environment
  2. Stop the app with docker compose down
  3. Change the file frankenphp/conf.d/app.prod.ini and provide a nonexistent file to opcache.preload (eg. /foo/bar.php)
  4. Rebuild the image to prod env: docker compose -f compose.yaml -f compose.prod.yaml build --no-cache
  5. Provide JWT keys on compose.prod.yaml
  6. Run the app for production: docker compose -f compose.yaml -f compose.prod.yaml up -d
  7. After that you will see the following log on app's container:
{"level":"error","ts":1709164144.1067986,"msg":"PHP Fatal error:  Uncaught Error: Call to undefined function dirname() in /app/public/index.php:5\nStack trace:\n#0 {main}\n  thrown in /app/public/index.php on line 5","syslog_level":"err"}

Related issue

https://github.com/dunglas/symfony-docker/issues/578

tianon commented 8 months ago

This is probably true for any install of PHP, right? I don't think we change anything in our packaging / Docker image that might cause this behavior.