-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Fix for running bin/magento without proper database connection (removes db connection attempts from DI constructors) #37424
Conversation
…e to DateTimeFactory. Both of these caused unnecessary connections to be made to the database when executing bin/magento commands.
Hi @hostep. Thank you for your contribution! Add the comment under your pull request to deploy test or vanilla Magento instance:
❗ Automated tests can be triggered manually with an appropriate comment:
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔ Approved.
Failing tests look not related to changes from this PR.
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
1 similar comment
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
app/code/Magento/MediaGallerySynchronization/Model/SynchronizeFiles.php
Outdated
Show resolved
Hide resolved
…es db connection attempts from DI constructors) Fix typo Co-authored-by: Dan Wallis <dan@wallis.nz>
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run Functional Tests EE, Functional Tests CE, Functional Tests B2B |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
1 similar comment
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
It looks like this PR got merged in 2.4-develop recently via: d4a9791 But this PR is not marked as merged, which is quite strange? Should I close it myself? |
This pull request was merged in 4095595. |
@ihor-sviziev Just want to call out that this certainly appears to be a backwards incompatible change, and for that reason I'm surprised it was merged into
|
@dfelton: I certainly agree that it's backwards compatible breaking in case 3rd party modules extends those classes, but Magento has this rule they only disallow such code changes on classes that are annotated with I don't think a lot of 3rd party modules will have extended these classes and fixing them would be pretty easy (unless they have to support both older Magento versions and upcoming ones at the same time, but even that can be solved, it's only a bit more complex though, here's an example). |
Ah, thank you for this piece of info @hostep. This makes sense. I felt compelled to mention it because I have had an open pr with Magento since 2019 for a much smaller change, that is taking forever to get merged in due to backwards incompatibility. However, as you point out, classes marked Cheers! |
Fix for running bin/magento without proper database connection (removes db connection attempts from DI constructors)
Remove obsolete ResourceModel\Product dependency and reworked DateTime to DateTimeFactory. Both of these caused unnecessary connections to be made to the database when executing bin/magento commands.
Description (*)
Whenever you execute
bin/magento
(with our without explicit commands), Magento will load all registered Commands and load all their dependencies through DI. Those dependencies will load their own dependencies, and so on and so forth.I've noticed that through the whole depenencies tree, some dependencies tried to fetch something from the database. This is really not needed when executing
bin/magento
without providing an explicit command to actually do something with the database.The removal of the
Magento\Catalog\Model\ResourceModel\Product
dependency should be safe, as it wasn't being used in the class anyways.The change of the
DateTime
toDateTimeFactory
causes that no locale info from the database is being requested in the constructor. It should only happen at runtime and was inspired by this code here.These 2 dependencies were loaded from the commands
bin/magento media-gallery:sync
&bin/magento media-content:sync
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
app/etc/env.php
file and change the correct database user to an incorrect onebin/magento
app/etc/env.php
filebin/magento media-gallery:sync
&bin/magento media-content:sync
still work as expected, those should be the only real commands affected by these changesQuestions or comments
Contribution checklist (*)