Skip to content
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

Wrong Environment loaded by Liip (Always Prod) #738

Closed
bastos71 opened this issue May 19, 2016 · 16 comments
Closed

Wrong Environment loaded by Liip (Always Prod) #738

bastos71 opened this issue May 19, 2016 · 16 comments

Comments

@bastos71
Copy link

bastos71 commented May 19, 2016

Hi everyone !

I have a problem with the bundle in my "preprod" and my "dev" environments.

After debuging it seems the bundle always load my "prod" configuration.

Here is my configurations files structure :

--app
----config
------config.yml
------config_dev.yml
------config_preprod.yml
------config_prod.yml
------parameters.yml
------parameters_dev.yml
------parameters_preprod.yml
------parameters_prod.yml

Does the bundle automaticaly load the parameter file set in /composer.json ? That would explain my problem...

Thanks !

@bastos71
Copy link
Author

Up ! :3

@BartVB
Copy link

BartVB commented Jul 12, 2016

As far as I know LiipimageBundle doesn't load any config files on it's own. Configuration is managed by Symfony.

Are you 100% sure that this is only a problem with LiipImagineBundle?

@bastos71
Copy link
Author

Hi BartVB ! And thx for your reply.

Yes as far as I tested my application in 3 environments (dev / prerprod / prod), the problem only occurs with LiipImagineBundle, and in both dev and preprod environments.

Here are more details : I have a multilingual website, and I use a bundle who need to define the different domain names of my different languages (mysite.fr, mysite.es, etc...), and this lines are in parameters_dev.yml / parameters_preprod.yml / parameters.yml. Those files are loaded in config_dev.yml / condif_preprod.yml / config_prod.yml.
And again, those files load the basic config.yml

So in dev, I try to call the url "http://www.dev-mysite.com/media/myimages/cache/resolve/....", the resolution is launched on the prod environment (with a different domain name) : "http://www.mysite.com/media/myimages/cache/resolve/....".

That's why I think the bundle launch on it's own at least the app.php instead of my app_dev.php, or it loads on it's own the config_prod.yml

Do you need more explenations ?

Thanks for your reply again !

@BartVB
Copy link

BartVB commented Jul 13, 2016

Trying to figure out what the problem is here.
Opening http://www.dev-mysite.com/media/myimages/cache/resolve/.... and http://www.mysite.com/media/myimages/cache/resolve/.... in a browser gives you the same result while they should be different? In that case check your (Symfony) log file to see wether app.php or app_dev.php is used. Or, even easier, temporarily remove/disable app.php and see what happens. If the URL won't load you'll know that your webserver configuration is at fault. Your webserver defines if app.php or app_dev.php is loaded when you open http://www.dev-mysite.com/....

Or does the output of your application contain http://www.mysite.com where this should be http://www.dev-mysite.com ?

@bastos71
Copy link
Author

Yes that's it :

Or does the output of your application contain http://www.mysite.com where this should be http://www.dev-mysite.com ?

Here are more informations about my application :

  • In fact in dev environment app_dev.php is always called, and in prod it's always app.php
  • In my application I've got legacy modules, and my VHost doesn't point directly in "/web" but in "/", and I make the redirections in my htaccess, executing the "app_[env].php" that is needed.

@bastos71
Copy link
Author

I know it's a little tricky ^^
But it works fine for others bundles :/

@BartVB
Copy link

BartVB commented Jul 13, 2016

How do you generate those URLs? Are you using asset() with imagine_filter() to do this?

@bastos71
Copy link
Author

yep

@bastos71
Copy link
Author

here is an example how I use it (I didn't metioned it but I also use VichUploader) :

{{ vich_uploader_asset(product, 'imageFile') | imagine_filter('product_medium_listing') }}

@bastos71
Copy link
Author

and I dumped the result of {{ vich_uploader_asset(product, 'imageFile') and it returns a dev url.

Also I dumped the url with imgine_filter() and it stills a dev url.

That's why I thnik it comes from the cache resolution :/

@BartVB
Copy link

BartVB commented Jul 13, 2016

The CacheResolvers aren't that complex, they should be fairly easy to debug?
The default resolver is this:
https://github.com/liip/LiipImagineBundle/blob/master/Imagine/Cache/Resolver/WebPathResolver.php

Everything highly depends on your exact implementation/configuration. The most obvious place to check is the value of $webRoot.

@bastos71
Copy link
Author

okay thanks, I'll debug this resolver to see where it implements my prod URL.

I will give you a feed back

@alexwilson
Copy link
Collaborator

Hey,

Any updates on this?

@bastos71
Copy link
Author

bastos71 commented Sep 6, 2016

No sorry :/ I did not find any solution to my problem :/

Le 6 sept. 2016 23:45, "Alex Wilson" [email protected] a écrit :

Hey,

Any updates on this?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#738 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADogEyK0J_S58Tjr76Za3bzw3EsLCcwpks5qnd7cgaJpZM4Ih_1S
.

@alexwilson
Copy link
Collaborator

alexwilson commented Sep 7, 2016

Thanks!

As @BartVB has said, this bundle doesn't load any configuration files by its own (That would defeat the purpose if being a Symfony Bundle!), nor does it make any assumptions about environment, so this sounds like a local issue specific to your configuration.

The WebPathResolver uses a factory to provide the value of web_root to its service definition, and so I wonder if for some reason Symfony is being run in prod mode during the generation/manipulation of the service definition.

Would you mind editing this file, and inserting an error_log("WebPathResolverFactory running in {$container->getParameter('kernel.environment')} mode.") on line 16, and then posting the output error messages here?

@michellesanver
Copy link
Contributor

Thanks @antoligy for your help in debugging this issue! As we had no response from @bastos71 it looks like this issue is abandoned. If it's still an issue for anyone, please open a new issue and we can look at it and prioritise accordingly.

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

No branches or pull requests

4 participants