Fixed  Undefined variable $source in \library\XenForo\BbCode\Formatter\Base.php

Yoskaldyr

Well-known member
Please consider of adding one line of code into file \library\XenForo\BbCode\Formatter\Base.php on line 1110:
Find
PHP:
        else
        {
            $name = false;
        }
Replace with
PHP:
        else
         {
             $name = false;
             $source = false;
          }
I'm asking of this, because I've got an error (Method XenForo_BbCode_TextWrapper::__toString() must not throw an exception) while processing quote bbcode without options in my add-on.
Code of My_ViewPublic_Post class (from my test add-on):
PHP:
class My_ViewPublic_Post extends XenForo_ViewPublic_Base
{
    public function renderHtml()
    {
        $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
        $this->_params['messageParsed'] = new XenForo_BbCode_TextWrapper($this->_params['message'], $bbCodeParser);
    }
}

That happens because of undefined variable $source in the source code (\library\XenForo\BbCode\Formatter\Base.php) in line 1120:
PHP:
        if ($this->_view)
        {
            $template = $this->_view->createTemplateObject('bb_code_tag_quote', array(
                'content' => $content,
                'nameHtml' => $name,
                'source' => $source
            ));
            return $template->render();
        }
 
Top Bottom