From 1c191868de317f132879bb1bee5ddea29f57c798 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Thu, 17 Mar 2022 02:59:34 +0100 Subject: [PATCH] [ticket/12683] Undo changes in fulltext_sphinx.php PHPBB3-12683 --- .../phpbb/search/backend/fulltext_sphinx.php | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/phpBB/phpbb/search/backend/fulltext_sphinx.php b/phpBB/phpbb/search/backend/fulltext_sphinx.php index 8023bc161a..709690b4f2 100644 --- a/phpBB/phpbb/search/backend/fulltext_sphinx.php +++ b/phpBB/phpbb/search/backend/fulltext_sphinx.php @@ -631,24 +631,24 @@ class fulltext_sphinx implements search_backend_interface */ public function create_index(int &$post_counter = 0): ?array { - $table_data = array( - 'COLUMNS' => array( - 'counter_id' => array('UINT', 0), - 'max_doc_id' => array('UINT', 0), - ), - 'PRIMARY_KEY' => 'counter_id', - ); - $this->db_tools->sql_create_table(SPHINX_TABLE, $table_data); + if (!$this->index_created()) + { + $table_data = array( + 'COLUMNS' => array( + 'counter_id' => array('UINT', 0), + 'max_doc_id' => array('UINT', 0), + ), + 'PRIMARY_KEY' => 'counter_id', + ); + $this->db_tools->sql_create_table(SPHINX_TABLE, $table_data); - $sql = 'TRUNCATE TABLE ' . SPHINX_TABLE; - $this->db->sql_query($sql); - - $data = array( - 'counter_id' => '1', - 'max_doc_id' => '0', - ); - $sql = 'INSERT INTO ' . SPHINX_TABLE . ' ' . $this->db->sql_build_array('INSERT', $data); - $this->db->sql_query($sql); + $data = array( + 'counter_id' => '1', + 'max_doc_id' => '0', + ); + $sql = 'INSERT INTO ' . SPHINX_TABLE . ' ' . $this->db->sql_build_array('INSERT', $data); + $this->db->sql_query($sql); + } return null; } @@ -658,7 +658,10 @@ class fulltext_sphinx implements search_backend_interface */ public function delete_index(int &$post_counter = null): ?array { - $this->db_tools->sql_table_drop(SPHINX_TABLE); + if ($this->index_created()) + { + $this->db_tools->sql_table_drop(SPHINX_TABLE); + } return null; }