From 35b01eaa184e8e42a7984072677d006eb2d5d6fa Mon Sep 17 00:00:00 2001 From: Patrick Barroca <pbarroca@afi-sa.fr> Date: Thu, 3 Feb 2022 14:54:16 +0100 Subject: [PATCH] hotline #147804 : fix regression --- .../opac/controllers/RechercheController.php | 20 ++++++++++++++++--- .../Templates/TemplatesUserSettingsTest.php | 5 +++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/application/modules/opac/controllers/RechercheController.php b/application/modules/opac/controllers/RechercheController.php index befd0ac9226..b61320222d9 100644 --- a/application/modules/opac/controllers/RechercheController.php +++ b/application/modules/opac/controllers/RechercheController.php @@ -153,13 +153,27 @@ class RechercheController extends ZendAfi_Controller_Action { return $this; $settings = new Class_User_Settings($user); - - if ( $this->_getParam('save_user_settings', null)) { + if ($this->_getParam('save_user_settings', null)) { + $this->_saveOrderParam($settings, $criteria); $settings - ->setSearchOrder($criteria->getTri()) ->setSearchLayout($criteria->getFormat()) ->setSearchPageSize($criteria->getPageSize()) ->save(); + + return $this; + } + + if ($tri = $settings->getSearchOrder()) + $criteria->setParam('tri', $tri); + + return $this; + } + + + protected function _saveOrderParam(Class_User_Settings $settings, + Class_CriteresRecherche $criteria) : self { + if ($tri = $criteria->getParam('tri')) { + $settings->setSearchOrder($tri); return $this; } diff --git a/tests/scenarios/Templates/TemplatesUserSettingsTest.php b/tests/scenarios/Templates/TemplatesUserSettingsTest.php index bcc2a9d3b9c..a5e98e47217 100644 --- a/tests/scenarios/Templates/TemplatesUserSettingsTest.php +++ b/tests/scenarios/Templates/TemplatesUserSettingsTest.php @@ -217,7 +217,7 @@ class TemplatesUserSettingsSearchSaveChiliAndSearchOrderTest extends TemplatesUs /** @test */ - public function searchWithSaveUserSettingsAndNoOrderShouldUseAlphaTitreTest() { + public function searchWithSaveUserSettingsAndNoOrderShouldUseAlphaTitreAsc() { $this->dispatch('/recherche/simple/save_user_settings/1'); $this->assertXPath('//div//select/option[@selected][@value="alpha_titre asc"]'); } @@ -226,7 +226,8 @@ class TemplatesUserSettingsSearchSaveChiliAndSearchOrderTest extends TemplatesUs /** @test */ public function userSearchOrderShouldBeAlphaTitreAsc() { $this->dispatch('/recherche/simple/save_user_settings/1'); - $this->assertEquals('alpha_titre asc', (new Class_User_Settings(Class_Users::getIdentity()))->getSearchOrder()); + $this->assertEquals('alpha_titre asc', + (new Class_User_Settings(Class_Users::getIdentity()))->getSearchOrder()); } } -- GitLab