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

Fixes problem getting the number of search results #7910

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Sources/Actions/Search2.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ protected function __construct()
// Number of pages hard maximum - normally not set at all.
Config::$modSettings['search_max_results'] = empty(Config::$modSettings['search_max_results']) ? 200 * Config::$modSettings['search_results_per_page'] : (int) Config::$modSettings['search_max_results'];

if (isset($_REQUEST['start'])) {
$_REQUEST['start'] = (int) $_REQUEST['start'];
}
$_REQUEST['start'] = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] - ((int) $_REQUEST['start'] % Config::$modSettings['search_results_per_page']) : 0;

Lang::load('Search');

Expand Down
10 changes: 4 additions & 6 deletions Sources/Search/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function format(int $counter = 0, array $format_options = []): array
$colorClass .= ' locked';
}

$output = array_merge(SearchApi::$loadedApi->results[$this->id_msg], [
$output = array_merge(SearchApi::$loadedApi->results[$this->id], [
'id' => $this->id_topic,
'is_sticky' => !empty($this->is_sticky),
'is_locked' => !empty($this->locked),
Expand Down Expand Up @@ -521,12 +521,10 @@ public static function highlight(string $text, array $words): string
*/
public static function getNumResults(): int
{
// @todo Should this trigger an error instead?
if (!isset(self::$messages_request)) {
return 0;
}
// Initialize the generator in order to set self::$messages_request.
self::$getter->current();

return Db::$db->num_rows(self::$messages_request);
return Db::$db->num_rows(self::$messages_request) + (int) $_REQUEST['start'];
}

/**
Expand Down
Loading