[7.0] Remove deprecated getDbo()/setDbo() from Table class#47440
[7.0] Remove deprecated getDbo()/setDbo() from Table class#47440Hackwar wants to merge 8 commits into
Conversation
HLeithner
left a comment
There was a problem hiding this comment.
That's not the right or best solution
|
What exactly do you mean? |
|
Yes, replacing |
| * Use setDatabase() and getDatabase() instead | ||
| * Example: $this->setDatabase($db); | ||
| */ | ||
| protected $_db; |
There was a problem hiding this comment.
Can we not make a magic getter for another major?
There was a problem hiding this comment.
We've kept this around for a very long time, so I don't think extending the deprecation period further would be of any help.
There was a problem hiding this comment.
I have something like https://github.com/joomla/joomla-cms/pull/45862/changes#r3274650060 in mind
| public function addTagMapping($ucmId, TableInterface $table, $tags = []) | ||
| { | ||
| $db = $table->getDbo(); | ||
| $db = Factory::getDbo(); |
There was a problem hiding this comment.
Load at least the database from the container
There was a problem hiding this comment.
The whole code actually needs to be refactored.
Summary of Changes
As with everywhere in Joomla, we shouldn't be implementing custom database object setters and getters and instead use the
DatabaseAwareTraitinstead. TheTableclass has the methodsgetDbo(),setDbo(),getDatabase()andsetDatabase()to retrieve the db object. The first 2 are supposed to be removed and the later 2 are only there to make the transition to the trait smoother. With the removal of the former 2, we can completely rely on the trait and remove the later 2 as well.Testing Instructions
Codereview
Link to documentations
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org: [7.0] Removal of custom DB object from Table class Manual#600
No documentation changes for manual.joomla.org needed