No Code Attached Yet
avatar basd82
basd82
24 Oct 2021

Steps to reproduce the issue

Multilpe components still use getDbo() with is depracted

Expected result

must use Factory::getContainer()->get('DatabaseDriver'); instead

Actual result

System information (as much as possible)

Additional comments

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
2.00

avatar basd82 basd82 - open - 24 Oct 2021
avatar basd82 basd82 - change - 24 Oct 2021
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 24 Oct 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 24 Oct 2021
avatar basd82
basd82 - comment - 24 Oct 2021

i submitted patch
basd82@0dc3b22
basd82@270753c
basd82@76cc185
basd82@18381f6
basd82@a0f1539
basd82@9ca19f9
basd82@051ff26

I am not sure if i can replace $this->getDbo(); also with Factory::getContainer()->get('DatabaseDriver'); in the following files :

com_banners/src/Model/BannerModel.php:56: $db = $this->getDbo();
com_banners/src/Model/BannerModel.php:184: $db = $this->getDbo();
com_banners/src/Model/BannersModel.php:64: $db = $this->getDbo();
com_banners/src/Model/BannersModel.php:317: $db = $this->getDbo();
com_contact/src/Model/CategoryModel.php:162: $db = $this->getDbo();
com_contact/src/Model/ContactModel.php:200: $db = $this->getDbo();
com_contact/src/Model/ContactModel.php:333: $db = $this->getDbo();
com_contact/src/Model/FeaturedModel.php:90: $db = $this->getDbo();
com_content/src/Model/ArchiveModel.php:74: $secondary = QueryHelper::orderbySecondary($articleOrderby, $articleOrderDate, $this->getDbo());
com_content/src/Model/ArchiveModel.php:97: $db = $this->getDbo();
com_content/src/Model/ArchiveModel.php:110: $queryDate = QueryHelper::getQueryDate($articleOrderDate, $this->getDbo());
com_content/src/Model/ArchiveModel.php:169: $db = $this->getDbo();
com_content/src/Model/ArchiveModel.php:215: $db = $this->getDbo();
com_content/src/Model/ArticleModel.php:98: $db = $this->getDbo();
com_content/src/Model/ArticleModel.php:345: $db = $this->getDbo();
com_content/src/Model/ArticlesModel.php:196: $db = $this->getDbo();
com_content/src/Model/ArticlesModel.php:866: $db = $this->getDbo();
com_content/src/Model/CategoryModel.php:312: $db = $this->getDbo();
com_content/src/Model/CategoryModel.php:337: $secondary = QueryHelper::orderbySecondary($articleOrderby, $articleOrderDate, $this->getDbo()) . ', ';
com_content/src/Model/FeaturedModel.php:111: $secondary = QueryHelper::orderbySecondary($articleOrderby, $articleOrderDate, $this->getDbo());
com_content/src/Model/FormModel.php:290: $db = $this->getDbo();
com_finder/src/Model/SearchModel.php:135: $db = $this->getDbo();
com_finder/src/Model/SuggestionsModel.php:73: $db = $this->getDbo();
com_newsfeeds/src/Model/CategoryModel.php:151: $db = $this->getDbo();
com_newsfeeds/src/Model/NewsfeedModel.php:90: $db = $this->getDbo();
com_privacy/src/Model/RemindModel.php:77: $db = $this->getDbo();
com_privacy/src/Model/RequestModel.php:93: $db = $this->getDbo();
com_tags/src/Model/TagsModel.php:102: $db = $this->getDbo();
com_users/src/Model/RegistrationModel.php:79: $db = $this->getDbo();
com_users/src/Model/RegistrationModel.php:156: $db = $this->getDbo();
com_users/src/Model/RegistrationModel.php:501: $db = $this->getDbo();
com_users/src/Model/RegistrationModel.php:643: $db = $this->getDbo();
com_users/src/Model/RemindModel.php:135: $db = $this->getDbo();
com_users/src/Model/ResetModel.php:298: $db = $this->getDbo();
com_users/src/Model/ResetModel.php:404: $db = $this->getDbo();


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35884.
avatar laoneo
laoneo - comment - 24 Oct 2021

Please use in models only $this->getDbo(). Factory::getContainer()->get('DatabaseDriver') should be used carefully only on places where there is no $db injected. Static access in general should be avoided in J4 whenever possible.

avatar richard67
richard67 - comment - 24 Oct 2021

@basd82 As @laoneo pointed out in the previous comment, the code which you have mentioned in your comment that you are not sure is ok as it is.

From the 7 changes you have made in your fork, the first one (branch patch-1) is in a model, so it seems it should be changed to use the injected bd object there, i.e. use $db = $this->getDbo();.

The other 6 changes you made seem to be valid at a first look.

But you haven't submitted your changes yet as a patch, you only have made them in your repository, i.e. your fork of the CMS repository.

To submit a change you would have to make pull requests.

But for this it would be better if you had all 7 changes in one branch, and not in 7 separate branches "patch-1" to "patch-7".

Do do that you can select one of these branches and then make the same changes as done in the other branches in that selected branch.

Then, when having all changes together in one branch, you can make a pull request to the CMS repository.

You can find here some documentation about how to do that on GitHub: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

Would be nice if you could make a pull request.

Let us know here if you need more advise and we will try to help as good as we can.

Finally: Could you update the description of this issue by the information that it refers to Joomla 4 and not 3.10? and later in the pull request refer to the issue and also mention the Joomla version?

Thanks in advance.

avatar basd82
basd82 - comment - 24 Oct 2021

I made the pull request but know or can’t link the isue i opend in tracker

Van: Richard Fath @.>
Verzonden: zondag 24 oktober 2021 15:24
Aan: joomla/joomla-cms @.
>
CC: Bas van den Dikkenberg @.>; Mention @.>
Onderwerp: Re: [joomla/joomla-cms] Joomla\CMS\Factory::getDbo() is deprecated. (Issue #35884)

@basd82https://github.com/basd82 As @laoneohttps://github.com/laoneo pointed out in the previous comment, the code which you have mentioned in your comment that you are not sure is ok as it is.

From the 7 changes you have made in your fork, the first one (branch patch-1) is in a model, so it seems it should be changed to use the injected bd object there, i.e. use $db = $this->getDbo();.

The other 6 changes you made seem to be valid at a first look.

But you haven't submitted your changes yet as a patch, you only have made them in your repository, i.e. your fork of the CMS repository.

To submit a change you would have to make pull requests.

But for this it would be better if you had all 7 changes in one branch, and not in 7 separate branches "patch-1" to "patch-7".

Do do that you can select one of these branches and then make the same changes as done in the other branches in that selected branch.

Then, when having all changes together in one branch, you can make a pull request to the CMS repository.

You can find here some documentation about how to do that on GitHub: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

Would be nice if you could make a pull request.

Let us know here if you need more advise and we will try to help as good as we can.

Finally: Could you update the description of this issue by the information that it refers to Joomla 4 and not 3.10? and later in the pull request refer to the issue and also mention the Joomla version?

Thanks in advance.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub#35884 (comment), or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAJJY6ICXKKHTX2UT3WMAZ3UIQCINANCNFSM5GTFHBDA.
Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

avatar basd82
basd82 - comment - 24 Oct 2021

I skiped patch 1, becouse you made that i am not shure of my self,

so i din't change that one that one is still Factory::getDbo();


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/35884.

avatar richard67
richard67 - comment - 24 Oct 2021

@basd82 When you create a pull-request, the description is pre-filled with text and headings as shown here: https://github.com/joomla/joomla-cms/blob/4.0-dev/.github/PULL_REQUEST_TEMPLATE.md , i.e.:

Pull Request for Issue # .

Summary of Changes

...

and so on.

You should not have removed that, you should have completed that.

I.e.:

Pull Request for Issue #35884 .

Summary of Changes

...

It also is required to provide testing instructions if a pull request is not trivial, and if it just is "Check that XXX works as well as before", with XXX being some information about where to test something.

Finally we assume of course that when you provide a pull request, you have tested the changes yourself. So it should not be a problem to provide testing instructions, just describe how you have tested it.

Please complete the description of your PR accordingly. Thanks in advance.

avatar richard67 richard67 - change - 24 Oct 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-10-24 14:33:55
Closed_By richard67
avatar richard67 richard67 - close - 24 Oct 2021
avatar richard67
richard67 - comment - 24 Oct 2021

Closing as having a pull request, see #35888 .

Add a Comment

Login with GitHub to post a comment