diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php index db82d4089b..f657a45d38 100644 --- a/phpBB/phpbb/textreparser/plugins/user_signature.php +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -21,22 +21,16 @@ class user_signature extends \phpbb\textreparser\row_based_plugin */ protected $keyoptions; - /** - * Constructor - * - * Retrieves and saves the bit numbers used for user options - */ - public function __construct() - { - $class_vars = get_class_vars('phpbb\\user'); - $this->keyoptions = $class_vars['keyoptions']; - } - /** * {@inheritdoc} */ protected function add_missing_fields(array $row) { + if (!isset($this->keyoptions)) + { + $this->save_keyoptions(); + } + $options = $row['user_options']; $row += array( 'enable_bbcode' => phpbb_optionget($this->keyoptions['sig_bbcode'], $options), @@ -44,7 +38,7 @@ class user_signature extends \phpbb\textreparser\row_based_plugin 'enable_magic_url' => phpbb_optionget($this->keyoptions['sig_links'], $options), ); - return $row; + return parent::add_missing_fields($row); } /** @@ -67,4 +61,13 @@ class user_signature extends \phpbb\textreparser\row_based_plugin { return USERS_TABLE; } + + /** + * Save the keyoptions var from \phpbb\user + */ + protected function save_keyoptions() + { + $class_vars = get_class_vars('phpbb\\user'); + $this->keyoptions = $class_vars['keyoptions']; + } } diff --git a/tests/text_reparser/fixtures/users.xml b/tests/text_reparser/fixtures/users.xml new file mode 100644 index 0000000000..60c623b6b1 --- /dev/null +++ b/tests/text_reparser/fixtures/users.xml @@ -0,0 +1,91 @@ + + + + user_id + user_permissions + username_clean + user_options + user_sig + user_sig_bbcode_uid + + 1 + + user1 + 230271 + This row should be [b]ignored[/b] + abcd1234 + + + 2 + + user2 + 895 + [b]Not bold[/b] :) http://example.org + abcd1234 + + + 3 + + user3 + 33663 + [b:abcd1234]Bold[/b:abcd1234] :) http://example.org + abcd1234 + + + 4 + + user4 + 66431 + :) http://example.org]]> + abcd1234 + + + 5 + + user5 + 131967 + http://example.org]]> + abcd1234 + + + 6 + + user6 + 99199 + + abcd1234 + + + 7 + + user7 + 99199 + + abcd1234 + + + 8 + + user8 + 99199 + + abcd1234 + + + 9 + + user9 + 99199 + + abcd1234 + + + 1000 + + user1000 + 230271 + This row should be [b]ignored[/b] + abcd1234 + +
+
diff --git a/tests/text_reparser/forum_description_test.php b/tests/text_reparser/forum_description_test.php index 66ed261a6f..3b739353cd 100644 --- a/tests/text_reparser/forum_description_test.php +++ b/tests/text_reparser/forum_description_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_forum_description_test extends phpbb_textreparser_test_ return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\forum_description($this->db); } diff --git a/tests/text_reparser/forum_rules_test.php b/tests/text_reparser/forum_rules_test.php index c89f47cf8e..4c267c9014 100644 --- a/tests/text_reparser/forum_rules_test.php +++ b/tests/text_reparser/forum_rules_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_forum_rules_test extends phpbb_textreparser_test_row_ba return $this->createXMLDataSet(__DIR__ . '/fixtures/forums.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\forum_rules($this->db); } diff --git a/tests/text_reparser/pm_text_test.php b/tests/text_reparser/pm_text_test.php index 6b409d27e3..3896a57e98 100644 --- a/tests/text_reparser/pm_text_test.php +++ b/tests/text_reparser/pm_text_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_pm_text_test extends phpbb_textreparser_test_row_based_ return $this->createXMLDataSet(__DIR__ . '/fixtures/privmsgs.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\pm_text($this->db); } diff --git a/tests/text_reparser/post_text_test.php b/tests/text_reparser/post_text_test.php index ac540f170c..0f934a06ee 100644 --- a/tests/text_reparser/post_text_test.php +++ b/tests/text_reparser/post_text_test.php @@ -19,7 +19,7 @@ class phpbb_textreparser_post_text_test extends phpbb_textreparser_test_row_base return $this->createXMLDataSet(__DIR__ . '/fixtures/posts.xml'); } - public function get_reparser() + protected function get_reparser() { return new \phpbb\textreparser\plugins\post_text($this->db); } diff --git a/tests/text_reparser/test_row_based_plugin.php b/tests/text_reparser/test_row_based_plugin.php index 0258745bf2..4d4d64a56d 100644 --- a/tests/text_reparser/test_row_based_plugin.php +++ b/tests/text_reparser/test_row_based_plugin.php @@ -18,6 +18,8 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t { protected $db; + abstract protected function get_reparser(); + public function setUp() { global $config; diff --git a/tests/text_reparser/user_signature_test.php b/tests/text_reparser/user_signature_test.php new file mode 100644 index 0000000000..ab830a303d --- /dev/null +++ b/tests/text_reparser/user_signature_test.php @@ -0,0 +1,26 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +include_once __DIR__ . '/test_row_based_plugin.php'; + +class phpbb_textreparser_user_signature_test extends phpbb_textreparser_test_row_based_plugin +{ + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/users.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\user_signature($this->db); + } +}