diff --git a/tests/unit/article_reparser_test.php b/tests/unit/article_reparser_test.php
new file mode 100644
index 0000000..253b004
--- /dev/null
+++ b/tests/unit/article_reparser_test.php
@@ -0,0 +1,54 @@
+createMock(\phpbb\db\driver\driver_interface::class),
+ 'phpbb_wiki_article'
+ );
+ $method = new \ReflectionMethod($plugin, 'add_missing_fields');
+ $method->setAccessible(true);
+
+ return $method->invoke($plugin, $record);
+ }
+
+ public function test_an_article_stored_as_xml_keeps_its_bbcode()
+ {
+ // Stored as XML with no bbcode_uid, which is how the wiki saves a version: core would guess "no BBCode" here
+ $record = $this->complete(array(
+ 'id' => 1,
+ 'text' => '[b]bold[/b] [[A]]',
+ 'bbcode_uid' => '',
+ ));
+
+ foreach (array('bbcode', 'smilies', 'magic_url', 'flash_bbcode', 'img_bbcode', 'quote_bbcode', 'url_bbcode') as $field)
+ {
+ $this->assertTrue($record['enable_' . $field], $field);
+ }
+ }
+
+ public function test_an_article_with_plain_text_is_parsed_the_same_way()
+ {
+ $record = $this->complete(array('id' => 2, 'text' => 'Plain [b]text[/b]', 'bbcode_uid' => ''));
+
+ $this->assertTrue($record['enable_bbcode']);
+ }
+}
diff --git a/textreparser/plugins/article_text.php b/textreparser/plugins/article_text.php
index 4a1b2c4..3e1af0f 100644
--- a/textreparser/plugins/article_text.php
+++ b/textreparser/plugins/article_text.php
@@ -24,6 +24,27 @@ public function get_columns()
);
}
+ /**
+ * Articles are always saved with BBCode, smilies and links on (see wiki/edit.php), and
+ * the table has no columns to say so. Core would guess from the stored text, and for text
+ * stored as XML without a bbcode_uid it guesses "no BBCode", which stripped every [b], [list]
+ * and [url] from an article the first time it was reparsed.
+ *
+ * {@inheritdoc}
+ */
+ protected function add_missing_fields(array $record)
+ {
+ return $record + array(
+ 'enable_bbcode' => true,
+ 'enable_smilies' => true,
+ 'enable_magic_url' => true,
+ 'enable_flash_bbcode' => true,
+ 'enable_img_bbcode' => true,
+ 'enable_quote_bbcode' => true,
+ 'enable_url_bbcode' => true,
+ );
+ }
+
/**
* Reparse with the wiki's own markup on, so headings and table of contents
* markers in older articles are recognised.