You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Forum BBCode isn't rendered on PHP 8: HTML_BBCodeParser constructor never runs #531
Forum messages show raw BBCode tags such as [b] and [url] instead of formatted text, and each view logs PHP warnings.
lib/PEAR/BBCodeParser.php still uses a PHP 4 style constructor (function HTML_BBCodeParser($options = array()), line 165). PHP 8 no longer treats a method named after the
class as a constructor, so it never runs and open_esc / close_esc are never set.
Environment
web2project 5.0.0-rc2, upgraded from 2.3.1 (the constructor is unchanged in master as of 2026-10-31)
PHP 8.3.36
Steps to reproduce
Open a forum message whose body contains BBCode, for example [b]text[/b].
Actual result
The raw tags are visible in the page, and the log shows:
PHP Warning: Undefined array key "open_esc" in lib/PEAR/BBCodeParser.php on line 436
PHP Warning: Undefined array key "close_esc" in lib/PEAR/BBCodeParser.php on line 437
PHP Warning: preg_match(): Compilation failed: missing terminating ] for character class at offset 15 in lib/PEAR/BBCodeParser.php on line 439
Expected result
BBCode is rendered as formatted text and no warnings are logged.
Suggested fix
Rename the constructor to __construct() and check whether the code that calls it needs adjusting.
We haven't tested this fix. The cause comes from reading the code and from the warnings above.
Thanks for the clear report, @MiklosPathy. Your diagnosis was right. HTML_BBCodeParser still had a PHP 4–style constructor, which PHP 8 no longer calls, so open_esc/close_esc were never set and none of the BBCode filters were loaded. I reproduced it on PHP 8.3 and got the same three warnings.
Your suggested fix was the right one. Commit 0224b12 on dev-5.0.0 renames the constructor to __construct(), and nothing else needed to change. The forums only call new HTML_BBCodeParser() and qparse(), and the filter subclasses don’t define constructors of their own. With the fix, [b], [i], [url], [email], [list] and [color] all render correctly and nothing is logged.
To patch an existing install now, change line 165 of lib/PEAR/BBCodeParser.php from
function HTML_BBCodeParser($options = array())
to
function __construct($options = array())
The fix will be in the next 5.0 release. This issue will close automatically when dev-5.0.0 is merged into master.
Activity
Fix forum BBCode on PHP 8: use __construct() in HTML_BBCodeParser
caseysoftware commentedon Nov 2, 2026
Thanks for the clear report, @MiklosPathy. Your diagnosis was right. HTML_BBCodeParser still had a PHP 4–style constructor, which PHP 8 no longer calls, so open_esc/close_esc were never set and none of the BBCode filters were loaded. I reproduced it on PHP 8.3 and got the same three warnings.
Your suggested fix was the right one. Commit 0224b12 on dev-5.0.0 renames the constructor to __construct(), and nothing else needed to change. The forums only call new HTML_BBCodeParser() and qparse(), and the filter subclasses don’t define constructors of their own. With the fix, [b], [i], [url], [email], [list] and [color] all render correctly and nothing is logged.
To patch an existing install now, change line 165 of lib/PEAR/BBCodeParser.php from
function HTML_BBCodeParser($options = array())to
function __construct($options = array())The fix will be in the next 5.0 release. This issue will close automatically when dev-5.0.0 is merged into master.