? Success

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
2 Mar 2015

Problem to solve

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

How to test

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

Possible issue with this PR

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.

avatar joomdonation joomdonation - open - 2 Mar 2015
avatar joomla-cms-bot joomla-cms-bot - change - 2 Mar 2015
Labels Added: ?
avatar joomdonation
joomdonation - comment - 2 Mar 2015

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 ?

avatar joomdonation
joomdonation - comment - 2 Mar 2015

Thanks @jackkum for assist. Yes, I found out that was the reason of the error and got it corrected with previous changes :).

avatar zero-24 zero-24 - change - 2 Mar 2015
Category Libraries
avatar dneukirchen
dneukirchen - comment - 14 Mar 2015

@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.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6251.
avatar dneukirchen dneukirchen - test_item - 14 Mar 2015 - Tested successfully
avatar dneukirchen
dneukirchen - comment - 14 Mar 2015

@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


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6251.
avatar dneukirchen dneukirchen - test_item - 14 Mar 2015 - Tested unsuccessfully
avatar joomdonation joomdonation - close - 9 Apr 2015
avatar joomdonation joomdonation - change - 9 Apr 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-04-09 12:21:06
avatar joomdonation joomdonation - close - 9 Apr 2015
avatar joomdonation joomdonation - head_ref_deleted - 19 Dec 2015

Add a Comment

Login with GitHub to post a comment