Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CoverController::getImageParams isbn array check #2800

Merged
merged 3 commits into from Mar 22, 2023

Conversation

LuomaJuha
Copy link
Contributor

@LuomaJuha LuomaJuha commented Mar 21, 2023

I think this was forgotten in #2633 but the parameters do not work properly when trying to fetch an image to show.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @LuomaJuha! I'm copying @xmorave2 into this thread in case he has any insights. I thought I had done end-to-end testing of this, but maybe I did something incorrectly or overlooked a detail. It certainly seems like you've found a gap in the code. I also have a couple of questions about implementation details (see below).

continue;
}
if (is_array($isbn)) {
$isbn = reset($isbn);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this reset necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you reduce the ISBNs to first one only? We probably want to pass all available ISBNs to cover loader.
So we want something like this instead:

$isbns = $params()->fromQuery($identification);
if (empty($isbns)) {
    continue;
}
if (!is_array($isbns)) {
    $isbns = [$isbns];
}

Copy link
Contributor Author

@LuomaJuha LuomaJuha Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it should convert them into an array as default. And keep all the array values.

return [
// Legacy support for "isn" param which has been superseded by isbn:
'isbn' => $params()->fromQuery('isbn') ?: $params()->fromQuery('isn'),
'isbn' => $isbn,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the VuFind\Cover\Loader is now expecting an 'isbns' key instead of singular 'isbn' in order to take advantage of multiple values. I wonder if 'isbns' => (array)$isbn would be the best way to approach this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we need isbns param instead of isbn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isbns it is now.

@demiankatz demiankatz added this to the 9.0 milestone Mar 21, 2023
Copy link
Contributor

@xmorave2 xmorave2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LuomaJuha for catching this! It's definitely a bug and my oversight from #2633.

continue;
}
if (is_array($isbn)) {
$isbn = reset($isbn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you reduce the ISBNs to first one only? We probably want to pass all available ISBNs to cover loader.
So we want something like this instead:

$isbns = $params()->fromQuery($identification);
if (empty($isbns)) {
    continue;
}
if (!is_array($isbns)) {
    $isbns = [$isbns];
}

return [
// Legacy support for "isn" param which has been superseded by isbn:
'isbn' => $params()->fromQuery('isbn') ?: $params()->fromQuery('isn'),
'isbn' => $isbn,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we need isbns param instead of isbn.

@LuomaJuha LuomaJuha requested review from demiankatz and xmorave2 and removed request for demiankatz March 22, 2023 07:27
Copy link
Contributor

@xmorave2 xmorave2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for quick update @LuomaJuha. I do some hand on testing using ObalkyKnih driver with ajax covers disabled and it is working fine.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks, @LuomaJuha and @xmorave2!

@demiankatz demiankatz merged commit f6eb1b0 into vufind-org:dev Mar 22, 2023
6 checks passed
@LuomaJuha LuomaJuha deleted the fix-covercontroller-image-params branch March 22, 2023 11:09
EreMaijala pushed a commit to EreMaijala/vufind that referenced this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants