• Resolved Frank

    (@bandy1967)


    PHP Warning (Attempt to read property “childNodes” on null) in simple-html-to-markdown.php

    Hi there,

    I noticed a PHP warning in my server logs caused by the Meerkat Markdown for AI Visibility plugin. The error occurs under PHP 8.5.x when the HTML-to-Markdown parser encounters an unexpected or empty node.

    Error Log:

    Plaintext

    [proxy_fcgi:error] AH01071: Got error 'PHP message: PHP Warning: Attempt to read property "childNodes" on null in /wp-content/plugins/meerkat-markdown-for-ai-visibility/includes/simple-html-to-markdown.php on line 50; PHP message: PHP Warning: foreach() argument must be of type array|object, null given in /wp-content/plugins/meerkat-markdown-for-ai-visibility/includes/simple-html-to-markdown.php on line 50'
    

    Cause: In includes/simple-html-to-markdown.php, the method process_nodes( $node ) receives $node which can sometimes be null (either on the initial call or during recursion). Line 50 tries to access $node->childNodes directly without validating the variable first.

    Suggested Fix: Adding a simple guard clause at the very beginning of the process_nodes function resolves the issue cleanly:

    PHP

    private function process_nodes( $node ) {
        if ( ! $node ) {
            return '';
        }
    
        $markdown = '';
    
        foreach ( $node->childNodes as $child ) {
            // ... rest of the code
    

    Could you please include a null-check in the next plugin update to prevent these warnings from flooding the logs?

    Thank you for your great work!

    Best regards,

    Frank

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Andy Brin

    (@andybrin)

    Hi! Thanks so much for bringing this to my attention, I appreciate you taking the time. The good news is, I’ve just rolled out a new version, so you shouldn’t be seeing that notice anymore. Have an awesome day!

    Thread Starter Frank

    (@bandy1967)

    Hi Andy, thank you so much for the update and for implementing the fix! It’s great to see the plugin running smoothly now. Much appreciated!

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.