Skip to content

Commit

Permalink
Fix search result links losing sid when e.g. sort is changed multiple…
Browse files Browse the repository at this point in the history
… times. (#3589)

saveToHistory wasn't being properly relayed when rendering the search results.
  • Loading branch information
EreMaijala committed Apr 16, 2024
1 parent a5a98a4 commit e58cbc6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions module/VuFind/src/VuFind/AjaxHandler/GetSearchResults.php
Expand Up @@ -241,6 +241,7 @@ protected function renderResults(ParamsHelper $requestParams, Results $results):
'showBulkOptions' => $showBulkOptions,
'showCartControls' => $showCartControls,
'showCheckboxes' => $showCheckboxes,
'saveToHistory' => (bool)$requestParams->fromQuery('history', false),
]
);
}
Expand Down
5 changes: 5 additions & 0 deletions module/VuFind/src/VuFindTest/Feature/SearchSortTrait.php
Expand Up @@ -80,6 +80,11 @@ protected function assertResultTitles(Element $page, int $count, string $first,
$this->assertCount($count, $titles);
$this->assertEquals($first, $titles[0]->getText());
$this->assertEquals($last, $titles[$count - 1]->getText());
// Check that record links contain sid parameter:
$url = $titles[0]->getAttribute('href');
parse_str(parse_url($url, PHP_URL_QUERY), $urlParams);
$this->assertArrayHasKey('sid', $urlParams);
$this->assertNotEmpty($urlParams['sid']);
}

/**
Expand Down
Expand Up @@ -99,6 +99,11 @@ public function testSortChange(): void
$this->assertResultTitles($page, 20, 'Test Publication 20177', 'Test Publication 201738');
// Check that url no longer contains the page parameter:
$this->assertStringNotContainsString('&page', $this->getCurrentQueryString());

// Change sort back to relevance (first option) and verify:
$this->clickCss($page, $this->sortControlSelector . ' option');
$this->waitForPageLoad($page);
$this->assertResultTitles($page, 20, 'Test Publication 20001', 'Test Publication 20020');
}

/**
Expand Down

0 comments on commit e58cbc6

Please sign in to comment.