-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[4.2] Change the db calls back to the getDbo #38506
Conversation
@FoTo50 Can you test this pull request please? |
I have tested this item ✅ successfully on f5b8086 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38506. |
Thanks very much for this good explanation. This now works just as expected, in 4.1.5 and in 4.2.0 I think this would be a good example to modify https://docs.joomla.org/Connecting_to_an_external_database with since this page is probably for most the starting point when asking Google for it |
Even when this article still uses the old code, it shows you how to do it the correct way, by using the setDbo function and not overriding getDbo. It is not safe to rely on the base class, that it uses all the time getDbo when there is even a protected variable $_db in the BaseDatabaseModel class. So I suggest you adapt your code, as this change will be reverted in 5.0. Anyway, happy that the pr works also for you now and the issue is fixed. |
@FoTo50 Great to hear it is working again. Could you please mark your test on our issue tracker as well? All you need to do is:
This will then be marked here as a human test result and we can get this merged. Thank you. |
I have tested this item ✅ successfully on f5b8086 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38506. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38506. |
Thank you very much! |
This reverts commit 1ce74dc.
Pull Request for Issue #38505.
Summary of Changes
When an extension is overriding the getDbo function in a model and returning it's own database instance, then the parent classes are not using it anymore as they use getDatabase now. Correct way would be to inject the database instance through the argument in the constructor config or setDbo/setDatabase.
The following code snippet shows the code issue:
Correctly you would write:
To maintain full backwards compatibility, this pr changes back the usage to getDbo.
Testing Instructions
Use the extension from issue #38505.
Actual result BEFORE applying this Pull Request
It throws an error.
Expected result AFTER applying this Pull Request
It works as expected.