diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 782559bec2..5d4c775895 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -137,15 +137,16 @@
[Fix] Enforce correct case for template variables
[Fix] Set topic_last_view_time on post/reply/edit to circumvent race conditions in auto prune and false removal of topics for manual forum prune (Bug #18055, #43515)
[Fix] Correctly split long subject lines according to the used RFC. This fixes extra spaces within long subjects. (Bug #43715)
- [Change] Allow download of conflicting file for later reference in automatic updater
[Change] Default difference view is now 'inline' instead of 'side by side'
[Change] Added new option for merging differences to conflicting files in automatic updater
- [Change] Added new options for visual confirmation.
[Change] Add link to user profile in the MCP for user notes and warn user.
[Change] Add IN_PHPBB check to generated cache files. (reported by bantu)
[Change] Add topic icons to prosilver UCP main and subscribed templates (Bug #42735 - Patch by Raimon)
[Change] Add unique key to ACL options table to prevent duplicate permission options. (Bug #41835)
[Change] Redirect to relevant MCP page of multi-page topic if accessing quickmod tools (Split option for example)
+ [Change] Performance improvements for native fulltext search (patch by Paul)
+ [Feature] Added new options for visual confirmation.
+ [Feature] Allow download of conflicting file for later reference in automatic updater
[Feature] Allow translation of custom BBCode help messages. (Patch by bantu)
[Feature] db_tools now support create table and drop table.
[Feature] Database updater checks for incompatible db schema (MySQL 3.x/4.x against MySQL 4.1.x/5.x/6.x)
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index ee36039454..5a9f34a261 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -650,8 +650,12 @@ class fulltext_native extends search_backend
case 'mysql4':
case 'mysqli':
+ $sql_array_copy = $sql_array;
+
// 3.x does not support SQL_CALC_FOUND_ROWS
- $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT'];
+ // $sql_array['SELECT'] = 'SQL_CALC_FOUND_ROWS ' . $sql_array['SELECT'];
+ $sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id ';
+
$is_mysql = true;
break;
@@ -730,8 +734,14 @@ class fulltext_native extends search_backend
}
// if we use mysql and the total result count is not cached yet, retrieve it from the db
- if (!$total_results && $is_mysql)
+ if (!$total_results && $is_mysql && !empty($sql_array_copy))
{
+ $sql = $db->sql_build_query('SELECT', $sql_array_copy);
+ unset($sql_array_copy);
+
+ $db->sql_query($sql);
+ $db->sql_freeresult($result);
+
$sql = 'SELECT FOUND_ROWS() as total_results';
$result = $db->sql_query($sql);
$total_results = (int) $db->sql_fetchfield('total_results');
@@ -855,7 +865,7 @@ class fulltext_native extends search_backend
{
case 'mysql4':
case 'mysqli':
- $select = 'SQL_CALC_FOUND_ROWS ' . $select;
+// $select = 'SQL_CALC_FOUND_ROWS ' . $select;
$is_mysql = true;
break;
@@ -948,6 +958,12 @@ class fulltext_native extends search_backend
if (!$total_results && $is_mysql)
{
+ // Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
+ $sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql);
+
+ $db->sql_query($sql);
+ $db->sql_freeresult($result);
+
$sql = 'SELECT FOUND_ROWS() as total_results';
$result = $db->sql_query($sql);
$total_results = (int) $db->sql_fetchfield('total_results');