symfony/symfony — pull request #12928 by xelaris (2014-12-10 03:05:46+00:00)
Title: bug #12893 [DependencyInjection] Normalize path values with realpath.

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #12893
| License | MIT
| Doc PR |

As mentioned in #12893 the PhpDumper currently produces paths like

'kernel.cache_dir' => (dirname(dirname(dirname(__DIR__))).'/app/../var/cache/de_'),

if the cache directory is outside the AppKernel root. With this PR this path would appear as

'kernel.cache_dir' => __DIR__,

which sould be equivalent. Since this path does not contain the enviroment part, even if it was outside AppKernel root, there is no more need to fix it from warmup to real cache path (which does not work with relative paths currently).

E.g. other path like session.save_path are written as

'session.save_path' => (__DIR__.'/sessions'),

instead of

'session.save_path' => (dirname(dirname(dirname(__DIR__))).'/app/../var/cache/de_/sessions'),

With this change the path values are normalized with realpath, before matching them against the targetDirRegex, which was in turn generated after passing the 'dir' option to realpath. So the path values have a better chance to match the regex.

I'm not sure if the change has a negative effect in other cases. Could it be a reasonable solution?