User tests: Successful: Unsuccessful:
JModelList class has a method getListQuery to build the query object use to get list of records from database. However, this method is too generic, so all classes which extends this class must implement this class itself.
The problem is that the code for the getListQuery on all children classes (atleast in Joomla core backend) are almost the same. Look at few of them below:
ContactModelContacts: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/models/contacts.php#L148
TagsModelTags: https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_tags/models/tags.php#L121
we end up writing these repeating code again and again. It wastes time and when we want to change something, we will have to change it in different places.
In this PR, I try to improve the getListQuery method of JModelList, move all these repeating code into the parent class so that children classes won't have to implement it again. At the beginning, I just use this new code in ContactModelContacts and TagsModelTags as the sample. We can work on other classes if this PR is accepted
This change will only affect to Contacts list and Tags list from backend of the site. So just test and make sure these pages work well
This PR also needs PLT to review code if we want to get this changed get into our system
This PR use FOFInflector class from FOF, so if FOF is removed from Joomla core in the future, we will need to replace it with similar class. From my experience, we will need to have an string inflector class in Joomla core.
Labels |
Added:
?
|
https://github.com/joomla/joomla-cms/blob/staging/tests/unit/suites/libraries/legacy/model/JModelListTest.php#L459
I think method getItems() return false
https://github.com/joomla/joomla-cms/blob/staging/tests/unit/suites/libraries/legacy/model/stubs/listmodeltest.php#L22 here was called parent method getListQuery(), what will call from() method here (https://github.com/joomdonation/joomla-cms/blob/cdbbc4633658f77feaf6408126414fdc77195530/libraries/joomla/database/query.php#L896) and second call from() here (https://github.com/joomla/joomla-cms/blob/staging/tests/unit/suites/libraries/legacy/model/stubs/listmodeltest.php#L25) will append table to the query.
Category | ⇒ | Libraries |
@test tested successfully, but im not sure if we should go that way.
Its nice to move all that repeating logic into a parent class, but modifying the getListQuery() method in JModelList and call all those sub-methods with table/component specific code feels not right to me.
@test tag list: Notice: Undefined property: stdClass::$access_title in ..joomla-cms/administrator/components/com_tags/views/tags/tmpl/default.php on line 212
JModelList: Line 839: $query->select('ag.title AS access_level') should be access_title
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-04-09 12:21:06 |
Hmm. System test failed. I don't have experience with this. Could anyone helps me have a look to see what I need to do to pass this test ?