Skip to content

Commit 72db97e

Browse files
authored
Merge pull request #131 from emgk/issue-48
2 parents 1b413ac + 3e471e0 commit 72db97e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

includes/class-syndication-wp-xml-client.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,25 @@ public function get_posts( $args = array() ) {
251251
do_action( 'push_syndication_event', 'pull_success', $this->site_ID );
252252
}
253253

254+
// Enable libxml to retrieve xml errors.
255+
libxml_use_internal_errors(true);
256+
254257
/** @var SimpleXMLElement $xml */
255258
$xml = simplexml_load_string( $feed, null, 0, $namespace, false );
256259

257260
if ( false === $xml ) {
258-
Syndication_Logger::log_post_error( $this->site_ID, $status = 'error', $message = sprintf( __( 'Failed to parse feed at: %s', 'push-syndication' ), $this->feed_url ), $log_time = $site_post->postmeta['is_update'], $extra = array() );
261+
262+
$xml_errors = '';
263+
264+
// Retrieve errors.
265+
foreach( libxml_get_errors() as $error ) {
266+
$xml_errors .= $error->message . '\n';
267+
}
268+
269+
// Clear libxml error buffer.
270+
libxml_clear_errors();
271+
272+
Syndication_Logger::log_post_error( $this->site_ID, $status = 'error', $message = sprintf( __( 'Failed to parse feed at: %s \nErrors: %s', 'push-syndication' ), $this->feed_url, $xml_errors ), $log_time = $site_post->postmeta['is_update'], $extra = array() );
259273

260274
// Track the event.
261275
do_action( 'push_syndication_event', 'pull_failure', $this->site_ID );

0 commit comments

Comments
 (0)