NO BUG: Disk storage explodes with Bricks PHP warning in error logs

Hello,

I have many lines of this error per seconds in my error log within my OLS server: “[STDERR] PHP Warning: Array to string conversion in …/wp-content/themes/bricks/includes/helpers.php on line 2765”

It blows my disk storage quickly in few days.

I’m using PHP 8.1 and Bricks v1.10.3

Can this be solved please?

Hey @Adrien,

are you by any chance using the new bricks/allowed_html_tags hook?

Best,

André

Hey @aslotta

It seems that this is the line that make thousands of PHP warning:

I created this code snippet also:

When I deactivate the code snippet, I no longer receive PHP warnings.

I think line 21 is not correct and breaks the array structure (which produces the warning). Use this line instead (see example in the academy):

return array_merge( $allowed_html_tags, $additional_tags );

Best,

André

Yeah you’re right, I don’t know why I had this line.

I’ve modified my code snippet by this so I have unique values inside the array also:

add_filter( 'bricks/allowed_html_tags', function( $allowed_html_tags ) {
    // Define the additional tags to be added
    $additional_tags = [
        'a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b',
        'base', 'basefont', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas',
        'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del',
        'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption',
        'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
        'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label',
        'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noframes',
        'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre',
        'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'search', 'section', 'select', 'small',
        'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'svg', 'table', 'tbody',
        'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u',
        'ul', 'var', 'video', 'wbr'
    ];

    // Merge additional tags with the existing allowed tags
    return array_unique(array_merge($allowed_html_tags, $additional_tags));
} );

Thanks for the quick help on this André!

Bricks already takes care of removing duplicates:

CleanShot 2024-09-02 at 12.55.07

So this is also not needed. :slight_smile: Just use the simple example from the academy.

Best,

André

2 Likes