[url]
or [quote]
. In 3.2.1, it is still possible to create two BBCodes in the ACP but only one of them will effectively work as intended. Starting with 3.2.2, only one BBCode can be created in the ACP but old definitions remain in the database and the behaviour remains unchanged: only one of them works.Since the overwhelming majority of those BBCodes fall into one of two categories (
[url]
-style or [quote]
-style) it is possible to merge them programmatically. A migration seems the right way to do that. I am not familiar with the migration system and I won't have time to learn it, that's why I'm looking for someone to handle this part.On my end, I will create a
text_formatter.s9e.bbcode_merger
service that takes the two BBCode definitions as input and produces a single, merged definition as output:
Code: Select all
$bbcode_merger = $phpbb_container->get('text_formatter.s9e.bbcode_merger');
$merged = $bbcode_merger->merge_bbcodes(
[
// First argument is the BBCode definition without an attribute
'usage' => '[url]{URL}[/url]',
'template' => '<a href="{URL}">{URL}</a>'
],
[
// Second argument is the BBCode definition with an attribute
'usage' => '[url={URL}]{TEXT}[/url]',
'template' => '<a href="{URL}">{TEXT}</a>'
]
);
Code: Select all
// $merged =
[
'usage' => '[url={URL;useContent}]{TEXT}[/url]',
'template' => '<a href="{@url}"><xsl:apply-templates/></a>'
]
phpbb_bbcodes
table, find entries with the same case-insensitive name minus the equal sign in bbcode_tag
(e.g. foo
and foo=
) then generate a merged definition, remove the entry with an equal sign and replace the remaining entry with the merged one. Maybe the BBCode's "help line" could be merged somehow, too.I have already written the service part, it's available in Pull request #5038. It relies on a yet-to-be-released version of s9e\TextFormatter, that's why it's currently marked WIP.
References
- Pull request #5038 (WIP)
- PHPBB3-15444 - Merge duplicate BBCodes via a migration
- PHPBB3-14357 - New BBCode engine ignores BBCodes with the same base tag
- https://www.phpbb.com/community/viewtop ... &t=2408021
- https://www.phpbb.com/community/viewtop ... &t=2416851
- https://www.phpbb.com/community/viewtop ... &t=2428586
- https://www.phpbb.com/community/viewtop ... &t=2442821