diff options
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/auth/provider/oauth/oauth.php | 16 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/upload.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/db/driver/driver.php | 7 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php | 36 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php | 33 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v32x/v323rc1.php | 36 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/tool/module.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/debug/error_handler.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/file_downloader.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/install/helper/database.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/report/report_handler_pm.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/report/report_handler_post.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/search/fulltext_mysql.php | 85 | ||||
-rw-r--r-- | phpBB/phpbb/search/fulltext_native.php | 67 | ||||
-rw-r--r-- | phpBB/phpbb/search/fulltext_postgres.php | 82 | ||||
-rw-r--r-- | phpBB/phpbb/search/fulltext_sphinx.php | 22 | ||||
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/bbcode_merger.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/factory.php | 43 |
18 files changed, 403 insertions, 55 deletions
diff --git a/phpBB/phpbb/auth/provider/oauth/oauth.php b/phpBB/phpbb/auth/provider/oauth/oauth.php index 5587e69d3c..8809a0c6b4 100644 --- a/phpBB/phpbb/auth/provider/oauth/oauth.php +++ b/phpBB/phpbb/auth/provider/oauth/oauth.php @@ -227,6 +227,22 @@ class oauth extends \phpbb\auth\provider\base $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); + /** + * Event is triggered before check if provider is already associated with an account + * + * @event core.oauth_login_after_check_if_provider_id_has_match + * @var array row User row + * @var array data Provider data + * @var \OAuth\Common\Service\ServiceInterface service OAuth service + * @since 3.2.3-RC1 + */ + $vars = array( + 'row', + 'data', + 'service', + ); + extract($this->dispatcher->trigger_event('core.oauth_login_after_check_if_provider_id_has_match', compact($vars))); + if (!$row) { // The user does not yet exist, ask to link or create profile diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index d765a27871..77b44754ac 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -203,15 +203,18 @@ class upload extends \phpbb\avatar\driver\driver * * @event core.avatar_driver_upload_move_file_before * @var array filedata Array containing uploaded file data + * @var \phpbb\files\filespec file Instance of filespec class * @var string destination Destination directory where the file is going to be moved * @var string prefix Prefix for the avatar filename * @var array row Array with avatar row data * @var array error Array of errors, if filled in by this event file will not be moved * @since 3.1.6-RC1 * @changed 3.1.9-RC1 Added filedata + * @changed 3.2.3-RC1 Added file */ $vars = array( 'filedata', + 'file', 'destination', 'prefix', 'row', diff --git a/phpBB/phpbb/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php index 5851469806..a36ce8c0d7 100644 --- a/phpBB/phpbb/db/driver/driver.php +++ b/phpBB/phpbb/db/driver/driver.php @@ -903,9 +903,10 @@ abstract class driver implements driver_interface // Subquery with {left hand} {operator} {compare kind} {SELECT Kind } {Sub Query} - $condition = $condition[self::LEFT_STMT] . ' ' . $condition[self::COMPARE_OP] . ' ' . $condition[self::SUBQUERY_OP] . ' ( '; - $condition .= $this->sql_build_query($condition[self::SUBQUERY_SELECT_TYPE], $condition[self::SUBQUERY_BUILD]); - $condition .= ' )'; + $result = $condition[self::LEFT_STMT] . ' ' . $condition[self::COMPARE_OP] . ' ' . $condition[self::SUBQUERY_OP] . ' ( '; + $result .= $this->sql_build_query($condition[self::SUBQUERY_SELECT_TYPE], $condition[self::SUBQUERY_BUILD]); + $result .= ' )'; + $condition = $result; break; diff --git a/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php b/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php new file mode 100644 index 0000000000..a7b99606f7 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/enable_accurate_pm_button.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class enable_accurate_pm_button extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\v322', + ); + } + + public function effectively_installed() + { + return isset($this->config['enable_accurate_pm_button']); + } + + public function update_data() + { + return array( + array('config.add', array('enable_accurate_pm_button', '1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php index 08609b571b..71ee19e3dd 100644 --- a/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php +++ b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php @@ -46,16 +46,25 @@ class merge_duplicate_bbcodes extends \phpbb\db\migration\container_aware_migrat protected function merge_bbcodes(array $without, array $with) { - $merged = $this->container->get('text_formatter.s9e.bbcode_merger')->merge_bbcodes( - [ - 'usage' => $without['bbcode_match'], - 'template' => $without['bbcode_tpl'] - ], - [ - 'usage' => $with['bbcode_match'], - 'template' => $with['bbcode_tpl'] - ] - ); + try + { + $merged = $this->container->get('text_formatter.s9e.bbcode_merger')->merge_bbcodes( + [ + 'usage' => $without['bbcode_match'], + 'template' => $without['bbcode_tpl'] + ], + [ + 'usage' => $with['bbcode_match'], + 'template' => $with['bbcode_tpl'] + ] + ); + } + catch (\Exception $e) + { + // Ignore the pair and move on. The BBCodes would have to be fixed manually + return; + } + $bbcode_data = [ 'bbcode_tag' => $without['bbcode_tag'], 'bbcode_helpline' => $without['bbcode_helpline'] . ' | ' . $with['bbcode_helpline'], @@ -65,11 +74,11 @@ class merge_duplicate_bbcodes extends \phpbb\db\migration\container_aware_migrat $sql = 'UPDATE ' . BBCODES_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . ' - WHERE bbcode_id = ' . $without['bbcode_id']; + WHERE bbcode_id = ' . (int) $without['bbcode_id']; $this->sql_query($sql); $sql = 'DELETE FROM ' . BBCODES_TABLE . ' - WHERE bbcode_id = ' . $with['bbcode_id']; + WHERE bbcode_id = ' . (int) $with['bbcode_id']; $this->sql_query($sql); } } diff --git a/phpBB/phpbb/db/migration/data/v32x/v323rc1.php b/phpBB/phpbb/db/migration/data/v32x/v323rc1.php new file mode 100644 index 0000000000..0ff20d5074 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/v323rc1.php @@ -0,0 +1,36 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace phpbb\db\migration\data\v32x; + +class v323rc1 extends \phpbb\db\migration\migration +{ + public function effectively_installed() + { + return phpbb_version_compare($this->config['version'], '3.2.3-RC1', '>='); + } + + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\enable_accurate_pm_button', + ); + } + + public function update_data() + { + return array( + array('config.update', array('version', '3.2.3-RC1')), + ); + } +} diff --git a/phpBB/phpbb/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php index 8a48efb19c..3893935723 100644 --- a/phpBB/phpbb/db/migration/tool/module.php +++ b/phpBB/phpbb/db/migration/tool/module.php @@ -86,7 +86,8 @@ class module implements \phpbb\db\migration\tool\tool_interface * check for to see if it exists * @param bool $lazy Checks lazily if the module exists. Returns true if it exists in at * least one given parent. - * @return bool true if module exists in *all* given parents, false if not + * @return bool true if module exists in *all* given parents, false if not in any given parent; + * true if ignoring parent check and module exists class wide, false if not found at all. */ public function exists($class, $parent, $module, $lazy = false) { @@ -110,6 +111,10 @@ class module implements \phpbb\db\migration\tool\tool_interface $parent_sqls[] = 'AND parent_id = ' . (int) $parent_id; } } + else + { + $parent_sqls[] = ''; + } foreach ($parent_sqls as $parent_sql) { @@ -126,7 +131,7 @@ class module implements \phpbb\db\migration\tool\tool_interface { return false; } - else if ($lazy && $module_id) + if ($lazy && $module_id) { return true; } diff --git a/phpBB/phpbb/debug/error_handler.php b/phpBB/phpbb/debug/error_handler.php index 246e724f56..ebd828b97f 100644 --- a/phpBB/phpbb/debug/error_handler.php +++ b/phpBB/phpbb/debug/error_handler.php @@ -17,7 +17,7 @@ use Symfony\Component\Debug\ErrorHandler; class error_handler extends ErrorHandler { - public function handleError($type, $message, $file, $line, array $context, array $backtrace = null) + public function handleError($type, $message, $file, $line) { if ($type === E_USER_WARNING || $type === E_USER_NOTICE) { @@ -26,6 +26,6 @@ class error_handler extends ErrorHandler $handler($type, $message, $file, $line); } - return parent::handleError($type, $message, $file, $line, $context, $backtrace); + return parent::handleError($type, $message, $file, $line); } } diff --git a/phpBB/phpbb/file_downloader.php b/phpBB/phpbb/file_downloader.php index ab9505a14c..403ca5bc83 100644 --- a/phpBB/phpbb/file_downloader.php +++ b/phpBB/phpbb/file_downloader.php @@ -42,7 +42,7 @@ class file_downloader $this->error_number = 0; $this->error_string = ''; - if ($socket = @fsockopen(($port == 443 ? 'tls://' : '') . $host, $port, $this->error_number, $this->error_string, $timeout)) + if ($socket = @fsockopen(($port == 443 ? 'ssl://' : '') . $host, $port, $this->error_number, $this->error_string, $timeout)) { @fputs($socket, "GET $directory/$filename HTTP/1.0\r\n"); @fputs($socket, "HOST: $host\r\n"); diff --git a/phpBB/phpbb/install/helper/database.php b/phpBB/phpbb/install/helper/database.php index ad0f3dd3cd..21af652f9d 100644 --- a/phpBB/phpbb/install/helper/database.php +++ b/phpBB/phpbb/install/helper/database.php @@ -338,7 +338,7 @@ class database // Check if SQLite database is writable if ($dbms_info['SCHEMA'] === 'sqlite' - && (!$this->filesystem->is_writable($dbhost) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) + && (($this->filesystem->exists($dbhost) && !$this->filesystem->is_writable($dbhost)) || !$this->filesystem->is_writable(pathinfo($dbhost, PATHINFO_DIRNAME)))) { $errors[] = array( 'title' =>'INST_ERR_DB_NO_WRITABLE', diff --git a/phpBB/phpbb/report/report_handler_pm.php b/phpBB/phpbb/report/report_handler_pm.php index 2f2a697efc..774ca329ad 100644 --- a/phpBB/phpbb/report/report_handler_pm.php +++ b/phpBB/phpbb/report/report_handler_pm.php @@ -53,8 +53,8 @@ class report_handler_pm extends report_handler 'user_notify' => $user_notify, 'report_text' => $report_text, 'reported_post_text' => $this->report_data['message_text'], - 'reported_post_uid' => $this->report_data['bbcode_bitfield'], - 'reported_post_bitfield' => $this->report_data['bbcode_uid'], + 'reported_post_uid' => $this->report_data['bbcode_uid'], + 'reported_post_bitfield' => $this->report_data['bbcode_bitfield'], 'reported_post_enable_bbcode' => $this->report_data['enable_bbcode'], 'reported_post_enable_smilies' => $this->report_data['enable_smilies'], 'reported_post_enable_magic_url' => $this->report_data['enable_magic_url'], diff --git a/phpBB/phpbb/report/report_handler_post.php b/phpBB/phpbb/report/report_handler_post.php index 5574a16dc0..52f09683ce 100644 --- a/phpBB/phpbb/report/report_handler_post.php +++ b/phpBB/phpbb/report/report_handler_post.php @@ -59,8 +59,8 @@ class report_handler_post extends report_handler 'user_notify' => $user_notify, 'report_text' => $report_text, 'reported_post_text' => $this->report_data['post_text'], - 'reported_post_uid' => $this->report_data['bbcode_bitfield'], - 'reported_post_bitfield' => $this->report_data['bbcode_uid'], + 'reported_post_uid' => $this->report_data['bbcode_uid'], + 'reported_post_bitfield' => $this->report_data['bbcode_bitfield'], 'reported_post_enable_bbcode' => $this->report_data['enable_bbcode'], 'reported_post_enable_smilies' => $this->report_data['enable_smilies'], 'reported_post_enable_magic_url' => $this->report_data['enable_magic_url'], diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 51c5fe8b76..137ed7433d 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -918,6 +918,34 @@ class fulltext_mysql extends \phpbb\search\base $words = array_unique(array_merge($split_text, $split_title)); + /** + * Event to modify method arguments and words before the MySQL search index is updated + * + * @event core.search_mysql_index_before + * @var string mode Contains the post mode: edit, post, reply, quote + * @var int post_id The id of the post which is modified/created + * @var string message New or updated post content + * @var string subject New or updated post subject + * @var int poster_id Post author's user id + * @var int forum_id The id of the forum in which the post is located + * @var array words List of words added to the index + * @var array split_text Array of words from the message + * @var array split_title Array of words from the title + * @since 3.2.3-RC1 + */ + $vars = array( + 'mode', + 'post_id', + 'message', + 'subject', + 'poster_id', + 'forum_id', + 'words', + 'split_text', + 'split_title', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_index_before', compact($vars))); + unset($split_text); unset($split_title); @@ -997,17 +1025,37 @@ class fulltext_mysql extends \phpbb\search\base $alter_list[] = $alter_entry; } - if (count($alter_list)) + $sql_queries = []; + + foreach ($alter_list as $alter) { - foreach ($alter_list as $alter) - { - $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter)); - } + $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter); } if (!isset($this->stats['post_text'])) { - $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ADD FULLTEXT post_text (post_text)'); + $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ADD FULLTEXT post_text (post_text)'; + } + + $stats = $this->stats; + + /** + * Event to modify SQL queries before the MySQL search index is created + * + * @event core.search_mysql_create_index_before + * @var array sql_queries Array with queries for creating the search index + * @var array stats Array with statistics of the current index (read only) + * @since 3.2.3-RC1 + */ + $vars = array( + 'sql_queries', + 'stats', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_create_index_before', compact($vars))); + + foreach ($sql_queries as $sql_query) + { + $this->db->sql_query($sql_query); } $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); @@ -1050,9 +1098,32 @@ class fulltext_mysql extends \phpbb\search\base $alter[] = 'DROP INDEX post_text'; } + $sql_queries = []; + if (count($alter)) { - $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter)); + $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter); + } + + $stats = $this->stats; + + /** + * Event to modify SQL queries before the MySQL search index is deleted + * + * @event core.search_mysql_delete_index_before + * @var array sql_queries Array with queries for deleting the search index + * @var array stats Array with statistics of the current index (read only) + * @since 3.2.3-RC1 + */ + $vars = array( + 'sql_queries', + 'stats', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_mysql_delete_index_before', compact($vars))); + + foreach ($sql_queries as $sql_query) + { + $this->db->sql_query($sql_query); } $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index bd222488a0..4172e2cc4f 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -1433,6 +1433,38 @@ class fulltext_native extends \phpbb\search\base $words['del']['post'] = array(); $words['del']['title'] = array(); } + + /** + * Event to modify method arguments and words before the native search index is updated + * + * @event core.search_native_index_before + * @var string mode Contains the post mode: edit, post, reply, quote + * @var int post_id The id of the post which is modified/created + * @var string message New or updated post content + * @var string subject New or updated post subject + * @var int poster_id Post author's user id + * @var int forum_id The id of the forum in which the post is located + * @var array words Grouped lists of words added to or remove from the index + * @var array split_text Array of words from the message + * @var array split_title Array of words from the title + * @var array cur_words Array of words currently in the index for comparing to new words + * when mode is edit. Empty for other modes. + * @since 3.2.3-RC1 + */ + $vars = array( + 'mode', + 'post_id', + 'message', + 'subject', + 'poster_id', + 'forum_id', + 'words', + 'split_text', + 'split_title', + 'cur_words', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_native_index_before', compact($vars))); + unset($split_text); unset($split_title); @@ -1664,20 +1696,43 @@ class fulltext_native extends \phpbb\search\base */ public function delete_index($acp_module, $u_action) { + $sql_queries = []; + switch ($this->db->get_sql_layer()) { case 'sqlite3': - $this->db->sql_query('DELETE FROM ' . SEARCH_WORDLIST_TABLE); - $this->db->sql_query('DELETE FROM ' . SEARCH_WORDMATCH_TABLE); - $this->db->sql_query('DELETE FROM ' . SEARCH_RESULTS_TABLE); + $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDLIST_TABLE; + $sql_queries[] = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE; + $sql_queries[] = 'DELETE FROM ' . SEARCH_RESULTS_TABLE; break; default: - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE); - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE); - $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); + $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE; + $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE; + $sql_queries[] = 'TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE; break; } + + $stats = $this->stats; + + /** + * Event to modify SQL queries before the native search index is deleted + * + * @event core.search_native_delete_index_before + * @var array sql_queries Array with queries for deleting the search index + * @var array stats Array with statistics of the current index (read only) + * @since 3.2.3-RC1 + */ + $vars = array( + 'sql_queries', + 'stats', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_native_delete_index_before', compact($vars))); + + foreach ($sql_queries as $sql_query) + { + $this->db->sql_query($sql_query); + } } /** diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index 6443342057..2f387e791e 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -889,6 +889,34 @@ class fulltext_postgres extends \phpbb\search\base $words = array_unique(array_merge($split_text, $split_title)); + /** + * Event to modify method arguments and words before the PostgreSQL search index is updated + * + * @event core.search_postgres_index_before + * @var string mode Contains the post mode: edit, post, reply, quote + * @var int post_id The id of the post which is modified/created + * @var string message New or updated post content + * @var string subject New or updated post subject + * @var int poster_id Post author's user id + * @var int forum_id The id of the forum in which the post is located + * @var array words Array of words added to the index + * @var array split_text Array of words from the message + * @var array split_title Array of words from the title + * @since 3.2.3-RC1 + */ + $vars = array( + 'mode', + 'post_id', + 'message', + 'subject', + 'poster_id', + 'forum_id', + 'words', + 'split_text', + 'split_title', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_index_before', compact($vars))); + unset($split_text); unset($split_title); @@ -935,14 +963,37 @@ class fulltext_postgres extends \phpbb\search\base $this->get_stats(); } + $sql_queries = []; + if (!isset($this->stats['post_subject'])) { - $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))"); + $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))"; } if (!isset($this->stats['post_content'])) { - $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))"); + $sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))"; + } + + $stats = $this->stats; + + /** + * Event to modify SQL queries before the Postgres search index is created + * + * @event core.search_postgres_create_index_before + * @var array sql_queries Array with queries for creating the search index + * @var array stats Array with statistics of the current index (read only) + * @since 3.2.3-RC1 + */ + $vars = array( + 'sql_queries', + 'stats', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_create_index_before', compact($vars))); + + foreach ($sql_queries as $sql_query) + { + $this->db->sql_query($sql_query); } $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); @@ -968,14 +1019,37 @@ class fulltext_postgres extends \phpbb\search\base $this->get_stats(); } + $sql_queries = []; + if (isset($this->stats['post_subject'])) { - $this->db->sql_query('DROP INDEX ' . $this->stats['post_subject']['relname']); + $sql_queries[] = 'DROP INDEX ' . $this->stats['post_subject']['relname']; } if (isset($this->stats['post_content'])) { - $this->db->sql_query('DROP INDEX ' . $this->stats['post_content']['relname']); + $sql_queries[] = 'DROP INDEX ' . $this->stats['post_content']['relname']; + } + + $stats = $this->stats; + + /** + * Event to modify SQL queries before the Postgres search index is created + * + * @event core.search_postgres_delete_index_before + * @var array sql_queries Array with queries for deleting the search index + * @var array stats Array with statistics of the current index (read only) + * @since 3.2.3-RC1 + */ + $vars = array( + 'sql_queries', + 'stats', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_delete_index_before', compact($vars))); + + foreach ($sql_queries as $sql_query) + { + $this->db->sql_query($sql_query); } $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE); diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index 54d32ca371..e2eeb5f7f3 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -758,6 +758,28 @@ class fulltext_sphinx */ public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) { + /** + * Event to modify method arguments before the Sphinx search index is updated + * + * @event core.search_sphinx_index_before + * @var string mode Contains the post mode: edit, post, reply, quote + * @var int post_id The id of the post which is modified/created + * @var string message New or updated post content + * @var string subject New or updated post subject + * @var int poster_id Post author's user id + * @var int forum_id The id of the forum in which the post is located + * @since 3.2.3-RC1 + */ + $vars = array( + 'mode', + 'post_id', + 'message', + 'subject', + 'poster_id', + 'forum_id', + ); + extract($this->phpbb_dispatcher->trigger_event('core.search_sphinx_index_before', compact($vars))); + if ($mode == 'edit') { $this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int) $post_id => array((int) $forum_id, (int) $poster_id))); diff --git a/phpBB/phpbb/textformatter/s9e/bbcode_merger.php b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php index 72b1473751..a05ca3c2b8 100644 --- a/phpBB/phpbb/textformatter/s9e/bbcode_merger.php +++ b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php @@ -37,6 +37,9 @@ class bbcode_merger * * All of the arrays contain a "usage" element and a "template" element * + * @throws InvalidArgumentException if a definition cannot be interpreted + * @throws RuntimeException if something unexpected occurs + * * @param array $without BBCode definition without an attribute * @param array $with BBCode definition with an attribute * @return array Merged definition diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index 1e85856898..c0bbc7b0e8 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -132,6 +132,11 @@ class factory implements \phpbb\textformatter\cache_interface protected $dispatcher; /** + * @var \phpbb\log\log_interface + */ + protected $log; + + /** * Constructor * * @param \phpbb\textformatter\data_access $data_access @@ -139,11 +144,12 @@ class factory implements \phpbb\textformatter\cache_interface * @param \phpbb\event\dispatcher_interface $dispatcher * @param \phpbb\config\config $config * @param \phpbb\textformatter\s9e\link_helper $link_helper + * @param \phpbb\log\log_interface $log * @param string $cache_dir Path to the cache dir * @param string $cache_key_parser Cache key used for the parser * @param string $cache_key_renderer Cache key used for the renderer */ - public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, $cache_dir, $cache_key_parser, $cache_key_renderer) + public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, \phpbb\log\log_interface $log, $cache_dir, $cache_key_parser, $cache_key_renderer) { $this->link_helper = $link_helper; $this->cache = $cache; @@ -153,6 +159,7 @@ class factory implements \phpbb\textformatter\cache_interface $this->config = $config; $this->data_access = $data_access; $this->dispatcher = $dispatcher; + $this->log = $log; } /** @@ -272,7 +279,7 @@ class factory implements \phpbb\textformatter\cache_interface // Add default BBCodes foreach ($this->get_default_bbcodes($configurator) as $bbcode) { - $configurator->BBCodes->addCustom($bbcode['usage'], new UnsafeTemplate($bbcode['template'])); + $this->add_bbcode($configurator, $bbcode['usage'], $bbcode['template']); } if (isset($configurator->tags['QUOTE'])) { @@ -299,17 +306,7 @@ class factory implements \phpbb\textformatter\cache_interface }, $row['bbcode_tpl'] ); - - try - { - $configurator->BBCodes->addCustom($row['bbcode_match'], new UnsafeTemplate($tpl)); - } - catch (\Exception $e) - { - /** - * @todo log an error? - */ - } + $this->add_bbcode($configurator, $row['bbcode_match'], $tpl); } // Load smilies @@ -419,6 +416,26 @@ class factory implements \phpbb\textformatter\cache_interface } /** + * Add a BBCode to given configurator + * + * @param Configurator $configurator + * @param string $usage + * @param string $template + * @return void + */ + protected function add_bbcode(Configurator $configurator, $usage, $template) + { + try + { + $configurator->BBCodes->addCustom($usage, new UnsafeTemplate($template)); + } + catch (\Exception $e) + { + $this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]); + } + } + + /** * Configure the Autolink / Autoemail plugins used to linkify text * * @param \s9e\TextFormatter\Configurator $configurator |