From 002c7596ea08c2db03ab8045d9429d7717664293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Sat, 7 Dec 2013 21:17:38 +0100 Subject: [PATCH] Changing the number of book per pages changed the search with multiple database. Reported by At-Libitum. fix #124 --- base.php | 2 +- book.php | 4 ++-- test/pageMultidatabaseTest.php | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/base.php b/base.php index 25f7a10..0d11286 100644 --- a/base.php +++ b/base.php @@ -752,7 +752,7 @@ class PageQueryResult extends Page $i = 0; foreach ($config['calibre_directory'] as $key => $value) { Base::clearDb (); - list ($array, $totalNumber) = Book::getBooksByQuery (array ($crit, $crit, $crit, $crit), $this->n, $i); + list ($array, $totalNumber) = Book::getBooksByQuery (array ($crit, $crit, $crit, $crit), 1, $i, 1); array_push ($this->entryArray, new Entry ($key, DB . ":query:{$i}", str_format (localize ("bookword", count($array)), count($array)), "text", array ( new LinkNavigation ("?" . DB . "={$i}&page=9&query=" . $this->query)))); diff --git a/book.php b/book.php index 271dfda..5d59ae2 100644 --- a/book.php +++ b/book.php @@ -553,8 +553,8 @@ where data.book = books.id and data.id = ?'); return NULL; } - public static function getBooksByQuery($query, $n, $database = NULL) { - return self::getEntryArray (self::SQL_BOOKS_QUERY, $query, $n, $database); + public static function getBooksByQuery($query, $n, $database = NULL, $numberPerPage = NULL) { + return self::getEntryArray (self::SQL_BOOKS_QUERY, $query, $n, $database, $numberPerPage); } public static function getBooks($n) { diff --git a/test/pageMultidatabaseTest.php b/test/pageMultidatabaseTest.php index cf373f9..94ee0b7 100644 --- a/test/pageMultidatabaseTest.php +++ b/test/pageMultidatabaseTest.php @@ -43,6 +43,21 @@ class PageMultiDatabaseTest extends PHPUnit_Framework_TestCase $qid = NULL; $n = "1"; + // Issue 124 + $config['cops_max_item_per_page'] = 2; + $currentPage = Page::getPage ($page, $qid, $query, $n); + $currentPage->InitializeContent (); + + + $this->assertEquals ("Search result for *art*", $currentPage->title); + $this->assertCount (2, $currentPage->entryArray); + $this->assertEquals ("Some books", $currentPage->entryArray [0]->title); + $this->assertEquals ("10 books", $currentPage->entryArray [0]->content); + $this->assertEquals ("One book", $currentPage->entryArray [1]->title); + $this->assertEquals ("1 book", $currentPage->entryArray [1]->content); + $this->assertFalse ($currentPage->ContainsBook ()); + + $config['cops_max_item_per_page'] = -1; $currentPage = Page::getPage ($page, $qid, $query, $n); $currentPage->InitializeContent ();