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

Media sources not working - Error 500 [2.4.2] #32341

Closed
1 of 5 tasks
Dutch77 opened this issue Mar 2, 2021 · 14 comments
Closed
1 of 5 tasks

Media sources not working - Error 500 [2.4.2] #32341

Dutch77 opened this issue Mar 2, 2021 · 14 comments
Assignees
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response

Comments

@Dutch77
Copy link

Dutch77 commented Mar 2, 2021

Preconditions (*)

  1. Magento version 2.4.2
  2. php 7.4
  3. nginx 1.19
  4. MariaDB 10.4.17
  5. elasticsearch 7.9.3

Steps to reproduce (*)

  1. Install fresh 2.4.2 project
  2. switch it to production mode
  3. Successfully upload image to any product
  4. Try to visit image public URL
  5. Get status code 500

Expected result (*)

  1. Getting 200 with image result :)

Actual result (*)

NOTICE: PHP message: PHP Fatal error:  Uncaught RuntimeException: ObjectManager isn't initialized in /var/www/web/vendor/magento/framework/App/ObjectManager.php:36
Stack trace:
#0 /var/www/web/vendor/magento/framework/File/Mime.php(84): Magento\Framework\App\ObjectManager::getInstance()
#1 /var/www/web/pub/get.php(61): Magento\Framework\File\Mime->__construct()
#2 {main}
  thrown in /var/www/web/vendor/magento/framework/App/ObjectManager.php on line 36
127.0.0.1 -  02/Mar/2021:15:47:12 +0000 "GET /get.php" 500

What exactly is wrong here

Workaround

  1. Move or duplicate line 76 anywhere before line 64 https://github.com/magento/magento2/blob/2.4.2/pub/get.php (not sure if that's not a performance issue)

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Mar 2, 2021

Hi @Dutch77. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@engcom-Bravo
Copy link
Contributor

Hello @Dutch77

Thank you for your report.

Can you please clarify step number 4 Try to visit image public URL and if possible provide a screen or video.
Because for now, it's not clear.

Thank you in advance

@engcom-Bravo engcom-Bravo self-assigned this Mar 4, 2021
@m2-assistant
Copy link

m2-assistant bot commented Mar 4, 2021

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Bravo engcom-Bravo added the Issue: needs update Additional information is require, waiting for response label Mar 4, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Mar 4, 2021
@Dutch77
Copy link
Author

Dutch77 commented Mar 4, 2021

Hello @Dutch77

Thank you for your report.

Can you please clarify step number 4 Try to visit image public URL and if possible provide a screen or video.
Because for now, it's not clear.

Thank you in advance

I will clarify that

  1. open some product in administration
  2. upload an product image
  3. save product
  4. image is missing, browser placeholder instead see: https://ibb.co/3Fn8StC
  5. this is the url of image /media/catalog/product/r/e/red.png
  6. when image is opened in the new window, response has error code 500

@engcom-Bravo engcom-Bravo removed their assignment Mar 5, 2021
@engcom-Bravo engcom-Bravo removed the Issue: needs update Additional information is require, waiting for response label Mar 5, 2021
@m2-community-project m2-community-project bot moved this from Needs Update to Ready for Confirmation in Issue Confirmation and Triage Board Mar 5, 2021
@stale
Copy link

stale bot commented May 20, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

@stale stale bot added the stale issue label May 20, 2021
@tangar76
Copy link

tangar76 commented May 27, 2021

I think it has something to do with server settings.

When media image exists then server has to show it immediately. But for some reason handling this request is given to Magento pub/get.php.

I'm not good with server settings. It is quite hard for me to understand such behavior. But form PHP side I have found quick solution. Move Magento bootstrat initialization earlier in code. ObjectManager is initialized in Bootstrap::create method.

--- /pub/get.php
+++ /pub/get.php (Unsaved)
@@ -33,6 +33,15 @@
     )
 );
 $relativePath = $request->getPathInfo();
+
+// Materialize file in application
+$params = $_SERVER;
+if (empty($mediaDirectory)) {
+    $params[ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG] = [];
+    $params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]];
+}
+$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
+
 if (file_exists($configCacheFile) && is_readable($configCacheFile)) {
     $config = json_decode(file_get_contents($configCacheFile), true);
 
@@ -67,13 +76,6 @@
     }
 }
 
-// Materialize file in application
-$params = $_SERVER;
-if (empty($mediaDirectory)) {
-    $params[ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG] = [];
-    $params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]];
-}
-$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
 /** @var \Magento\MediaStorage\App\Media $app */
 $app = $bootstrap->createApplication(
     \Magento\MediaStorage\App\Media::class,

@stale stale bot removed the stale issue label May 27, 2021
@Dutch77
Copy link
Author

Dutch77 commented May 27, 2021

That is the exact workaround we're currently using :D

@engcom-Lima engcom-Lima self-assigned this May 31, 2021
@m2-assistant
Copy link

m2-assistant bot commented May 31, 2021

Hi @engcom-Lima. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Lima
Copy link
Contributor

Hi @Dutch77

I saw your issue, it is looking configuration settings related. Can you please provide me some screenshots and more steps to investigate this in details.

@engcom-Lima engcom-Lima added the Issue: needs update Additional information is require, waiting for response label Jun 3, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Jun 3, 2021
@engcom-Lima engcom-Lima added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Jun 16, 2021
@engcom-Lima
Copy link
Contributor

Hi @Dutch77 Can't reproduce the issue. I tested Magento ver. dev-2.4-develop. Hence closing this ticket.

Please find the attached Screenshots.
Screenshot 2021-06-16 at 6 21 50 PM
Screenshot 2021-06-16 at 6 21 59 PM
Screenshot 2021-06-16 at 6 22 16 PM

@vshatylo
Copy link
Contributor

Hello,
problem still reproduces on magento 2.4.3
it's hard to reproduce with one user or could be simulated with adding code "sleep(1)" into pub/get.php
error occurs when many visitor surfs website.
Steps to reproduce

  • upload new image for product or could be existing image
  • check media directory pub/media/catalog/product/cache/<image_path>, if file exists - remove it
  • open cached product image with 10+ concurrent requests

@alexmtch
Copy link

alexmtch commented Mar 1, 2022

Hello @engcom-Lima Make sure you goes trough this condition with you test case.
if (file_exists($configCacheFile) && is_readable($configCacheFile))

@Dutch77
I've reproduced in local with this case because the file permissions of my wysiwyg folder was "drwx". To fix that we could set the permissions to the media folder. Try chmod -R 755 pub/media. In this case if the media exists the get.php file is not called and then the error cannot be reproduced.

@LB-Team-igniti
Copy link

LB-Team-igniti commented Aug 24, 2022

Hello, problem still reproduces on magento 2.4.3 it's hard to reproduce with one user or could be simulated with adding code "sleep(1)" into pub/get.php error occurs when many visitor surfs website. Steps to reproduce

* upload new image for product or could be existing image

* check media directory pub/media/catalog/product/cache/<image_path>, if file exists - remove it

* open cached product image with 10+ concurrent requests

@engcom-Lima This is exactly how I could reproduce/enforce the issue locally as well. We see this error message on our LIVE system.

@LB-Team-igniti
Copy link

I just realized that this issue has been solved already in the latest 2.4-develop branch of magento and in version 2.4.5: f142625

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response
Projects
None yet
Development

No branches or pull requests

7 participants