mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 01:22:23 -04:00
Fix possible infinite loop when building ebook carousel
This commit is contained in:
parent
e6f74449a2
commit
98850bd475
1 changed files with 3 additions and 2 deletions
|
@ -23,7 +23,6 @@ try{
|
||||||
// Ensure the path exists and that the root is in our www directory
|
// Ensure the path exists and that the root is in our www directory
|
||||||
throw new Exceptions\InvalidEbookException();
|
throw new Exceptions\InvalidEbookException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Were we passed the author and a work but not the translator?
|
// Were we passed the author and a work but not the translator?
|
||||||
// For example:
|
// For example:
|
||||||
// https://standardebooks.org/ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam
|
// https://standardebooks.org/ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam
|
||||||
|
@ -85,7 +84,9 @@ try{
|
||||||
shuffle($ebooks);
|
shuffle($ebooks);
|
||||||
|
|
||||||
$targetCarouselSize = 5;
|
$targetCarouselSize = 5;
|
||||||
if(sizeof($ebooks) < $targetCarouselSize){
|
// Use <= here because we want to exclude the ebook we're looking at from the carousel.
|
||||||
|
// One of the matching ebooks will always be the current ebook.
|
||||||
|
if(sizeof($ebooks) <= $targetCarouselSize){
|
||||||
$targetCarouselSize = sizeof($ebooks) - 1;
|
$targetCarouselSize = sizeof($ebooks) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue