-
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
ProductRepository is loading initializationHelper which is an Adminhtml controller #37864
Comments
Hi @MrBlueEyez. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Just been looking back into the history: But the usage is removed in 2.1.0 and beyond: |
Good catch! |
@magento I am working on this |
- Removed unused class \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper from \Magento\Catalog\Model\ProductRepository
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @MrBlueEyez, Thanks for the report and collaboration! We have tried to reproduce the issue in Magento 2.4-develop branch by looking into the codebase. And it seems the issue is reproducible for us.
Hence confirming the issue. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-9302 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
Summary
The
Magento\Catalog\Model\ProductRepository
is loading theMagento\Catalog\Controller\Adminhtml\Product\Initialization\Helper
in its constructor, but then continues to not use it.This, on a first look, doesn't seem to cause any issues. However when using some third party modules which extend the
PathInfoProcessor
and that uses the productRepository this is causing some issues with loading in di.xml configurations.When trying to use the rest-api with an oauth authorization, the
Magento\Framework\App\Http
class is triggered, which first tries to get the area code of the current url. But then the custom logic by the third party is triggered, finally loading in the productRepository. The productRepository then tries to load the above mentioned adminhtml controller, which tries to access the roleLocatorInterface, which is now not based on the webapi_rest/di.xml, but on the default app/etc/di.xml. Causing theMagento\Framework\Authorization\RoleLocator\DefaultRoleLocator
to be loaded instead of theMagento\Framework\Authorization\RoleLocatorInterface\WebapiRoleLocator
. This last thing causes the authorization to fail, as theDefaultRoleLocator
returns''
instead of executing logic like theWebapiRoleLocator
.There is currently no workaround for this.
Examples
The only thing that is required to be changed for this to work is to remove the
\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper,
inMagento\Catalog\Model\ProductRepository
on line 225.Which is causing this issue, and isn't being used in the file at all.
Proposed solution
Remove the loading of
\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper,
inside theMagento\Catalog\Model\ProductRepository
.Release note
Removing unused
Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper
fromMagento\Catalog\Model\ProductRepository
Triage and priority
The text was updated successfully, but these errors were encountered: