diff --git a/VERSIONS_HOTLINE/163882 b/VERSIONS_HOTLINE/163882 new file mode 100644 index 0000000000000000000000000000000000000000..db2431b39c8cc4baf59748a8c204668154dc5ef4 --- /dev/null +++ b/VERSIONS_HOTLINE/163882 @@ -0,0 +1 @@ + - ticket#163882 : [MT] Recherche : Quand certains utilisateurs avec un nombre de notices par pages non numérique, page blanche. \ No newline at end of file diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 7db0d071bac059a5c22cdb542247bdb464db4ff6..d8b5dc30b78a39886d2c91ac95b143392e6ff94c 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -1008,8 +1008,8 @@ class Class_CriteresRecherche extends Class_CriteresRecherche_Abstract { } - public function getPageSize() { - if ($size = $this->getParam('page_size')) + public function getPageSize() : int { + if ($size = (int) $this->getParam('page_size')) return $size; if ($user_page_size = (new Class_User_Settings(Class_Users::getIdentity()))->getSearchPageSize()) diff --git a/library/Class/CriteresRecherche/Abstract.php b/library/Class/CriteresRecherche/Abstract.php index 3f1288a066c65677e5baea192910b9775e872be2..2afa02fad302b67043686c95281993ebd3446880 100644 --- a/library/Class/CriteresRecherche/Abstract.php +++ b/library/Class/CriteresRecherche/Abstract.php @@ -163,8 +163,8 @@ abstract class Class_CriteresRecherche_Abstract { } - public function getPageSize() { - return $this->getParam('page_size', + public function getPageSize() : int { + return (int) $this->getParam('page_size', $this->_default_page_size); } diff --git a/library/Class/MoteurRecherche/Result.php b/library/Class/MoteurRecherche/Result.php index af4912deb2fbbbe702b696871e6f7cf350d5e08a..1776d975ab99b7e1cceaa0020840b057242e9577 100644 --- a/library/Class/MoteurRecherche/Result.php +++ b/library/Class/MoteurRecherche/Result.php @@ -238,7 +238,7 @@ class Class_MoteurRecherche_Result { } - public function getRecordsCount() { + public function getRecordsCount() : int { return count($this->fetchAllRecordsIds()); } @@ -315,7 +315,7 @@ class Class_MoteurRecherche_ResultWork extends Class_MoteurRecherche_Result { } - public function getRecordsCount() { + public function getRecordsCount() : int { $this->fetchAllRecordsIds(); return count($this->_works); } diff --git a/library/Class/User/Settings.php b/library/Class/User/Settings.php index 41d351e73f84f41c58863e7dab42236e1c9ca9e7..df17ad20d6988a76aae40bb9d3ec52c25e096122 100644 --- a/library/Class/User/Settings.php +++ b/library/Class/User/Settings.php @@ -288,7 +288,7 @@ class Class_User_Settings { protected function _saveUserWithLib($id) : self { - if ($id === $this->get(Class_User_Setting::BOOKMARKED_LIBRARIES)) + if ((int) $id === (int) $this->get(Class_User_Setting::BOOKMARKED_LIBRARIES)) return $this; $this->set(Class_User_Setting::BOOKMARKED_LIBRARIES, [$id]); @@ -364,12 +364,12 @@ class Class_User_Settings { } - public function getSearchPageSize() { - return $this->get(Class_User_Setting::SEARCH_PAGE_SIZE); + public function getSearchPageSize() : int { + return (int) $this->get(Class_User_Setting::SEARCH_PAGE_SIZE); } - public function setSearchPageSize($size) { + public function setSearchPageSize(int $size) { return $this->set(Class_User_Setting::SEARCH_PAGE_SIZE, $size); } diff --git a/tests/scenarios/Templates/TemplatesUserSettingsTest.php b/tests/scenarios/Templates/TemplatesUserSettingsTest.php index 01eeba821b07bae1f63696b74f0b73b719193fa0..280fc65842372fd013b82cddb23ef6bff73c5434 100644 --- a/tests/scenarios/Templates/TemplatesUserSettingsTest.php +++ b/tests/scenarios/Templates/TemplatesUserSettingsTest.php @@ -1,4 +1,4 @@ -<?php +><?php /** * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. * @@ -370,3 +370,36 @@ class TemplatesUserSettingsSearchSaveChiliAndDomainBDAndWidgetDomainTest extends Zend_Registry::get('sql')->getFirstAttributeForLastCallOn('fetchAll')); } } + + + + +class TemplateUserSettingsWithCorruptedDataTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + $this->_buildTemplateProfil(['id' => 1]); + + $john = $this->fixture(Class_Users::class, + ['id' => 5, + 'login' => 'John', + 'password' => 'motdepasse', + 'settings' => 'a:5:{s:11:"library_ids";s:0:"";s:12:"search_order";s:35:"date_creation desc, alpha_titre asc";s:13:"search_layout";s:1:"3";s:16:"search_page_size";s:12:"kreversi.png";s:13:"profile_image";s:41:"public/opac/images/abonnes/read_black.png";}' + ]); + ZendAfi_Auth::getInstance()->logUser($john); + + $this->fixture(Class_Notice::class, + ['id' => 1]); + + Zend_Registry::set('sql', $this->mock() + ->whenCalled('fetchAll') + ->answers([[1,'']])); + + $this->dispatch('/recherche/pomme'); + } + + + /** @test */ + public function pageSizeShouldBeTen() { + $this->assertXPathContentContains('//div[@class="selector_widget"]//form//select[contains(@onchange, "page_size/\'+value")]/option[@value=10][@selected]', '10'); + } +}