mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/16738] Multiple changes
Add post helper to get last post id Launch exception if an action is in progress Launch an exception if the action is already done When listing search backend in cli, if the active backend is not indexed an error is launched Add state to commands Fix small error in sphinx search backend PHPBB3-16738
This commit is contained in:
@@ -16,6 +16,8 @@ namespace phpbb\search\backend;
|
||||
use phpbb\cache\service;
|
||||
use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\search\exception\index_created_exception;
|
||||
use phpbb\search\exception\index_empty_exception;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
@@ -323,6 +325,11 @@ abstract class base implements search_backend_interface
|
||||
*/
|
||||
public function create_index(int &$post_counter = 0): ?array
|
||||
{
|
||||
if ($this->index_created())
|
||||
{
|
||||
throw new index_created_exception();
|
||||
}
|
||||
|
||||
$max_post_id = $this->get_max_post_id();
|
||||
$forums_indexing_enabled = $this->forum_ids_with_indexing_enabled();
|
||||
|
||||
@@ -385,6 +392,11 @@ abstract class base implements search_backend_interface
|
||||
*/
|
||||
public function delete_index(int &$post_counter = null): ?array
|
||||
{
|
||||
if (!$this->index_created())
|
||||
{
|
||||
throw new index_empty_exception();
|
||||
}
|
||||
|
||||
$max_post_id = $this->get_max_post_id();
|
||||
|
||||
$starttime = microtime(true);
|
||||
|
@@ -17,6 +17,8 @@ use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\search\exception\index_created_exception;
|
||||
use phpbb\search\exception\index_empty_exception;
|
||||
use phpbb\user;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -913,6 +915,11 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||
*/
|
||||
public function create_index(int &$post_counter = 0): ?array
|
||||
{
|
||||
if ($this->index_created())
|
||||
{
|
||||
throw new index_created_exception();
|
||||
}
|
||||
|
||||
// Make sure we can actually use MySQL with fulltext indexes
|
||||
if ($error = $this->init())
|
||||
{
|
||||
@@ -985,6 +992,11 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||
*/
|
||||
public function delete_index(int &$post_counter = null): ?array
|
||||
{
|
||||
if (!$this->index_created())
|
||||
{
|
||||
throw new index_empty_exception();
|
||||
}
|
||||
|
||||
// Make sure we can actually use MySQL with fulltext indexes
|
||||
if ($error = $this->init())
|
||||
{
|
||||
|
@@ -17,6 +17,7 @@ use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\search\exception\index_empty_exception;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
@@ -1598,6 +1599,11 @@ class fulltext_native extends base implements search_backend_interface
|
||||
*/
|
||||
public function delete_index(int &$post_counter = null): ?array
|
||||
{
|
||||
if (!$this->index_created())
|
||||
{
|
||||
throw new index_empty_exception();
|
||||
}
|
||||
|
||||
$sql_queries = [];
|
||||
|
||||
switch ($this->db->get_sql_layer())
|
||||
|
@@ -17,6 +17,8 @@ use phpbb\config\config;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\search\exception\index_created_exception;
|
||||
use phpbb\search\exception\index_empty_exception;
|
||||
use phpbb\user;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -868,6 +870,11 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||
*/
|
||||
public function create_index(int &$post_counter = 0): ?array
|
||||
{
|
||||
if ($this->index_created())
|
||||
{
|
||||
throw new index_created_exception();
|
||||
}
|
||||
|
||||
// Make sure we can actually use PostgreSQL with fulltext indexes
|
||||
if ($error = $this->init())
|
||||
{
|
||||
@@ -927,6 +934,11 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||
*/
|
||||
public function delete_index(int &$post_counter = null): ?array
|
||||
{
|
||||
if (!$this->index_created())
|
||||
{
|
||||
throw new index_empty_exception();
|
||||
}
|
||||
|
||||
// Make sure we can actually use PostgreSQL with fulltext indexes
|
||||
if ($error = $this->init())
|
||||
{
|
||||
|
@@ -20,6 +20,7 @@ use phpbb\db\tools\tools_interface;
|
||||
use phpbb\event\dispatcher_interface;
|
||||
use phpbb\language\language;
|
||||
use phpbb\log\log;
|
||||
use phpbb\search\exception\index_empty_exception;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
@@ -633,23 +634,28 @@ class fulltext_sphinx implements search_backend_interface
|
||||
{
|
||||
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);
|
||||
|
||||
$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);
|
||||
throw new index_empty_exception();
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -658,11 +664,13 @@ class fulltext_sphinx implements search_backend_interface
|
||||
*/
|
||||
public function delete_index(int &$post_counter = null): ?array
|
||||
{
|
||||
if ($this->index_created())
|
||||
if (!$this->index_created())
|
||||
{
|
||||
$this->db_tools->sql_table_drop(SPHINX_TABLE);
|
||||
throw new index_empty_exception();
|
||||
}
|
||||
|
||||
$this->db_tools->sql_table_drop(SPHINX_TABLE);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user