Use getState instead of direct property read#10435
Conversation
Use getState instead of direct property read to avoid any undefined property warnings.
|
@izharaazmi you have unit test errors. |
|
@andrepereiradasilva yeah, I'm looking at that. Apparently that is the issue with the test definition. But can't say it yet. |
We're setting state manually for this test case. But since the flag is not set the populateState will be called and it will overwrite them.
|
@Devportobello you have to mark as tested in the issue tracker (https://issues.joomla.org/tracker/joomla-cms/10435 login with github and mark test as success). |
|
I have tested this item ✅ successfully on 45a6d09 But for what is worth, if you exchange the order the filters/ordering/search (aka searchtols) will not work properly. With or without this PR. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10435. |
|
I have tested this item ✅ successfully on 45a6d09 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10435. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10435. |
@andrepereiradasilva Can you please explain this. |
|
Note this happens with or without your PR. For instance, change the order of the $this->filterForm = $this->get('FilterForm'); // PUT THIS ONE ON TOP
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->authors = $this->get('Authors');
$this->activeFilters = $this->get('ActiveFilters');Now try to use the searchtools in articles view. search for something, order or filter by something. |
|
@andrepereiradasilva The solution is straightforward. Use But that is not all. Therefore instead of a placing a PR, I'd prefer a little discussion regarding |
|
ok then create a issue / RFC |
|
Thanks everybody |
Pull Request for Issue #10416.
Summary of Changes
Use getState instead of direct property read in JModelList to avoid any undefined property warnings.
Using
$this->getStateagainst$this->state->getensures the model state is populated appropriately.Testing Instructions
ContentViewArticlesatadministrator/components/com_content/views/articles/view.html.phpin the display method call$this->get('FilterForm');before$this->get('State')or$this->get('Items')etc.Expected: Everything should work correctly.
Actual: You see 4 php notices such as
Notice: Undefined property: JObject::$list....Fixes #10416