Error get nodes of content (there may not be any)
-
I am seeing this error when trying to automatically create a new post.
Trying to get property of non-object
/mnt/storage/stage/www/wp-content/plugins/publish-to-apple-news/includes/apple-exporter/class-exporter-content.php – 231 – HandleErrorpublic function nodes() {
// Because PHP’s DomDocument doesn’t like HTML5 tags, ignore errors.
$dom = new \DOMDocument();
libxml_use_internal_errors( true );
$dom->loadHTML( ‘<?xml encoding=”utf-8″ ?>’ . $this->content() );
libxml_clear_errors( true );// Find the first-level nodes of the body tag.
return $dom->getElementsByTagName( ‘body’ )->item( 0 )->childNodes; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar
}While the php ignore errors comment is worrying I believe a simple change might stop this erroring out.
return $dom->getElementsByTagName( ‘body’ )->item( 0 )->childNodes ?? [];
This bug stops the actual insert of post, thus makes the site unworkable.
- The topic ‘Error get nodes of content (there may not be any)’ is closed to new replies.