diff options
author | JoshyPHP <s9e.dev@gmail.com> | 2015-05-01 19:21:01 +0200 |
---|---|---|
committer | JoshyPHP <s9e.dev@gmail.com> | 2015-05-30 17:26:00 +0200 |
commit | b5911281ae175340817345e63ddbfaf43abb3cec (patch) | |
tree | 044e1fe16209c353e55689febe322096b5b1b6bc /phpBB/phpbb/textreparser/row_based_plugin.php | |
parent | 986af43f37342953bff548630aa33904c21234f4 (diff) | |
download | forums-b5911281ae175340817345e63ddbfaf43abb3cec.tar forums-b5911281ae175340817345e63ddbfaf43abb3cec.tar.gz forums-b5911281ae175340817345e63ddbfaf43abb3cec.tar.bz2 forums-b5911281ae175340817345e63ddbfaf43abb3cec.tar.xz forums-b5911281ae175340817345e63ddbfaf43abb3cec.zip |
[ticket/13803] Added tests, fixed param order in generate_text_for_storage()
PHPBB3-13803
Diffstat (limited to 'phpBB/phpbb/textreparser/row_based_plugin.php')
-rw-r--r-- | phpBB/phpbb/textreparser/row_based_plugin.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/phpBB/phpbb/textreparser/row_based_plugin.php b/phpBB/phpbb/textreparser/row_based_plugin.php index 2317c79e4f..b946d6532b 100644 --- a/phpBB/phpbb/textreparser/row_based_plugin.php +++ b/phpBB/phpbb/textreparser/row_based_plugin.php @@ -45,6 +45,29 @@ abstract class row_based_plugin extends base abstract protected function get_table_name(); /** + * Add fields to given row, if applicable + * + * The enable_* fields are not always saved to the database. Sometimes we need to guess their + * original value based on the text content or possibly other fields + * + * @param array $row Original row + * @return array Complete row + */ + protected function add_missing_fields(array $row) + { + if (!isset($row['enable_bbcode'], $row['enable_smilies'], $row['enable_magic_url'])) + { + $row += array( + 'enable_bbcode' => !empty($row['bbcode_uid']), + 'enable_smilies' => (strpos($row['text'], '<!-- s') !== false), + 'enable_magic_url' => (strpos($row['text'], '<!-- m -->') !== false), + ); + } + + return $row; + } + + /** * {@inheritdoc} */ public function get_max_id() @@ -67,16 +90,7 @@ abstract class row_based_plugin extends base $result = $this->db->sql_query($this->get_records_query($min_id, $max_id)); while ($row = $this->db->sql_fetchrow($result)) { - if (!isset($row['enable_bbcode'], $row['enable_smilies'], $row['enable_magic_url'])) - { - // Those fields are not saved to the database, we need to guess their original value - $row += array( - 'enable_bbcode' => !empty($row['bbcode_uid']), - 'enable_smilies' => (strpos($row['text'], '<!-- s') !== false), - 'enable_magic_url' => (strpos($row['text'], '<!-- m -->') !== false) - ); - } - $records[] = $row; + $records[] = $this->add_missing_fields($row); } $this->db->sql_freeresult($result); |