Skip to content

Commit b2ada8b

Browse files
committed
Merge branch '3.1.x'
Conflicts: phpBB/includes/mcp/mcp_main.php
2 parents d3e55a8 + 072f4c9 commit b2ada8b

17 files changed

Lines changed: 105 additions & 21 deletions

phpBB/develop/search_fill.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
}
4141

4242
$error = false;
43-
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
43+
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
4444

4545
if ($error)
4646
{

phpBB/includes/acp/acp_main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ function main($id, $mode)
638638
{
639639
$error = false;
640640
$search_type = $config['search_type'];
641-
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
641+
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
642642

643643
if (!$search->index_created())
644644
{

phpBB/includes/acp/acp_search.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ function save_state($state = false)
596596
*/
597597
function init_search($type, &$search, &$error)
598598
{
599-
global $phpbb_root_path, $phpEx, $user, $auth, $config, $db;
599+
global $phpbb_root_path, $phpEx, $user, $auth, $config, $db, $phpbb_dispatcher;
600600

601601
if (!class_exists($type) || !method_exists($type, 'keyword_search'))
602602
{
@@ -605,7 +605,7 @@ function init_search($type, &$search, &$error)
605605
}
606606

607607
$error = false;
608-
$search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
608+
$search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
609609

610610
return $error;
611611
}

phpBB/includes/functions_admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
942942
}
943943

944944
$error = false;
945-
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
945+
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
946946

947947
if ($error)
948948
{

phpBB/includes/functions_posting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2226,7 +2226,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
22262226
}
22272227

22282228
$error = false;
2229-
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
2229+
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
22302230

22312231
if ($error)
22322232
{

phpBB/includes/mcp/mcp_main.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '',
11881188
function mcp_fork_topic($topic_ids)
11891189
{
11901190
global $auth, $user, $db, $template, $config;
1191-
global $phpEx, $phpbb_root_path, $phpbb_log, $request;
1191+
global $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher;
11921192

11931193
if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
11941194
{
@@ -1266,7 +1266,7 @@ function mcp_fork_topic($topic_ids)
12661266
}
12671267

12681268
$error = false;
1269-
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
1269+
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
12701270
$search_mode = 'post';
12711271

12721272
if ($error)

phpBB/includes/mcp/mcp_post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ function change_poster(&$post_info, $userdata)
538538
{
539539
// We do some additional checks in the module to ensure it can actually be utilised
540540
$error = false;
541-
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
541+
$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
542542

543543
if (!$error && method_exists($search, 'destroy_cache'))
544544
{

phpBB/install/install_convert.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ function convert_data($sub)
625625
{
626626
global $template, $user, $phpbb_root_path, $phpEx, $db, $lang, $config, $cache, $auth;
627627
global $convert, $convert_row, $message_parser, $skip_rows, $language;
628-
global $request, $phpbb_config_php_file;
628+
global $request, $phpbb_config_php_file, $phpbb_dispatcher;
629629

630630
extract($phpbb_config_php_file->get_all());
631631

@@ -800,7 +800,7 @@ function convert_data($sub)
800800
}
801801

802802
$error = false;
803-
$convert->fulltext_search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
803+
$convert->fulltext_search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
804804

805805
if ($error)
806806
{

phpBB/install/install_install.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ function load_schema($mode, $sub)
14941494
*/
14951495
function build_search_index($mode, $sub)
14961496
{
1497-
global $db, $lang, $phpbb_root_path, $phpEx, $config, $auth, $user;
1497+
global $db, $lang, $phpbb_root_path, $phpbb_dispatcher, $phpEx, $config, $auth, $user;
14981498

14991499
// Obtain any submitted data
15001500
$data = $this->get_submitted_data();
@@ -1525,7 +1525,7 @@ function build_search_index($mode, $sub)
15251525
$config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE);
15261526

15271527
$error = false;
1528-
$search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
1528+
$search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher);
15291529

15301530
$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
15311531
FROM ' . POSTS_TABLE;

phpBB/phpbb/search/fulltext_mysql.php

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ class fulltext_mysql extends \phpbb\search\base
4242
*/
4343
protected $db;
4444

45+
/**
46+
* phpBB event dispatcher object
47+
* @var \phpbb\event\dispatcher_interface
48+
*/
49+
protected $phpbb_dispatcher;
50+
4551
/**
4652
* User object
4753
* @var \phpbb\user
@@ -79,11 +85,13 @@ class fulltext_mysql extends \phpbb\search\base
7985
* @param \phpbb\config\config $config Config object
8086
* @param \phpbb\db\driver\driver_interface Database object
8187
* @param \phpbb\user $user User object
88+
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object
8289
*/
83-
public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user)
90+
public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, $phpbb_dispatcher)
8491
{
8592
$this->config = $config;
8693
$this->db = $db;
94+
$this->phpbb_dispatcher = $phpbb_dispatcher;
8795
$this->user = $user;
8896

8997
$this->word_length = array('min' => $this->config['fulltext_mysql_min_word_len'], 'max' => $this->config['fulltext_mysql_max_word_len']);
@@ -447,6 +455,55 @@ public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key,
447455
break;
448456
}
449457

458+
$search_query = $this->search_query;
459+
460+
/**
461+
* Allow changing the query used to search for posts using fulltext_mysql
462+
*
463+
* @event core.search_mysql_keywords_main_query_before
464+
* @var string search_query The parsed keywords used for this search
465+
* @var int result_count The previous result count for the format of the query.
466+
* Set to 0 to force a re-count
467+
* @var bool join_topic Weather or not TOPICS_TABLE should be CROSS JOIN'ED
468+
* @var array author_ary Array of user_id containing the users to filter the results to
469+
* @var string author_name An extra username to search on (!empty(author_ary) must be true, to be relevant)
470+
* @var array ex_fid_ary Which forums not to search on
471+
* @var int topic_id Limit the search to this topic_id only
472+
* @var string sql_sort_table Extra tables to include in the SQL query.
473+
* Used in conjunction with sql_sort_join
474+
* @var string sql_sort_join SQL conditions to join all the tables used together.
475+
* Used in conjunction with sql_sort_table
476+
* @var int sort_days Time, in days, of the oldest possible post to list
477+
* @var string sql_match Which columns to do the search on.
478+
* @var string sql_match_where Extra conditions to use to properly filter the matching process
479+
* @var string sort_by_sql The possible predefined sort types
480+
* @var string sort_key The sort type used from the possible sort types
481+
* @var string sort_dir "a" for ASC or "d" dor DESC for the sort order used
482+
* @var string sql_sort The result SQL when processing sort_by_sql + sort_key + sort_dir
483+
* @var int start How many posts to skip in the search results (used for pagination)
484+
* @since 3.1.5-RC1
485+
*/
486+
$vars = array(
487+
'search_query',
488+
'result_count',
489+
'join_topic',
490+
'author_ary',
491+
'author_name',
492+
'ex_fid_ary',
493+
'topic_id',
494+
'sql_sort_table',
495+
'sql_sort_join',
496+
'sort_days',
497+
'sql_match',
498+
'sql_match_where',
499+
'sort_by_sql',
500+
'sort_key',
501+
'sort_dir',
502+
'sql_sort',
503+
'start',
504+
);
505+
extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_keywords_main_query_before', compact($vars)));
506+
450507
$sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : '';
451508
$sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id';
452509
$sql_from = ($join_topic) ? TOPICS_TABLE . ' t, ' : '';

0 commit comments

Comments
 (0)