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

Magento 2.3.1: Catalog setup fails with error "Magento\Catalog\Setup\Media does not exist" #22124

Closed
nussjustin opened this issue Apr 3, 2019 · 16 comments
Assignees
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@nussjustin
Copy link

nussjustin commented Apr 3, 2019

Preconditions

  1. magento/product-enterprise-edition 2.3.0
  2. PHP 7.2

Exact PHP version:

PHP 7.2.16 (cli) (built: Mar  5 2019 13:10:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.16, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans

Steps to reproduce

  1. Update from magento/product-enterprise-edition 2.3.0 to 2.3.1
  2. Run bin/magento setup:upgrade

Expected result

  1. No errors, normal output

Actual result

  1. Error Class Magento\Catalog\Setup\Media does not exist when running Data install/update for Magento_Catalog

This seems to be a bug in the CategorySetup.php:

https://github.com/magento/magento2/blob/4a28abb/app/code/Magento/Catalog/Setup/CategorySetup.php#L629

This should probably be \Magento\Catalog\Model\Product\Attribute\Backend\Media::class or a use \Magento\Catalog\Model\Product\Attribute\Backend\Media be added at the beginning of the file.

@m2-assistant
Copy link

m2-assistant bot commented Apr 3, 2019

Hi @nussjustin. 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-engcom-team give me 2.3-develop instance - upcoming 2.3.x release

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

@nussjustin do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Apr 3, 2019
@nussjustin
Copy link
Author

Hi @nussjustin. 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:

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

@nussjustin do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@hostep
Copy link
Contributor

hostep commented Apr 3, 2019

Nice find @nussjustin! Issue seems to have been introduced in dcd8b32#diff-7b8ac6c93b8d79968c8d4d8237621404L587 (I'm wondering why the tests didn't catch this...)

Would you be willing to create a Pull Request with a fix for this?

@nussjustin
Copy link
Author

After looking at it again, I'm not sure what the correct fix would be. In Magento 2.2 there was some kind of mapping in the di.xml

https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Catalog/etc/di.xml#L692-L703

This was removed in 2.3.1 at it seems, so just using Magento\Catalog\Model\Product\Attribute\Backend\Media does not work anymore.

@renttek
Copy link

renttek commented Apr 3, 2019

maybe the author of the mentioned commit has an answer for this, @rganin ?

@orlangur
Copy link
Contributor

orlangur commented Apr 3, 2019

This functionality does not seem to be a part of Magento Open Source, isn't it?

In such case

Please report Magento Commerce issues via the Support portal of your account or Partner portal if you are a partner reporting on behalf of a merchant.
GitHub is intended for Magento Open Source bug reports given no account management for Magento Open Source users. This will allow for proper tracking of issues at the account level.

@orlangur orlangur closed this as completed Apr 3, 2019
@renttek
Copy link

renttek commented Apr 3, 2019

@orlangur he may have used the enterprise, but the error is in Magento_Catalog, which is in Open Source...

@orlangur
Copy link
Contributor

orlangur commented Apr 3, 2019

@renttek it does not matter, it's quite a frequent situation that enterprise issues require fixes in community modules.

This issue can be reopened if it is reproducible on a Magento Open Source. Otherwise it just cannot be reproduced and fixed by Community members.

@renttek
Copy link

renttek commented Apr 3, 2019

I can understand this reasoning, but this is literally a basic 'could be catched by an IDE' php coding error, in a an OS module, introduced by @rganin withint commit dcd8b32 (Which references "MAGETWO-87551")

@nussjustin maybe you should just open another issue with the CE m(

@orlangur
Copy link
Contributor

orlangur commented Apr 3, 2019

@renttek man, do you hear me? :) There is no need to open another one.

@nussjustin @hostep @renttek could please anyone confirm it is reproducible on Magento Open Source? I really doubt this wasn't tested prior to release but reopening in advance.

@orlangur orlangur reopened this Apr 3, 2019
@hostep
Copy link
Contributor

hostep commented Apr 3, 2019

@nussjustin: thanks for pointing out that Magento\Catalog\Model\Product\Attribute\Backend\Media actually doesn't even exist, hadn't seen that yet. It was removed a while ago in 0f0063045b5 (part of merge commit 9b08b0b)
Regarding the mapping, I don't think this is relevant here.

If I take a look at the database, in the table eav_attribute, the column backend_model for the attribute media_gallery is set to NULL, both in Magento 2.3.1 as 2.2.7.
So it looks like providing a non existing class in the database migration scripts for the backend model doesn't throw errors or warnings, but just inserts NULL. (Not sure if that is correct though, a warning would be nice here I think?).

The correct fix here would probably be to remove the backend model in the CategorySetup.php file for the media_gallery attribute as it doesn't need to have one I think.

@orlangur: I don't know how to reproduce the error @nussjustin sees. But this is a code smell, and it would be nice if this could get cleaned up I think.

@orlangur
Copy link
Contributor

orlangur commented Apr 3, 2019

The correct fix here would probably be to remove the backend model in the CategorySetup.php file for the media_gallery attribute as it doesn't need to have one I think.

Agree on that, @nussjustin for the reproduction would be nice if you figure out what causes a problem in one of Magento Commerce modules, maybe provide an isolated case as a small module just for revealing issue.

@nussjustin
Copy link
Author

I'm currently unable to reproduce with a fresh Magento 2 (with sample data, both when installing 2.3.1 directly and when upgrading from 2.3.0 to 2.3.1) both CE and EE, but consistently with a copy of one of our customers M2 EE installations.

This problem is currently preventing us from upgrading one of our customers sites from 2.3.0 EE to 2.3.1 EE.

@orlangur
Copy link
Contributor

orlangur commented Apr 3, 2019

If I take a look at the database, in the table eav_attribute, the column backend_model for the attribute media_gallery is set to NULL, both in Magento 2.3.1 as 2.2.7.

@nussjustin probably this is not true for this one customer?

As a workaround just create a dummy app/code/Magento/Catalog/Model/Product/Attribute/Backend/Media.php class and surely it would be nice to create a pull request for 2.3-develop which eliminates referring nonexistent class.

@nussjustin
Copy link
Author

@orlangur The backend_model for media_gallery is NULL for this customer.

Creating an empty class Media that extends AbstractBackend worked, thanks. The backend_model is still NULL in the eav_attribute table, but everything works.

@magento-engcom-team
Copy link
Contributor

Hi @nussjustin. Thank you for your report.
The issue has been fixed in #22446 by @hostep in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

5 participants