php icon indicating copy to clipboard operation
php copied to clipboard

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

Open tsantos84 opened this issue 1 year ago • 1 comments

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

tsantos84 avatar Mar 01 '24 15:03 tsantos84

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.

tianon avatar Mar 02 '24 00:03 tianon