Description
I ran into an issue where my asset urls where not prefixed with the base url on my production server. I could not reproduce this on my development machine (not even in the production environment). After digging in for a while i figured out that the one difference between my development environment and my production environment is the fact that i use https for all requests in production.
This issues is that when your configuration looks like this:
framework:
templating:
assets_base_urls: /symfony
This does only prefix http requests with /symfony, not http/ssl-request, as i was expecting.
To get the desired behavior, you need to use this configuration:
framework:
templating:
assets_base_urls:
http: /symfony
ssl: /symfony
I expected these two examples to be compatible with each other.
To fix this, you could make a change here: https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php#L391
To:
if (is_integer($i)) {
if (0 === strpos($url, 'http://')) {
$urls['http'][] = $url;
} else {
$urls['http'][] = $urls['ssl'][] = $url;
}
unset($urls[$i]);
}
This handles the case where you don't explicitly specify http and ssl.
Before, it added to both https and http for everything containing https or //, and to http only for everything containing http or nothing of the above.
The change adds to http only if http is specified and to http and ssl for all other cases. The case that was missing from the ssl-configuration was when you didn't specify protocol at all.
Is this an acceptable solution? Is this considered backwards compatibility breaking? If i can get some approval of this change here, i will create a pull request.