PHP Warning
-
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 methodprocess_nodes( $node )receives$nodewhich can sometimes benull(either on the initial call or during recursion). Line 50 tries to access$node->childNodesdirectly without validating the variable first.Suggested Fix: Adding a simple guard clause at the very beginning of the
process_nodesfunction resolves the issue cleanly:PHP
private function process_nodes( $node ) { if ( ! $node ) { return ''; } $markdown = ''; foreach ( $node->childNodes as $child ) { // ... rest of the codeCould 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
You must be logged in to reply to this topic.