symfony/symfony — pull request #10999 by fabpot (2014-05-26 16:58:11+00:00)
Title: [HttpKernel] removed absolute paths from the generated container

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | first step to resolve #6484, #3079, and #9238
| License | MIT
| Doc PR | n/a

This code was merged to 2.3 in (#10894, #10937, and #10979) but it caused too many problems and so was reverted. This PR targets master (aka 2.6) to get plenty of time to figure out the best way to implement this feature without too many BC breaks.

Some issues that should be taken care of before re-merging this into master: #10976, symfony/symfony-standard#659.

The biggest problem is the usage of `dirname` which is naive per the PHP documentation: "dirname() operates naively on the input string, and is not aware of the actual filesystem, or path components such as "..".")". So, basically, as we have now `..` in the root and cache dirs, using dirname on them is not possible anymore. One solution would be to use `dirname` calls instead of adding `..` specifically for the root and cache dir, but other paths could be used a problem as well. A better fix would be to check usage of all `dirname` calls and be sure that we operate on a safe path or call `realpath` when needed.

From the original PR:

This PR converts absolute paths to relative ones in the dumped container. The code is a bit "ugly", but it gets the job done and I'm not sure that there is a more elegant way without breaking everything.