{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/6677","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/6677/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/6677/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/6677/events","html_url":"https://github.com/joomla/joomla-cms/pull/6677","id":66583131,"number":6677,"title":"[fix] store JModelList filters as objects in session without relaying in Registry","user":{"login":"phproberto","id":1119272,"avatar_url":"https://avatars.githubusercontent.com/u/1119272?v=3","gravatar_id":"","url":"https://api.github.com/users/phproberto","html_url":"https://github.com/phproberto","followers_url":"https://api.github.com/users/phproberto/followers","following_url":"https://api.github.com/users/phproberto/following{/other_user}","gists_url":"https://api.github.com/users/phproberto/gists{/gist_id}","starred_url":"https://api.github.com/users/phproberto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phproberto/subscriptions","organizations_url":"https://api.github.com/users/phproberto/orgs","repos_url":"https://api.github.com/users/phproberto/repos","events_url":"https://api.github.com/users/phproberto/events{/privacy}","received_events_url":"https://api.github.com/users/phproberto/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/joomla/joomla-cms/labels/PR-staging","name":"PR-staging","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-06T11:12:23Z","updated_at":"2015-04-07T10:55:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/6677","html_url":"https://github.com/joomla/joomla-cms/pull/6677","diff_url":"https://github.com/joomla/joomla-cms/pull/6677.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/6677.patch"},"body":"This issue tries to fix issue https://github.com/joomla/joomla-cms/issues/6544 after updating Registry package to latest framework version.\r\n\r\nReplaces https://github.com/joomla/joomla-cms/pull/6548\r\n\r\n## A bit of history\r\n\r\nWhen I implemented searchtools (yes you can blame me :dancer: ) I stored filters in session as array and relayed in Registry to cast them to objects. After updating to the latest Registry package my modification was gone and searchtools started to experience conflicts between filters sent as objects (the old way) and filters sent as arrays (the new way). \r\n\r\nHaving reviewed and discussed about it I now see that I did it wrong forcing Registry to cast data to objects. The solution is to cast data in JModelList directly. But can we now do that without causing B/C issues with extensions already using searchtools? This what this pull request tries to test. Let's see if the best fix is still possible. If not we will need a B plan.\r\n\r\n## Backward compatibility issues\r\n\r\nAs you can see in the changes the best behavior `parent::populateState()` is called now on top of any model extending `JModelList` that way automatic filters can be overriden by custom filters. In the old implementation the `parent::populateState` was done the last thing to allow that any filter could initialize the object in session before any filter is stored. That was mainly to support old filtering systems (like the ones that Hathor uses).\r\n\r\nAfter searchtools was implemented extension developers should decide if you they going to use searchtools or not and based in that setup their model `populateState()` method.\r\n\r\nThe issue may now be that third part extensions have to move the `parent::populateState()` method inside their model `populateState()`. So **we need third part extensions using searchtools to HEAVILY test this**.\r\n\r\n## Why is this the best fix possible?\r\n\r\nBecause it now ensures that all the filters are stored in session in the same way (objects). Filters can be accessed & modified in the same way than before Searchtools was implemented (using objects). The idea is that JModelList automatically detects the filters allowing you to override them if needed. \r\n\r\n## How to test it\r\n\r\nGo to any of the current managements using Searchtools and ensure that filters work normally. This includes:\r\n\r\n* Creating more than 5 items per management to be able to test pagination\r\n* Set any filter and then test pagination ensuring that filters are kept and pagination works normally.\r\n* Reset filters should restore all the values and should redirect you to page 1 of search results.\r\n* Enable Hathor template and test that all the filters work there too. Thos filters are not using searchtools. Before you had to logout / login to get the filters working but now it should work correctly.\r\n\r\nManagements to test:\r\n\r\n* com_banners > Banner list\r\n* com_banners > Client list\r\n* com_content > Category list\r\n* com_content > Article list\r\n* com_content > Featured articles list\r\n* com_menus > Item list\r\n\r\n## Test by third part extensions\r\n\r\n* Install your extension in a joomla that includes this patch and test that your filters work normally.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/90506293","html_url":"https://github.com/joomla/joomla-cms/pull/6677#issuecomment-90506293","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/6677","id":90506293,"user":{"login":"phproberto","id":1119272,"avatar_url":"https://avatars.githubusercontent.com/u/1119272?v=3","gravatar_id":"","url":"https://api.github.com/users/phproberto","html_url":"https://github.com/phproberto","followers_url":"https://api.github.com/users/phproberto/followers","following_url":"https://api.github.com/users/phproberto/following{/other_user}","gists_url":"https://api.github.com/users/phproberto/gists{/gist_id}","starred_url":"https://api.github.com/users/phproberto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phproberto/subscriptions","organizations_url":"https://api.github.com/users/phproberto/orgs","repos_url":"https://api.github.com/users/phproberto/repos","events_url":"https://api.github.com/users/phproberto/events{/privacy}","received_events_url":"https://api.github.com/users/phproberto/received_events","type":"User","site_admin":false},"created_at":"2015-04-07T10:55:06Z","updated_at":"2015-04-07T10:55:06Z","body":"About tests I cannot get the errors locally so I think I need some help with that :(\r\n\r\nThe main issue is that now filters & list options from searchtools are not using `$app->getUserStateFromRequest()` but `JModelList::getFilterStateFromRequest()` so I think the tests need to be changed to test that. \r\n\r\nThis is what I get when running unit tests:\r\n\r\n```php\r\n$ phpunit --testsuite libraries-legacy\r\nPHPUnit 4.6.1 by Sebastian Bergmann and contributors.\r\n\r\nConfiguration read from /home/roberto/www/jcms3x/phpunit.xml\r\n\r\nThe Xdebug extension is not loaded. No code coverage will be generated.\r\n\r\n....S.....................................SSSSSSSSSSSSSSSSSSSSS  63 / 140 ( 45%)\r\nSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS....SSS.. 126 / 140 ( 90%)\r\n..............\r\n\r\nTime: 268 ms, Memory: 23.50Mb\r\n\r\nOK, but incomplete, skipped, or risky tests!\r\nTests: 140, Assertions: 146, Skipped: 79.\r\n```"}}