Fixed Custom BBCode and quick save

Arty

Well-known member
Affected version
2.1.0
I've attached a custom add-on that implements "test" bbcode. Its as basic as possible to demonstrate bug.

It uses template engine to render custom BBCode.

It highlights contents in red color:
Code:
[test]qwerty[/test]
is turned into this HTML:
Code:
<span style="color: red">qwerty</span>

BBCode is simple: its a PHP callback that renders template public:bbcode_test.
Contents of callback:
Code:
public static function getHTML($tagChildren, $tagOption, $tag, array $options, \XF\BbCode\Renderer\AbstractRenderer $renderer)
{
    $content = $renderer->renderSubTree($tagChildren, $options);

    /* @var \XF\Template\Templater $templater */
    $templater = $renderer->getTemplater();
    $content = $templater->renderTemplate('public:bbcode_test', [
        'content' => $content
    ], true);

    return $content;
}
Contents of public:bbcode_test:
Code:
<span style="color: red">{{ $content | raw }}</span>

So it is very simple. Here is bug: if post is saved from quick edit, BBCode is rendered using master style instead of currently selected style.

How to test it:
  • Install this test add-on
  • In default style edit template "bbcode_test". Change it to this:
    Code:
    <span style="color: green">{{ $content | raw }}</span>
    so in master style highlight is red, in default style highlight is green
  • Go to visitor area, make sure default style is selected, create sample post:
    Code:
    [test]qwerty[/test]
  • Click "Post thread" to submit thread.
  • Post will have "qwerty" in green color, as it is supposed to (because in default style it was changed to green).
  • Click "Edit" link below post to show quick edit.
  • Do not change anything, simply click "Save".
  • Post will refresh and "qwerty" will be in red color instead of green.
 

Attachments

Last edited:
I can't reproduce this, though it's possible that there's another bug fix in 2.1.1 that is relevant (related to template caching).

As a test, you may be able to switch the master version to:
Code:
<xf:set var="$templater" value="{{ templater() }}" />
<span style="color: red">{{ $content | raw }} [{{ $templater.getStyleId() }}]</span>
And then change the default style version to green as before.

If it reports a style ID other than 0 but it renders the master version, then that could be the bug I'm thinking of. At this point, it may be easiest to just have you reconfirm once 2.1.1 is released.
 
In that case, I think we're confident enough that this is fixed in XF 2.1.1 :)

Not going to directly call it a duplicate, but the changes were made while we were fixing this one:
 
Top Bottom