From 72fc6d3153d4b8dcfb824057dea934f4a9c70044 Mon Sep 17 00:00:00 2001 From: Mohammad Jangda <batmoo@gmail.com> Date: Wed, 3 Apr 2013 21:13:46 -0400 Subject: [PATCH] Pull XML: Fail and blog instances where the post_root XPath fails to find any nodes. --- includes/class-syndication-wp-xml-client.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/class-syndication-wp-xml-client.php b/includes/class-syndication-wp-xml-client.php index 24a2930..a8d5ac1 100644 --- a/includes/class-syndication-wp-xml-client.php +++ b/includes/class-syndication-wp-xml-client.php @@ -181,7 +181,14 @@ class Syndication_WP_XML_Client implements Syndication_Client { } $post_position = 0; - foreach ($xml->xpath($post_root) as $item) { + $items = $xml->xpath( $post_root ); + + if ( empty( $items ) ) { + self::log_post( 'n/a', null, get_post($this->site_ID), sprintf( __( 'No post nodes found using XPath "%s" in feed', 'push-syndication' ), $post_root ) ); + return array(); + } + + foreach ( $items as $item ) { $item_fields = array(); $enclosures = array(); $meta_data = array(); -- GitLab