1 (edited by Popov 2023-02-23 14:07)

Topic: "list" tag crashes the forum

Try to post the following markup.

[list]
    [*]Example list item 1.[/*]
    [*]Example list item 2.[/*]
    [*]Example list item 3.[/*]
[/list]

It provides:

This page isn’t working
punbb.informer.com is currently unable to handle this request.
HTTP ERROR 500

Log message on my server:

AH01071: Got error 'PHP message: PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /.../forum/include/parser.php on line 820'

I'm using PunBB at Forex Forum since 2006.

Re: "list" tag crashes the forum

You can try editing the parser.php file

function do_bbcode($text, $is_signature = false)
{
    global $lang_common, $forum_user, $forum_config;

-->

function do_bbcode($text, $is_signature = false)
{
    global $lang_common, $forum_user, $forum_config;

    $pattern_callback = array();
ForkBB
I speak only Russian  :P

3 (edited by Popov 2023-02-23 15:36)

Re: "list" tag crashes the forum

Can you please attach the fixed `parser.php`?

I'm asking because it crashes in another place when I add this line.

I'm using PunBB at Forex Forum since 2006.

Re: "list" tag crashes the forum

I don't have this parser.php as I maintain a different version of punbb with my edits: https://punbb.informer.com/forums/post/158390/#p158390

ForkBB
I speak only Russian  :P

5

Re: "list" tag crashes the forum

Thank you for your hard work!

I'll try your fork.

I'm using PunBB at Forex Forum since 2006.

6 (edited by Popov 2023-02-23 21:18)

Re: "list" tag crashes the forum

To fix it, we have to replace "function($matches, $errors)" with "function($matches) use (&$errors)" in two places:

Line 58

        $text = preg_replace_callback($pattern_callback, function($matches, $errors) {
            return preparse_list_tag($matches[2], $matches[1], $errors);
        }, $text);

To become

        $text = preg_replace_callback($pattern_callback, function($matches) use (&$errors) {
            return preparse_list_tag($matches[2], $matches[1], $errors);
        }, $text);

And line 532

        $content = preg_replace_callback($pattern_callback, function($matches, $errors) {
            return preparse_list_tag($matches[2], $matches[1], $errors);
        }, $content);

To become

        $content = preg_replace_callback($pattern_callback, function($matches) use (&$errors) {
            return preparse_list_tag($matches[2], $matches[1], $errors);
        }, $content);
I'm using PunBB at Forex Forum since 2006.