mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/15540] Add types
PHPBB3-15540
This commit is contained in:
parent
a8de540e93
commit
658a0489d0
12 changed files with 140 additions and 133 deletions
|
@ -283,6 +283,7 @@ class acp_search
|
||||||
case 'delete':
|
case 'delete':
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$this->state[2] = $this->state[2] ?? 0;
|
||||||
if ($status = $this->search->delete_index($this->state[2])) // Status is not null, so deleting is in progress....
|
if ($status = $this->search->delete_index($this->state[2])) // Status is not null, so deleting is in progress....
|
||||||
{
|
{
|
||||||
// save the current state
|
// save the current state
|
||||||
|
@ -312,6 +313,7 @@ class acp_search
|
||||||
case 'create':
|
case 'create':
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$this->state[2] = $this->state[2] ?? 0;
|
||||||
if ($status = $this->search->create_index($this->state[2])) // Status is not null, so indexing is in progress....
|
if ($status = $this->search->create_index($this->state[2])) // Status is not null, so indexing is in progress....
|
||||||
{
|
{
|
||||||
// save the current state
|
// save the current state
|
||||||
|
|
|
@ -1634,7 +1634,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
|
||||||
|
|
||||||
// Collect some basic information about which tables and which rows to update/insert
|
// Collect some basic information about which tables and which rows to update/insert
|
||||||
$sql_data = array();
|
$sql_data = array();
|
||||||
$poster_id = ($mode == 'edit') ? $data_ary['poster_id'] : (int) $user->data['user_id'];
|
$poster_id = ($mode == 'edit') ? (int) $data_ary['poster_id'] : (int) $user->data['user_id'];
|
||||||
|
|
||||||
// Retrieve some additional information if not present
|
// Retrieve some additional information if not present
|
||||||
if ($mode == 'edit' && (!isset($data_ary['post_visibility']) || !isset($data_ary['topic_visibility']) || $data_ary['post_visibility'] === false || $data_ary['topic_visibility'] === false))
|
if ($mode == 'edit' && (!isset($data_ary['post_visibility']) || !isset($data_ary['topic_visibility']) || $data_ary['post_visibility'] === false || $data_ary['topic_visibility'] === false))
|
||||||
|
@ -2215,7 +2215,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
|
||||||
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'";
|
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'";
|
||||||
|
|
||||||
// Maybe not only the subject, but also changing anonymous usernames. ;)
|
// Maybe not only the subject, but also changing anonymous usernames. ;)
|
||||||
if ($data_ary['poster_id'] == ANONYMOUS)
|
if ((int) $data_ary['poster_id'] == ANONYMOUS)
|
||||||
{
|
{
|
||||||
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'";
|
$sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'";
|
||||||
}
|
}
|
||||||
|
@ -2232,7 +2232,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
// this post is the latest post in the forum, better update
|
// this post is the latest post in the forum, better update
|
||||||
if ($row['forum_last_post_id'] == $data_ary['post_id'] && ($row['forum_last_post_subject'] !== $subject || $data_ary['poster_id'] == ANONYMOUS))
|
if ($row['forum_last_post_id'] == $data_ary['post_id'] && ($row['forum_last_post_subject'] !== $subject || (int) $data_ary['poster_id'] == ANONYMOUS))
|
||||||
{
|
{
|
||||||
// the post's subject changed
|
// the post's subject changed
|
||||||
if ($row['forum_last_post_subject'] !== $subject)
|
if ($row['forum_last_post_subject'] !== $subject)
|
||||||
|
@ -2241,7 +2241,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the user name if poster is anonymous... just in case a moderator changed it
|
// Update the user name if poster is anonymous... just in case a moderator changed it
|
||||||
if ($data_ary['poster_id'] == ANONYMOUS)
|
if ((int) $data_ary['poster_id'] == ANONYMOUS)
|
||||||
{
|
{
|
||||||
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'";
|
$sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'";
|
||||||
}
|
}
|
||||||
|
@ -2308,11 +2308,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$search->index($mode, $data_ary['post_id'], $data_ary['message'], $subject, $poster_id, $data_ary['forum_id']);
|
$search->index($mode, (int) $data_ary['post_id'], $data_ary['message'], $subject, $poster_id, (int) $data_ary['forum_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Topic Notification, do not change if moderator is changing other users posts...
|
// Topic Notification, do not change if moderator is changing other users posts...
|
||||||
if ($user->data['user_id'] == $poster_id)
|
if ((int) $user->data['user_id'] == $poster_id)
|
||||||
{
|
{
|
||||||
if (!$data_ary['notify_set'] && $data_ary['notify'])
|
if (!$data_ary['notify_set'] && $data_ary['notify'])
|
||||||
{
|
{
|
||||||
|
|
|
@ -1566,7 +1566,7 @@ function mcp_fork_topic($topic_ids)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
$db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
||||||
$new_post_id = $db->sql_nextid();
|
$new_post_id = (int) $db->sql_nextid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform actions after forked topic is created.
|
* Perform actions after forked topic is created.
|
||||||
|
@ -1605,7 +1605,7 @@ function mcp_fork_topic($topic_ids)
|
||||||
|
|
||||||
if (!empty($search))
|
if (!empty($search))
|
||||||
{
|
{
|
||||||
$search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id);
|
$search->index($search_mode, $new_post_id, $sql_ary['post_text'], $sql_ary['post_subject'], (int) $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id);
|
||||||
$search_mode = 'reply'; // After one we index replies
|
$search_mode = 'reply'; // After one we index replies
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -642,7 +642,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$search->index('edit', $first_post_data['post_id'], $first_post_data['post_text'], $subject, $first_post_data['poster_id'], $first_post_data['forum_id']);
|
$search->index('edit', (int) $first_post_data['post_id'], $first_post_data['post_text'], $subject, (int) $first_post_data['poster_id'], (int) $first_post_data['forum_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy topic subscriptions to new topic
|
// Copy topic subscriptions to new topic
|
||||||
|
|
|
@ -169,11 +169,11 @@ class create_search_index extends database_task
|
||||||
{
|
{
|
||||||
$this->search_indexer->index(
|
$this->search_indexer->index(
|
||||||
'post',
|
'post',
|
||||||
$value['post_id'],
|
(int) $value['post_id'],
|
||||||
$value['post_text'],
|
$value['post_text'],
|
||||||
$value['post_subject'],
|
$value['post_subject'],
|
||||||
$value['poster_id'],
|
(int) $value['poster_id'],
|
||||||
$value['forum_id']
|
(int) $value['forum_id']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -321,7 +321,7 @@ abstract class base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function create_index(int &$post_counter = null): ?array
|
public function create_index(int &$post_counter = 0): ?array
|
||||||
{
|
{
|
||||||
$max_post_id = $this->get_max_post_id();
|
$max_post_id = $this->get_max_post_id();
|
||||||
$forums_indexing_enabled = $this->forum_ids_with_indexing_enabled();
|
$forums_indexing_enabled = $this->forum_ids_with_indexing_enabled();
|
||||||
|
@ -343,7 +343,7 @@ abstract class base implements search_backend_interface
|
||||||
// Indexing enabled for this forum
|
// Indexing enabled for this forum
|
||||||
if (in_array($row['forum_id'], $forums_indexing_enabled, true))
|
if (in_array($row['forum_id'], $forums_indexing_enabled, true))
|
||||||
{
|
{
|
||||||
$this->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
|
$this->index('post', (int) $row['post_id'], $row['post_text'], $row['post_subject'], (int) $row['poster_id'], (int) $row['forum_id']);
|
||||||
}
|
}
|
||||||
$row_count++;
|
$row_count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_word_length(): array
|
public function get_word_length()
|
||||||
{
|
{
|
||||||
return $this->word_length;
|
return $this->word_length;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function split_keywords(&$keywords, $terms): bool
|
public function split_keywords(string &$keywords, string $terms): bool
|
||||||
{
|
{
|
||||||
if ($terms == 'all')
|
if ($terms == 'all')
|
||||||
{
|
{
|
||||||
|
@ -342,7 +342,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function keyword_search(string $type, string $fields, string $terms, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
// No keywords? No posts
|
// No keywords? No posts
|
||||||
if (!$this->search_query)
|
if (!$this->search_query)
|
||||||
|
@ -590,7 +590,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function author_search(string $type, bool $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
// No author? No posts
|
// No author? No posts
|
||||||
if (!count($author_ary))
|
if (!count($author_ary))
|
||||||
|
@ -844,7 +844,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
|
public function index(string $mode, int $post_id, string &$message, string &$subject, int $poster_id, int $forum_id)
|
||||||
{
|
{
|
||||||
// Split old and new post/subject to obtain array of words
|
// Split old and new post/subject to obtain array of words
|
||||||
$split_text = $this->split_message($message);
|
$split_text = $this->split_message($message);
|
||||||
|
@ -892,7 +892,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index_remove($post_ids, $author_ids, $forum_ids)
|
public function index_remove(array $post_ids, array $author_ids, array $forum_ids): void
|
||||||
{
|
{
|
||||||
$this->destroy_cache([], array_unique($author_ids));
|
$this->destroy_cache([], array_unique($author_ids));
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function tidy()
|
public function tidy(): void
|
||||||
{
|
{
|
||||||
// destroy too old cached search results
|
// destroy too old cached search results
|
||||||
$this->destroy_cache([]);
|
$this->destroy_cache([]);
|
||||||
|
@ -911,7 +911,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function create_index(int &$post_counter = null): ?array
|
public function create_index(int &$post_counter = 0): ?array
|
||||||
{
|
{
|
||||||
// Make sure we can actually use MySQL with fulltext indexes
|
// Make sure we can actually use MySQL with fulltext indexes
|
||||||
if ($error = $this->init())
|
if ($error = $this->init())
|
||||||
|
@ -1049,7 +1049,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index_created()
|
public function index_created(): bool
|
||||||
{
|
{
|
||||||
if (empty($this->stats))
|
if (empty($this->stats))
|
||||||
{
|
{
|
||||||
|
@ -1146,7 +1146,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function acp()
|
public function acp(): array
|
||||||
{
|
{
|
||||||
$tpl = '
|
$tpl = '
|
||||||
<dl>
|
<dl>
|
||||||
|
|
|
@ -134,7 +134,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_name()
|
public function get_name(): string
|
||||||
{
|
{
|
||||||
return 'phpBB Native Fulltext';
|
return 'phpBB Native Fulltext';
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_search_query()
|
public function get_search_query(): string
|
||||||
{
|
{
|
||||||
return $this->search_query;
|
return $this->search_query;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_common_words()
|
public function get_common_words(): array
|
||||||
{
|
{
|
||||||
return $this->common_words;
|
return $this->common_words;
|
||||||
}
|
}
|
||||||
|
@ -180,21 +180,9 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function fills $this->search_query with the cleaned user search query
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* If $terms is 'any' then the words will be extracted from the search query
|
|
||||||
* and combined with | inside brackets. They will afterwards be treated like
|
|
||||||
* an standard search query.
|
|
||||||
*
|
|
||||||
* Then it analyses the query and fills the internal arrays $must_not_contain_ids,
|
|
||||||
* $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search()
|
|
||||||
*
|
|
||||||
* @param string $keywords contains the search query string as entered by the user
|
|
||||||
* @param string $terms is either 'all' (use search query as entered, default words to 'must be contained in post')
|
|
||||||
* or 'any' (find all posts containing at least one of the given words)
|
|
||||||
* @return boolean false if no valid keywords were found and otherwise true
|
|
||||||
*/
|
*/
|
||||||
public function split_keywords(&$keywords, $terms)
|
public function split_keywords(string &$keywords, string $terms): bool
|
||||||
{
|
{
|
||||||
$tokens = '+-|()* ';
|
$tokens = '+-|()* ';
|
||||||
|
|
||||||
|
@ -516,7 +504,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function keyword_search(string $type, string $fields, string $terms, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
// No keywords? No posts.
|
// No keywords? No posts.
|
||||||
if (empty($this->search_query))
|
if (empty($this->search_query))
|
||||||
|
@ -1001,7 +989,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function author_search(string $type, bool $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
// No author? No posts
|
// No author? No posts
|
||||||
if (!count($author_ary))
|
if (!count($author_ary))
|
||||||
|
@ -1303,7 +1291,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
|
public function index(string $mode, int $post_id, string &$message, string &$subject, int $poster_id, int $forum_id)
|
||||||
{
|
{
|
||||||
if (!$this->config['fulltext_native_load_upd'])
|
if (!$this->config['fulltext_native_load_upd'])
|
||||||
{
|
{
|
||||||
|
@ -1492,7 +1480,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index_remove($post_ids, $author_ids, $forum_ids)
|
public function index_remove(array $post_ids, array $author_ids, array $forum_ids): void
|
||||||
{
|
{
|
||||||
if (count($post_ids))
|
if (count($post_ids))
|
||||||
{
|
{
|
||||||
|
@ -1549,7 +1537,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function tidy()
|
public function tidy(): void
|
||||||
{
|
{
|
||||||
// Is the fulltext indexer disabled? If yes then we need not
|
// Is the fulltext indexer disabled? If yes then we need not
|
||||||
// carry on ... it's okay ... I know when I'm not wanted boo hoo
|
// carry on ... it's okay ... I know when I'm not wanted boo hoo
|
||||||
|
@ -2008,7 +1996,7 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function acp()
|
public function acp(): array
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* if we need any options, copied from fulltext_native for now, will have to be adjusted or removed
|
* if we need any options, copied from fulltext_native for now, will have to be adjusted or removed
|
||||||
|
|
|
@ -114,7 +114,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_name()
|
public function get_name(): string
|
||||||
{
|
{
|
||||||
return 'PostgreSQL Fulltext';
|
return 'PostgreSQL Fulltext';
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_search_query()
|
public function get_search_query(): string
|
||||||
{
|
{
|
||||||
return $this->search_query;
|
return $this->search_query;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_common_words()
|
public function get_common_words(): array
|
||||||
{
|
{
|
||||||
return $this->common_words;
|
return $this->common_words;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function split_keywords(&$keywords, $terms)
|
public function split_keywords(string &$keywords, string $terms): bool
|
||||||
{
|
{
|
||||||
if ($terms == 'all')
|
if ($terms == 'all')
|
||||||
{
|
{
|
||||||
|
@ -258,7 +258,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function keyword_search(string $type, string $fields, string $terms, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
// No keywords? No posts
|
// No keywords? No posts
|
||||||
if (!$this->search_query)
|
if (!$this->search_query)
|
||||||
|
@ -522,7 +522,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function author_search(string $type, bool $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
// No author? No posts
|
// No author? No posts
|
||||||
if (!count($author_ary))
|
if (!count($author_ary))
|
||||||
|
@ -798,7 +798,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
|
public function index(string $mode, int $post_id, string &$message, string &$subject, int $poster_id, int $forum_id)
|
||||||
{
|
{
|
||||||
// Split old and new post/subject to obtain array of words
|
// Split old and new post/subject to obtain array of words
|
||||||
$split_text = $this->split_message($message);
|
$split_text = $this->split_message($message);
|
||||||
|
@ -846,7 +846,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index_remove($post_ids, $author_ids, $forum_ids)
|
public function index_remove(array $post_ids, array $author_ids, array $forum_ids): void
|
||||||
{
|
{
|
||||||
$this->destroy_cache([], $author_ids);
|
$this->destroy_cache([], $author_ids);
|
||||||
}
|
}
|
||||||
|
@ -854,7 +854,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function tidy()
|
public function tidy(): void
|
||||||
{
|
{
|
||||||
// destroy too old cached search results
|
// destroy too old cached search results
|
||||||
$this->destroy_cache(array());
|
$this->destroy_cache(array());
|
||||||
|
@ -865,7 +865,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function create_index(int &$post_counter = null): ?array
|
public function create_index(int &$post_counter = 0): ?array
|
||||||
{
|
{
|
||||||
// Make sure we can actually use PostgreSQL with fulltext indexes
|
// Make sure we can actually use PostgreSQL with fulltext indexes
|
||||||
if ($error = $this->init())
|
if ($error = $this->init())
|
||||||
|
@ -983,7 +983,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index_created()
|
public function index_created(): bool
|
||||||
{
|
{
|
||||||
if (empty($this->stats))
|
if (empty($this->stats))
|
||||||
{
|
{
|
||||||
|
@ -1081,7 +1081,7 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function acp()
|
public function acp(): array
|
||||||
{
|
{
|
||||||
$tpl = '
|
$tpl = '
|
||||||
<dl>
|
<dl>
|
||||||
|
|
|
@ -190,7 +190,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_name()
|
public function get_name(): string
|
||||||
{
|
{
|
||||||
return 'Sphinx Fulltext';
|
return 'Sphinx Fulltext';
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_search_query()
|
public function get_search_query(): string
|
||||||
{
|
{
|
||||||
return $this->search_query;
|
return $this->search_query;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function get_common_words()
|
public function get_common_words(): array
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function split_keywords(&$keywords, $terms)
|
public function split_keywords(string &$keywords, string $terms): bool
|
||||||
{
|
{
|
||||||
// Keep quotes and new lines
|
// Keep quotes and new lines
|
||||||
$keywords = str_replace(['"', "\n"], ['"', ' '], trim($keywords));
|
$keywords = str_replace(['"', "\n"], ['"', ' '], trim($keywords));
|
||||||
|
@ -280,7 +280,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function keyword_search(string $type, string $fields, string $terms, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
// No keywords? No posts.
|
// No keywords? No posts.
|
||||||
if (!strlen($this->search_query) && !count($author_ary))
|
if (!strlen($this->search_query) && !count($author_ary))
|
||||||
|
@ -520,7 +520,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
|
public function author_search(string $type, bool $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page)
|
||||||
{
|
{
|
||||||
$this->search_query = '';
|
$this->search_query = '';
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
|
public function index(string $mode, int $post_id, string &$message, string &$subject, int $poster_id, int $forum_id)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Event to modify method arguments before the Sphinx search index is updated
|
* Event to modify method arguments before the Sphinx search index is updated
|
||||||
|
@ -607,7 +607,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index_remove($post_ids, $author_ids, $forum_ids)
|
public function index_remove(array $post_ids, array $author_ids, array $forum_ids): void
|
||||||
{
|
{
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($post_ids as $post_id)
|
foreach ($post_ids as $post_id)
|
||||||
|
@ -621,7 +621,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* Nothing needs to be destroyed
|
* Nothing needs to be destroyed
|
||||||
*/
|
*/
|
||||||
public function tidy()
|
public function tidy(): void
|
||||||
{
|
{
|
||||||
$this->config->set('search_last_gc', time(), false);
|
$this->config->set('search_last_gc', time(), false);
|
||||||
}
|
}
|
||||||
|
@ -629,7 +629,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function create_index(int &$post_counter = null): ?array
|
public function create_index(int &$post_counter = 0): ?array
|
||||||
{
|
{
|
||||||
if ($this->index_created())
|
if ($this->index_created())
|
||||||
{
|
{
|
||||||
|
@ -672,7 +672,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function index_created($allow_new_files = true)
|
public function index_created($allow_new_files = true): bool
|
||||||
{
|
{
|
||||||
$created = false;
|
$created = false;
|
||||||
|
|
||||||
|
@ -783,7 +783,7 @@ class fulltext_sphinx implements search_backend_interface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function acp()
|
public function acp(): array
|
||||||
{
|
{
|
||||||
$config_vars = array(
|
$config_vars = array(
|
||||||
'fulltext_sphinx_data_path' => 'string',
|
'fulltext_sphinx_data_path' => 'string',
|
||||||
|
|
|
@ -20,14 +20,14 @@ interface search_backend_interface
|
||||||
*
|
*
|
||||||
* @return string Name
|
* @return string Name
|
||||||
*/
|
*/
|
||||||
public function get_name();
|
public function get_name(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the search engine is available
|
* Returns if the search engine is available
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function is_available();
|
public function is_available(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method executed when a search backend is set from acp.
|
* Method executed when a search backend is set from acp.
|
||||||
|
@ -43,31 +43,39 @@ interface search_backend_interface
|
||||||
*
|
*
|
||||||
* @return string search query
|
* @return string search query
|
||||||
*/
|
*/
|
||||||
public function get_search_query();
|
public function get_search_query(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the common_words array
|
* Returns the common_words array
|
||||||
*
|
*
|
||||||
* @return array common words that are ignored by search backend
|
* @return array common words that are ignored by search backend
|
||||||
*/
|
*/
|
||||||
public function get_common_words();
|
public function get_common_words(): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the word_length array
|
* Returns the word_length array
|
||||||
*
|
*
|
||||||
* @return array min and max word length for searching
|
* @return array|false min and max word length for searching
|
||||||
*/
|
*/
|
||||||
public function get_word_length();
|
public function get_word_length();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits keywords entered by a user into an array of words stored in $this->split_words
|
* Splits keywords entered by a user into an array of words stored in $this->split_words
|
||||||
* Stores the tidied search query in $this->search_query
|
* This function fills $this->search_query with the cleaned user search query
|
||||||
*
|
*
|
||||||
* @param string &$keywords Contains the keyword as entered by the user
|
* If $terms is 'any' then the words will be extracted from the search query
|
||||||
* @param string $terms is either 'all' or 'any'
|
* and combined with | inside brackets. They will afterwards be treated like
|
||||||
* @return bool false if no valid keywords were found and otherwise true
|
* an standard search query.
|
||||||
|
*
|
||||||
|
* Then it analyses the query and fills the internal arrays $must_not_contain_ids,
|
||||||
|
* $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search()
|
||||||
|
*
|
||||||
|
* @param string $keywords contains the search query string as entered by the user
|
||||||
|
* @param string $terms is either 'all' (use search query as entered, default words to 'must be contained in post')
|
||||||
|
* or 'any' (find all posts containing at least one of the given words)
|
||||||
|
* @return boolean false if no valid keywords were found and otherwise true
|
||||||
*/
|
*/
|
||||||
public function split_keywords(&$keywords, $terms);
|
public function split_keywords(string &$keywords, string $terms): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first
|
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first
|
||||||
|
@ -89,7 +97,7 @@ interface search_backend_interface
|
||||||
* @param int $per_page number of ids each page is supposed to contain
|
* @param int $per_page number of ids each page is supposed to contain
|
||||||
* @return boolean|int total number of results
|
* @return boolean|int total number of results
|
||||||
*/
|
*/
|
||||||
public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page);
|
public function keyword_search(string $type, string $fields, string $terms, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a search on an author's posts without caring about message contents. Depends on display specific params
|
* Performs a search on an author's posts without caring about message contents. Depends on display specific params
|
||||||
|
@ -110,7 +118,7 @@ interface search_backend_interface
|
||||||
* @param int $per_page number of ids each page is supposed to contain
|
* @param int $per_page number of ids each page is supposed to contain
|
||||||
* @return boolean|int total number of results
|
* @return boolean|int total number of results
|
||||||
*/
|
*/
|
||||||
public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page);
|
public function author_search(string $type, bool $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array &$id_ary, int &$start, int $per_page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if phrase search is supported or not
|
* Returns if phrase search is supported or not
|
||||||
|
@ -130,38 +138,47 @@ interface search_backend_interface
|
||||||
* @param int $poster_id contains the user id of the poster
|
* @param int $poster_id contains the user id of the poster
|
||||||
* @param int $forum_id contains the forum id of parent forum of the post
|
* @param int $forum_id contains the forum id of parent forum of the post
|
||||||
*/
|
*/
|
||||||
public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id);
|
public function index(string $mode, int $post_id, string &$message, string &$subject, int $poster_id, int $forum_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy cached results, that might be outdated after deleting a post
|
* Destroy cached results, that might be outdated after deleting a post
|
||||||
|
* @param array $post_ids
|
||||||
|
* @param array $author_ids
|
||||||
|
* @param array $forum_ids
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function index_remove($post_ids, $author_ids, $forum_ids);
|
public function index_remove(array $post_ids, array $author_ids, array $forum_ids): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy old cache entries
|
* Destroy old cache entries
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tidy();
|
public function tidy(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create fulltext index
|
* Create fulltext index
|
||||||
*
|
*
|
||||||
* @param int|null $post_counter
|
* @param int $post_counter
|
||||||
* @return array|null array with current status or null if finished
|
* @return array|null array with current status or null if finished
|
||||||
*/
|
*/
|
||||||
public function create_index(int &$post_counter = null): ?array;
|
public function create_index(int &$post_counter = 0): ?array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop fulltext index
|
* Drop fulltext index
|
||||||
*
|
*
|
||||||
* @param int|null $post_counter
|
* @param int $post_counter
|
||||||
* @return array|null array with current status or null if finished
|
* @return array|null array with current status or null if finished
|
||||||
*/
|
*/
|
||||||
public function delete_index(int &$post_counter = null): ?array;
|
public function delete_index(int &$post_counter = 0): ?array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if both FULLTEXT indexes exist
|
* Returns true if both FULLTEXT indexes exist
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function index_created();
|
public function index_created(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an associative array containing information about the indexes
|
* Returns an associative array containing information about the indexes
|
||||||
|
@ -173,7 +190,7 @@ interface search_backend_interface
|
||||||
/**
|
/**
|
||||||
* Display various options that can be configured for the backend from the acp
|
* Display various options that can be configured for the backend from the acp
|
||||||
*
|
*
|
||||||
* @return associative array containing template and config variables
|
* @return array array containing template and config variables
|
||||||
*/
|
*/
|
||||||
public function acp();
|
public function acp(): array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ $mode = $request->variable('mode', '');
|
||||||
$search_id = $request->variable('search_id', '');
|
$search_id = $request->variable('search_id', '');
|
||||||
$start = max($request->variable('start', 0), 0);
|
$start = max($request->variable('start', 0), 0);
|
||||||
$post_id = $request->variable('p', 0);
|
$post_id = $request->variable('p', 0);
|
||||||
$topic_id = $request->variable('t', 0);
|
$topic_id = (int) $request->variable('t', 0);
|
||||||
$view = $request->variable('view', '');
|
$view = $request->variable('view', '');
|
||||||
|
|
||||||
$submit = $request->variable('submit', false);
|
$submit = $request->variable('submit', false);
|
||||||
|
@ -544,7 +544,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
|
||||||
extract($phpbb_dispatcher->trigger_event('core.search_modify_param_after', compact($vars)));
|
extract($phpbb_dispatcher->trigger_event('core.search_modify_param_after', compact($vars)));
|
||||||
|
|
||||||
// show_results should not change after this
|
// show_results should not change after this
|
||||||
$per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
|
$per_page = ($show_results == 'posts') ? (int) $config['posts_per_page'] : (int) $config['topics_per_page'];
|
||||||
$total_match_count = 0;
|
$total_match_count = 0;
|
||||||
|
|
||||||
// Set limit for the $total_match_count to reduce server load
|
// Set limit for the $total_match_count to reduce server load
|
||||||
|
|
Loading…
Add table
Reference in a new issue