Skip to content

Commit 4c34452

Browse files
committed
Improve error logging when insert post fails
1 parent b6f96b6 commit 4c34452

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

includes/feed-importing.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ function wprss_items_insert_post( $items, $feed_ID ) {
715715
}
716716

717717
// Create and insert post object into the DB
718-
$inserted_ID = wp_insert_post( $feed_item );
718+
$inserted_ID = wp_insert_post( $feed_item, true );
719719

720720
if ( !is_wp_error( $inserted_ID ) ) {
721721

@@ -749,9 +749,13 @@ function wprss_items_insert_post( $items, $feed_ID ) {
749749
]);
750750
}
751751
else {
752-
update_post_meta( $feed_ID, 'wprss_error_last_import', 'An error occurred while inserting a feed item into the database.' );
752+
$message = sprintf(
753+
__('Failed to save a feed item: %s', 'wprss'),
754+
$inserted_ID->get_error_message()
755+
);
753756

754-
$logger->error('Failed to save item "{0}" into the database', [$item->get_title()]);
757+
update_post_meta($feed_ID, 'wprss_error_last_import', $message);
758+
$logger->error($message);
755759
}
756760
}
757761
// If the item is TRUE, then a hook function in the filter inserted the item.

0 commit comments

Comments
 (0)