Skip to content
Snippets Groups Projects
Commit 9c4c4a42 authored by Demian Katz's avatar Demian Katz
Browse files

Bug fix: reset page number when switching library cards.

- Prevents fatal error when switching from a deep page of checked out items to an account that has fewer pages of results.
parent 64f401a9
No related merge requests found
......@@ -178,6 +178,21 @@ class LibraryCardsController extends AbstractBase
);
}
/**
* When redirecting after selecting a library card, adjust the URL to make
* sure it will work correctly.
*
* @param string $url URL to adjust
*
* @return string
*/
protected function adjustCardRedirectUrl($url)
{
// If there is pagination in the URL, reset it to page 1, since the
// new card may have a different number of pages of data:
return preg_replace('/([&?]page)=[0-9]+/', '$1=1', $url);
}
/**
* Activates a library card
*
......@@ -215,7 +230,7 @@ class LibraryCardsController extends AbstractBase
$this->setFollowupUrlToReferer();
if ($url = $this->getFollowupUrl()) {
$this->clearFollowupUrl();
return $this->redirect()->toUrl($url);
return $this->redirect()->toUrl($this->adjustCardRedirectUrl($url));
}
return $this->redirect()->toRoute('myresearch-home');
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment