Skip to content

[Dependency-Injection] Preloading file is not generated #34750

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

Closed
Plopix opened this issue Dec 1, 2019 · 5 comments
Closed

[Dependency-Injection] Preloading file is not generated #34750

Plopix opened this issue Dec 1, 2019 · 5 comments

Comments

@Plopix
Copy link
Contributor

Plopix commented Dec 1, 2019

Symfony version(s) affected: 4.4.x and 5.x

The issue was detected on Platform.sh using PHP 7.4 trying to enable the Preloading support.

Description

On Platform.sh the file var/cache/prod/srcApp_KernelProdContainer.preload.php is NOT generated when it is working locally.

How to reproduce

Just deploy an empty app on Platform.sh.
OR (and the following explanation will explain why)

  • Install Symfony locally in your root directory /
  • run bin/console
  • check the cache directory,
  • you will see that the preload file is NOT generated

Reasons

This is happening for 3 combined reasons:

The return of getAutoloadFile is always null is this context.
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L306
And that is even explained in the code:

// Build a regexp where the first root dirs are mandatory,
// but every other sub-dir is optional up to the full path in $dir
// Mandate at least 2 root dirs and not more that 5 optional dirs.

Traces that explain the bug better
preg_match: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L2055

When it works:

string(54) "ComposerAutoloaderInit7a88e581ff3256a1c9451ad0a87173b8"
string(65) "/Users/plopix/DOCKFILES/NOVACTIVE/INTERNAL/XXX/application/vendor"
string(78) "/Users/plopix/DOCKFILES/NOVACTIVE/INTERNAL/XXX/application/vendor/autoload.php"
string(90) "#/Users/plopix/DOCKFILES/NOVACTIVE/INTERNAL(/XXX(/application(/var(/cache(/dev)?)?)?)?)?#A"

here the preg_match works

When it DOES NOT work (on Platform.sh):

string(54) "ComposerAutoloaderInitb7e173ef0544858adc8ec39ee3ef34c1"
string(11) "/app/vendor"
string(24) "/app/vendor/autoload.php"
string(28) "#/app/var(/cache(/pro_)?)?#A"

here the preg_match DOES NOT work

Solutions
That is a bit deep in the stack and I don't know enough to propose something. But if you tell me I could do it ;)

ping @nicolas-grekas

@Plopix Plopix changed the title Preloading file is not generated [Dependency-Injection] Preloading file is not generated Dec 1, 2019
@fabpot fabpot closed this as completed Dec 2, 2019
fabpot added a commit that referenced this issue Dec 2, 2019
…p is in /app (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Fix making the container path-independent when the app is in /app

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #34750, Fix #34611
| License       | MIT
| Doc PR        | -

Right now, we mandate the app to be nested in a directory of level 2 minimum. This means apps cannot be made path-independent if they are built in e.g. `/app`.

Commits
-------

b33b9a6 [DI] Fix making the container path-independent when the app is in /app
@Plopix
Copy link
Contributor Author

Plopix commented Dec 2, 2019

so fast! thx ;)

@khs1994
Copy link

khs1994 commented Dec 18, 2019

How to solve? @Plopix

@stof
Copy link
Member

stof commented Dec 18, 2019

@khs1994 either wait for the next patch release at the end of the month, or use the dev version.

But anyway, given that PHP 7.4.0 is itself broken for preloading, waiting is a sane option, unless you also compile a dev version of PHP.

@khs1994
Copy link

khs1994 commented Dec 18, 2019

PHP 7.4.1 Fixed?

@stof
Copy link
Member

stof commented Dec 18, 2019

Well, PHP 7.4.1 is expected to fix the seg faults which happen in 7.4.0 when using the preload file generated by Symfony. And Symfony 4.4.1 and 5.0.1 will include a fix for the case where this file was not generated when running on platform.sh and some other hosting.

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

No branches or pull requests

6 participants