From 32ceeaedb50b74a008116ec728658438e27fb573 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Thu, 16 Aug 2012 13:06:52 +0100 Subject: [PATCH 1/2] 2869 Fixes problem with invalid data being passed to solr. The feeds take a page number from the query string and use it to determine the start position in the list. Occassionally this is 0 and code around line 441 then decrement and then multiply this number, generating a start number less than 0 which solr chokes on. --- ckan/controllers/feed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckan/controllers/feed.py b/ckan/controllers/feed.py index c39ffcc3628..c54bb39b948 100644 --- a/ckan/controllers/feed.py +++ b/ckan/controllers/feed.py @@ -432,7 +432,7 @@ def _parse_url_params(self): """ try: - page = int(request.params.get('page', 1)) + page = int(request.params.get('page', 1)) or 1 except ValueError: abort(400, ('"page" parameter must be an integer')) From 0425e9caf785dd17fbc0b6af1092d4115cfab076 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Thu, 16 Aug 2012 13:26:35 +0100 Subject: [PATCH 2/2] Test for 2868 --- ckan/tests/functional/test_group.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ckan/tests/functional/test_group.py b/ckan/tests/functional/test_group.py index f4930961230..7bfc04aaadd 100644 --- a/ckan/tests/functional/test_group.py +++ b/ckan/tests/functional/test_group.py @@ -58,6 +58,20 @@ def setup_class(self): def teardown_class(self): model.repo.rebuild_db() + def test_atom_feed_page_zero(self): + group_name = 'deletetest' + CreateTestData.create_groups([{'name': group_name, + 'packages': []}], + admin_user_name='russianfan') + + offset = url_for(controller='feed', action='group', + id=group_name) + offset = offset + '?page=0' + res = self.app.get(offset) + assert '' in res, res + def test_children(self): if model.engine_is_sqlite() : from nose import SkipTest