diff options
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php | 6 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php | 37 | ||||
-rw-r--r-- | phpBB/phpbb/template/assets_bag.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/bbcode_merger.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/textformatter/s9e/factory.php | 43 | ||||
-rw-r--r-- | phpBB/phpbb/textreparser/plugins/poll_title.php | 2 |
6 files changed, 64 insertions, 31 deletions
diff --git a/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php index 282c6bef2f..16fbdbc77b 100644 --- a/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php +++ b/phpBB/phpbb/db/migration/data/v32x/fix_user_styles.php @@ -33,13 +33,17 @@ class fix_user_styles extends \phpbb\db\migration\migration public function styles_fix() { $default_style = (int) $this->config['default_style']; + $enabled_styles = array(); // Get enabled styles $sql = 'SELECT style_id FROM ' . STYLES_TABLE . ' WHERE style_active = 1'; $result = $this->db->sql_query($sql); - $enabled_styles = $result->fetch_array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $enabled_styles[] = (int) $row['style_id']; + } $this->db->sql_freeresult($result); // Set the default style to users who have an invalid style 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 3bf442bab5..71ee19e3dd 100644 --- a/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php +++ b/phpBB/phpbb/db/migration/data/v32x/merge_duplicate_bbcodes.php @@ -13,7 +13,7 @@ namespace phpbb\db\migration\data\v32x; -class merge_duplicate_bbcodes extends \phpbb\db\migration\migration +class merge_duplicate_bbcodes extends \phpbb\db\migration\container_aware_migration { public function update_data() { @@ -30,7 +30,7 @@ class merge_duplicate_bbcodes extends \phpbb\db\migration\migration while ($row = $this->db->sql_fetchrow($result)) { $variant = (substr($row['bbcode_tag'], -1) === '=') ? 'with': 'without'; - $bbcode_name = rtrim($row['bbcode_tag'], '='); + $bbcode_name = strtolower(rtrim($row['bbcode_tag'], '=')); $bbcodes[$bbcode_name][$variant] = $row; } $this->db->sql_freeresult($result); @@ -46,16 +46,25 @@ class merge_duplicate_bbcodes extends \phpbb\db\migration\migration 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\migration $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/template/assets_bag.php b/phpBB/phpbb/template/assets_bag.php index 9013061b96..067b0eb8f1 100644 --- a/phpBB/phpbb/template/assets_bag.php +++ b/phpBB/phpbb/template/assets_bag.php @@ -71,7 +71,7 @@ class assets_bag $output = ''; foreach ($this->stylesheets as $stylesheet) { - $output .= "<link href=\"{$stylesheet->get_url()}\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" />\n"; + $output .= "<link href=\"{$stylesheet->get_url()}\" rel=\"stylesheet\" media=\"screen\" />\n"; } return $output; @@ -87,7 +87,7 @@ class assets_bag $output = ''; foreach ($this->scripts as $script) { - $output .= "<script type=\"text/javascript\" src=\"{$script->get_url()}\"></script>\n"; + $output .= "<script src=\"{$script->get_url()}\"></script>\n"; } return $output; 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 diff --git a/phpBB/phpbb/textreparser/plugins/poll_title.php b/phpBB/phpbb/textreparser/plugins/poll_title.php index 76d30655c9..5ca8bb063b 100644 --- a/phpBB/phpbb/textreparser/plugins/poll_title.php +++ b/phpBB/phpbb/textreparser/plugins/poll_title.php @@ -34,7 +34,7 @@ class poll_title extends \phpbb\textreparser\row_based_plugin $sql = 'SELECT t.topic_id AS id, t.poll_title AS text, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, p.bbcode_uid FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE t.topic_id BETWEEN ' . $min_id . ' AND ' . $max_id .' - AND t.poll_max_options > 0 + AND t.poll_start > 0 AND p.post_id = t.topic_first_post_id'; return $sql; |