-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[2.x.x] Production mode is not detected in CLI => the uri for media and static are not good and contain pub #8868
Comments
This also affects stock alert emails sent by cron, as both the CLI and cron.php entry points are missing the explicit directory path override that |
Finally found workaround: |
but this is just a workaround... It will be better if it was automatic... |
@spipu, thank you for your report. |
Additional use case: #9111 |
There's no possibility to assign correct paths automatically as it was mentioned by @spipu Cloning bin/magento file to pub is not good enough solution so my proposal is to store custom document_root variable in application.config.php #distributed-cd |
@Tomasz-Silpion thank you for joining. Please accept team invitation here and self-assign the issue. |
This bug has shown up for me a few times in different situations and is starting to become quite annoying. First noticed in sitemaps when generated via cron and now for an email module I am writing where images paths are incorrect. Has anyone a simple workaround for this yet? Not sure how to use workaround mentioned by @scottsb to set environment variables. |
@harrigo: can you try this workaround: #5321 (comment), it used to work at the time of writing, but it's been a while since I last tested this, so not sure anymore. |
@hostep Yeah thanks for the tip think i tried that and not had much luck i will however give another go see how it goes. Any idea how I set them environment variables for crontab? I have tried by setting them in Am not actually sure of what |
Hi @harrigo. We're following each other around. In the workaround I suggest over on StackExchange, |
@scottsb haha seems so this is bugging me so just gone everywhere! I think my problem more now how to set that. I tried within |
Hi @peterjaap. Thank you for working on this issue.
|
Any update? :) |
Hi @nik4152. Thank you for working on this issue.
|
@spipu Hi you need add code to file
` |
[Bengals Team] Test Fixes and Automation Tasks
This is a technical issue. It occurs on every edition (CE an EE) and every version (2.0.0 -> 2.1.5) of Magento.
When we are in Production Mode, and if we use the
pub
folder as main public folder, then all the static url and media url must not contain thepub
part. That's normal.It is not a automatic switch made on the magento mode value, but its depends on the index.php file that is used.
In the file
./pub/index.php
, it overrides the directoryList's config (given to the bootstrap) with the following :https://github.com/magento/magento2/blob/2.1/pub/index.php#L27
This configuration overriding is not present in the developer mode index.php :
https://github.com/magento/magento2/blob/2.1/index.php#L36
The pb is that when we are in production mode, if we ask for a static url or a media url in CLI, then the urls are not good and contain the pub part.
It is because, in CLi, there is no switch that will detect if we are in production or not, and if the directoryList configuration have to be overridden or not.
It could be in
Magento\Framework\Console\Cli::getApplicationCommands
at line 127:https://github.com/magento/magento2/blob/2.1/lib/internal/Magento/Framework/Console/Cli.php#L127
=> For now, it is impossible to send emails in CLI if we are in production mode, because the website logo will not work...
Preconditions
Steps to reproduce
Expected result
Command output does not contain "pub"
Actual result
Command output contains "pub"
The text was updated successfully, but these errors were encountered: