Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add checks for WP_Error. Props filosofo. see #4809

git-svn-id: http://svn.automattic.com/wordpress/trunk@6125 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit 9bfccd628638e948c2150bf3f3d4019d2a5e52bc 1 parent f30cd7a
ryan authored
5 wp-admin/admin-ajax.php
@@ -204,8 +204,11 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
204 204 $now = current_time('timestamp', 1);
205 205 if ( $pid = wp_insert_post( array(
206 206 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
207   - ) ) )
  207 + ) ) ) {
  208 + if ( is_wp_error( $pid ) )
  209 + return $pid;
208 210 $mid = add_meta( $pid );
  211 + }
209 212 else
210 213 die('0');
211 214 } else if ( !$mid = add_meta( $id ) ) {
11 wp-admin/import/blogger.php
@@ -380,7 +380,9 @@ function import_blog($blogID) {
380 380 $entry = "<feed>$entry</feed>";
381 381 $AtomParser = new AtomParser();
382 382 $AtomParser->parse( $entry );
383   - $this->import_post($AtomParser->entry);
  383 + $result = $this->import_post($AtomParser->entry);
  384 + if ( is_wp_error( $result ) )
  385 + return $result;
384 386 unset($AtomParser);
385 387 }
386 388 } else break;
@@ -518,6 +520,8 @@ function import_post( $entry ) {
518 520 $post = compact('post_date', 'post_content', 'post_title', 'post_status');
519 521
520 522 $post_id = wp_insert_post($post);
  523 + if ( is_wp_error( $post_id ) )
  524 + return $post_id;
521 525
522 526 wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id );
523 527
@@ -531,6 +535,7 @@ function import_post( $entry ) {
531 535 ++$this->blogs[$importing_blog]['posts_done'];
532 536 }
533 537 $this->save_vars();
  538 + return;
534 539 }
535 540
536 541 function import_comment( $entry ) {
@@ -767,7 +772,9 @@ function start() {
767 772 if ( isset( $_REQUEST['blog'] ) ) {
768 773 $blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog'];
769 774 $blog = (int) $blog;
770   - $this->import_blog( $blog );
  775 + $result = $this->import_blog( $blog );
  776 + if ( is_wp_error( $result ) )
  777 + echo $result->get_error_message();
771 778 } elseif ( isset($_GET['token']) )
772 779 $this->auth();
773 780 elseif ( $this->token && $this->token_is_valid() )
11 wp-admin/import/blogware.php
@@ -91,6 +91,9 @@ function import_posts() {
91 91 printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
92 92 $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
93 93 $post_id = wp_insert_post($postdata);
  94 + if ( is_wp_error( $post_id ) ) {
  95 + return $post_id;
  96 + }
94 97 if (!$post_id) {
95 98 _e("Couldn't get post ID");
96 99 echo '</li>';
@@ -155,7 +158,9 @@ function import() {
155 158 }
156 159
157 160 $this->file = $file['file'];
158   - $this->import_posts();
  161 + $result = $this->import_posts();
  162 + if ( is_wp_error( $result ) )
  163 + return $result;
159 164 wp_import_cleanup($file['id']);
160 165
161 166 echo '<h3>';
@@ -176,7 +181,9 @@ function dispatch() {
176 181 $this->greet();
177 182 break;
178 183 case 1 :
179   - $this->import();
  184 + $result = $this->import();
  185 + if ( is_wp_error( $result ) )
  186 + $result->get_error_message();
180 187 break;
181 188 }
182 189
12 wp-admin/import/dotclear.php
@@ -364,6 +364,8 @@ function posts2wp($posts='')
364 364 'ping_status' => $comment_status_map[$post_open_tb],
365 365 'comment_count' => $post_nb_comment + $post_nb_trackback)
366 366 );
  367 + if ( is_wp_error( $ret_id ) )
  368 + return $ret_id;
367 369 }
368 370 else
369 371 {
@@ -382,6 +384,8 @@ function posts2wp($posts='')
382 384 'ping_status' => $comment_status_map[$post_open_tb],
383 385 'comment_count' => $post_nb_comment + $post_nb_trackback)
384 386 );
  387 + if ( is_wp_error( $ret_id ) )
  388 + return $ret_id;
385 389 }
386 390 $dcposts2wpposts[$post_id] = $ret_id;
387 391
@@ -562,7 +566,9 @@ function import_posts()
562 566 {
563 567 // Post Import
564 568 $posts = $this->get_dc_posts();
565   - $this->posts2wp($posts);
  569 + $result = $this->posts2wp($posts);
  570 + if ( is_wp_error( $result ) )
  571 + return $result;
566 572
567 573 echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
568 574 wp_nonce_field('import-dotclear');
@@ -710,7 +716,9 @@ function dispatch()
710 716 $this->import_users();
711 717 break;
712 718 case 3 :
713   - $this->import_posts();
  719 + $result = $this->import_posts();
  720 + if ( is_wp_error( $result ) )
  721 + echo $result->get_error_message();
714 722 break;
715 723 case 4 :
716 724 $this->import_comments();
7 wp-admin/import/greymatter.php
@@ -233,6 +233,8 @@ function import() {
233 233
234 234 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
235 235 $post_ID = wp_insert_post($postdata);
  236 + if ( is_wp_error( $post_ID ) )
  237 + return $post_ID;
236 238 }
237 239
238 240 $c=count($entry);
@@ -287,6 +289,7 @@ function import() {
287 289 <p><?php _e('Completed GreyMatter import!') ?></p>
288 290 <?php
289 291 $this->footer();
  292 + return;
290 293 }
291 294
292 295 function dispatch() {
@@ -301,7 +304,9 @@ function dispatch() {
301 304 break;
302 305 case 1:
303 306 check_admin_referer('import-greymatter');
304   - $this->import();
  307 + $result = $this->import();
  308 + if ( is_wp_error( $result ) )
  309 + echo $result->get_error_message();
305 310 break;
306 311 }
307 312 }
10 wp-admin/import/livejournal.php
@@ -71,6 +71,8 @@ function import_posts() {
71 71 printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
72 72 $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
73 73 $post_id = wp_insert_post($postdata);
  74 + if ( is_wp_error( $post_id ) )
  75 + return $post_id;
74 76 if (!$post_id) {
75 77 _e("Couldn't get post ID");
76 78 echo '</li>';
@@ -132,7 +134,9 @@ function import() {
132 134 }
133 135
134 136 $this->file = $file['file'];
135   - $this->import_posts();
  137 + $result = $this->import_posts();
  138 + if ( is_wp_error( $result ) )
  139 + return $result;
136 140 wp_import_cleanup($file['id']);
137 141
138 142 echo '<h3>';
@@ -154,7 +158,9 @@ function dispatch() {
154 158 break;
155 159 case 1 :
156 160 check_admin_referer('import-upload');
157   - $this->import();
  161 + $result = $this->import();
  162 + if ( is_wp_error( $result ) )
  163 + echo $result->get_error_message();
158 164 break;
159 165 }
160 166
14 wp-admin/import/mt.php
@@ -215,6 +215,8 @@ function save_post(&$post, &$comments, &$pings) {
215 215
216 216 $post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor
217 217 $post_id = wp_insert_post($post);
  218 + if ( is_wp_error( $post_id ) )
  219 + return $post_id;
218 220
219 221 // Add categories.
220 222 if ( 0 != count($post->categories) ) {
@@ -291,7 +293,9 @@ function process_posts() {
291 293 } else if ( '--------' == $line ) {
292 294 // Finishing a post.
293 295 $context = '';
294   - $this->save_post($post, $comments, $pings);
  296 + $result = $this->save_post($post, $comments, $pings);
  297 + if ( is_wp_error( $result ) )
  298 + return $result;
295 299 $post = new StdClass;
296 300 $comment = new StdClass();
297 301 $ping = new StdClass();
@@ -415,7 +419,9 @@ function import() {
415 419 else
416 420 $this->file = get_attached_file($this->id);
417 421 $this->get_authors_from_post();
418   - $this->process_posts();
  422 + $result = $this->process_posts();
  423 + if ( is_wp_error( $result ) )
  424 + return $result;
419 425 }
420 426
421 427 function dispatch() {
@@ -434,7 +440,9 @@ function dispatch() {
434 440 break;
435 441 case 2:
436 442 check_admin_referer('import-mt');
437   - $this->import();
  443 + $result = $this->import();
  444 + if ( is_wp_error( $result ) )
  445 + echo $result->get_error_message();
438 446 break;
439 447 }
440 448 }
10 wp-admin/import/rss.php
@@ -110,6 +110,8 @@ function import_posts() {
110 110 _e('Post already imported');
111 111 } else {
112 112 $post_id = wp_insert_post($post);
  113 + if ( is_wp_error( $post_id ) )
  114 + return $post_id;
113 115 if (!$post_id) {
114 116 _e("Couldn't get post ID");
115 117 return;
@@ -135,7 +137,9 @@ function import() {
135 137
136 138 $this->file = $file['file'];
137 139 $this->get_posts();
138   - $this->import_posts();
  140 + $result = $this->import_posts();
  141 + if ( is_wp_error( $result ) )
  142 + return $result;
139 143 wp_import_cleanup($file['id']);
140 144
141 145 echo '<h3>';
@@ -157,7 +161,9 @@ function dispatch() {
157 161 break;
158 162 case 1 :
159 163 check_admin_referer('import-upload');
160   - $this->import();
  164 + $result = $this->import();
  165 + if ( is_wp_error( $result ) )
  166 + echo $result->get_error_message();
161 167 break;
162 168 }
163 169
12 wp-admin/import/textpattern.php
@@ -305,6 +305,8 @@ function posts2wp($posts='')
305 305 'post_name' => $url_title,
306 306 'comment_count' => $comments_count)
307 307 );
  308 + if ( is_wp_error( $ret_id ) )
  309 + return $ret_id;
308 310 }
309 311 else
310 312 {
@@ -321,6 +323,8 @@ function posts2wp($posts='')
321 323 'post_name' => $url_title,
322 324 'comment_count' => $comments_count)
323 325 );
  326 + if ( is_wp_error( $ret_id ) )
  327 + return $ret_id;
324 328 }
325 329 $txpposts2wpposts[$ID] = $ret_id;
326 330
@@ -498,7 +502,9 @@ function import_posts()
498 502 {
499 503 // Post Import
500 504 $posts = $this->get_txp_posts();
501   - $this->posts2wp($posts);
  505 + $result = $this->posts2wp($posts);
  506 + if ( is_wp_error( $result ) )
  507 + return $result;
502 508
503 509 echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
504 510 wp_nonce_field('import-textpattern');
@@ -638,7 +644,9 @@ function dispatch()
638 644 $this->import_users();
639 645 break;
640 646 case 3 :
641   - $this->import_posts();
  647 + $result = $this->import_posts();
  648 + if ( is_wp_error( $result ) )
  649 + echo $result->get_error_message();
642 650 break;
643 651 case 4 :
644 652 $this->import_comments();
23 wp-admin/import/wordpress.php
@@ -250,8 +250,11 @@ function process_posts() {
250 250 $i = -1;
251 251 echo '<ol>';
252 252
253   - foreach ($this->posts as $post)
254   - $this->process_post($post);
  253 + foreach ($this->posts as $post) {
  254 + $result = $this->process_post($post);
  255 + if ( is_wp_error( $result ) )
  256 + return $result;
  257 + }
255 258
256 259 echo '</ol>';
257 260
@@ -303,7 +306,11 @@ function process_post($post) {
303 306 // If it has parent, process parent first.
304 307 $post_parent = (int) $post_parent;
305 308 if ($parent = $this->posts_processed[$post_parent]) {
306   - if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first.
  309 + if (!$parent[1]) {
  310 + $result = $this->process_post($parent[0]); // If not yet, process the parent first.
  311 + if ( is_wp_error( $result ) )
  312 + return $result;
  313 + }
307 314 $post_parent = $parent[1]; // New ID of the parent;
308 315 }
309 316
@@ -314,6 +321,8 @@ function process_post($post) {
314 321
315 322 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'post_name', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt', 'guid', 'post_parent', 'menu_order', 'post_type');
316 323 $comment_post_ID = $post_id = wp_insert_post($postdata);
  324 + if ( is_wp_error( $post_id ) )
  325 + return $post_id;
317 326
318 327 // Memorize old and new ID.
319 328 if ( $post_id && $post_ID && $this->posts_processed[$post_ID] )
@@ -382,7 +391,9 @@ function import() {
382 391 $this->get_authors_from_post();
383 392 $this->get_entries();
384 393 $this->process_categories();
385   - $this->process_posts();
  394 + $result = $this->process_posts();
  395 + if ( is_wp_error( $result ) )
  396 + return $result;
386 397 }
387 398
388 399 function dispatch() {
@@ -402,7 +413,9 @@ function dispatch() {
402 413 break;
403 414 case 2:
404 415 check_admin_referer('import-wordpress');
405   - $this->import();
  416 + $result = $this->import();
  417 + if ( is_wp_error( $result ) )
  418 + echo $result->get_error_message();
406 419 break;
407 420 }
408 421 $this->footer();
3  wp-admin/includes/import.php
@@ -8,7 +8,8 @@ function get_importers() {
8 8
9 9 function register_importer( $id, $name, $description, $callback ) {
10 10 global $wp_importers;
11   -
  11 + if ( is_wp_error( $callback ) )
  12 + return $callback;
12 13 $wp_importers[$id] = array ( $name, $description, $callback );
13 14 }
14 15
2  wp-admin/includes/post.php
@@ -284,6 +284,8 @@ function wp_write_post() {
284 284
285 285 // Create the post.
286 286 $post_ID = wp_insert_post( $_POST );
  287 + if ( is_wp_error( $post_ID ) )
  288 + return $post_ID;
287 289
288 290 if ( empty($post_ID) )
289 291 return 0;
2  wp-admin/includes/upgrade.php
@@ -992,7 +992,7 @@ function dbDelta($queries, $execute = true) {
992 992 }
993 993 // Add the column list to the index create string
994 994 $index_string .= ' ('.$index_columns.')';
995   -
  995 + error_log("Index string: $index_string", 0);
996 996 if(!(($aindex = array_search($index_string, $indices)) === false)) {
997 997 unset($indices[$aindex]);
998 998 //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
2  wp-admin/link-manager.php
@@ -159,6 +159,8 @@ function checkAll(form)
2  wp-app.php
@@ -262,6 +262,8 @@ function create_post() {
262 262 log_app('Inserting Post. Data:', print_r($post_data,true));
263 263
264 264 $postID = wp_insert_post($post_data);
  265 + if ( is_wp_error( $postID ) )
  266 + $this->internal_error($postID->get_error_message());
265 267
266 268 if (!$postID) {
267 269 $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
31 wp-includes/category-template.php
@@ -12,6 +12,8 @@ function get_category_children($id, $before = '/', $after = '') {
12 12 continue;
13 13
14 14 $category = get_category($cat_id);
  15 + if ( is_wp_error( $category ) )
  16 + return $category;
15 17 if ( $category->parent == $id ) {
16 18 $chain .= $before.$category->term_id.$after;
17 19 $chain .= get_category_children($category->term_id, $before, $after);
@@ -29,6 +31,8 @@ function get_category_link($category_id) {
29 31 $catlink = $file . '?cat=' . $category_id;
30 32 } else {
31 33 $category = &get_category($category_id);
  34 + if ( is_wp_error( $category ) )
  35 + return $category;
32 36 $category_nicename = $category->slug;
33 37
34 38 if ( $parent = $category->parent )
@@ -43,6 +47,8 @@ function get_category_link($category_id) {
43 47 function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
44 48 $chain = '';
45 49 $parent = &get_category($id);
  50 + if ( is_wp_error( $parent ) )
  51 + return $parent;
46 52
47 53 if ( $nicename )
48 54 $name = $parent->slug;
@@ -98,6 +104,8 @@ function _usort_terms_by_ID($a, $b) {
98 104 function get_the_category_by_ID($cat_ID) {
99 105 $cat_ID = (int) $cat_ID;
100 106 $category = &get_category($cat_ID);
  107 + if ( is_wp_error( $category ) )
  108 + return $category;
101 109 return $category->name;
102 110 }
103 111
@@ -313,7 +321,10 @@ function wp_tag_cloud( $args = '' ) {
313 321 return;
314 322
315 323 $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
316   - echo apply_filters( 'wp_tag_cloud', $return, $args );
  324 + if ( is_wp_error( $return ) )
  325 + return false;
  326 + else
  327 + echo apply_filters( 'wp_tag_cloud', $return, $args );
317 328 }
318 329
319 330 // $tags = prefetched tag array ( get_tags() )
@@ -334,6 +345,8 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
334 345 foreach ( (array) $tags as $tag ) {
335 346 $counts[$tag->name] = $tag->count;
336 347 $tag_links[$tag->name] = get_tag_link( $tag->term_id );
  348 + if ( is_wp_error( $tag_links[$tag->name] ) )
  349 + return $tag_links[$tag->name];
337 350 $tag_ids[$tag->name] = $tag->term_id;
338 351 }
339 352
@@ -410,6 +423,8 @@ function get_tag_link( $tag_id ) {
410 423 $taglink = $wp_rewrite->get_tag_permastruct();
411 424
412 425 $tag = &get_term($tag_id, 'post_tag');
  426 + if ( is_wp_error( $tag ) )
  427 + return $tag;
413 428 $slug = $tag->slug;
414 429
415 430 if ( empty($taglink) ) {
@@ -450,8 +465,12 @@ function get_the_tag_list( $before = '', $sep = '', $after = '' ) {
450 465 return false;
451 466
452 467 $tag_list = $before;
453   - foreach ( $tags as $tag )
454   - $tag_links[] = '<a href="' . get_tag_link($tag->term_id) . '" rel="tag">' . $tag->name . '</a>';
  468 + foreach ( $tags as $tag ) {
  469 + $link = get_tag_link($tag->term_id);
  470 + if ( is_wp_error( $link ) )
  471 + return $link;
  472 + $tag_links[] = '<a href="' . $link . '" rel="tag">' . $tag->name . '</a>';
  473 + }
455 474
456 475 $tag_links = join( $sep, $tag_links );
457 476 $tag_links = apply_filters( 'the_tags', $tag_links );
@@ -463,7 +482,11 @@ function get_the_tag_list( $before = '', $sep = '', $after = '' ) {
463 482 }
464 483
465 484 function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
466   - echo get_the_tag_list($before, $sep, $after);
  485 + $return = get_the_tag_list($before, $sep, $after);
  486 + if ( is_wp_error( $return ) )
  487 + return false;
  488 + else
  489 + echo $return;
467 490 }
468 491
469 492 ?>
4 wp-includes/category.php
@@ -30,6 +30,8 @@ function &get_categories($args = '') {
30 30 // Handles category caching.
31 31 function &get_category($category, $output = OBJECT, $filter = 'raw') {
32 32 $category = get_term($category, 'category', $output, $filter);
  33 + if ( is_wp_error( $category ) )
  34 + return $category;
33 35
34 36 _make_cat_compat($category);
35 37
@@ -58,6 +60,8 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE
58 60 $curcategory = $category;
59 61 while ( ($curcategory->parent != 0) && ($curcategory->parent != $curcategory->term_id) ) {
60 62 $curcategory = get_term($curcategory->parent, 'category');
  63 + if ( is_wp_error( $curcategory ) )
  64 + return $curcategory;
61 65 $path = '/' . $curcategory->slug . $path;
62 66 }
63 67
2  wp-includes/feed.php
@@ -12,6 +12,8 @@ function bloginfo_rss($show = '') {
12 12
13 13 function get_wp_title_rss($sep = '&#187;') {
14 14 $title = wp_title($sep, false);
  15 + if ( is_wp_error( $title ) )
  16 + return $title->get_error_message();
15 17 $title = apply_filters('get_wp_title_rss', $title);
16 18 return $title;
17 19 }
2  wp-includes/general-template.php
@@ -195,6 +195,8 @@ function wp_title($sep = '&raquo;', $display = true) {
195 195
196 196 if ( !empty($tag) ) {
197 197 $tag = get_term($tag, 'post_tag', OBJECT, 'display');
  198 + if ( is_wp_error( $tag ) )
  199 + return $tag;
198 200 if ( ! empty($tag->name) )
199 201 $title = apply_filters('single_tag_title', $tag->name);
200 202 }
4 wp-includes/query.php
@@ -940,6 +940,8 @@ function &get_posts() {
940 940
941 941 if ( !empty($q['category__not_in']) ) {
942 942 $ids = get_objects_in_term($q['category__not_in'], 'category');
  943 + if ( is_wp_error( $ids ) )
  944 + return $ids;
943 945 if ( is_array($ids) && count($ids > 0) ) {
944 946 $out_posts = "'" . implode("', '", $ids) . "'";
945 947 $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)";
@@ -1415,6 +1417,8 @@ function get_queried_object() {
1415 1417 } else if ($this->is_tag) {
1416 1418 $tag_id = $this->get('tag_id');
1417 1419 $tag = &get_term($tag_id, 'post_tag');
  1420 + if ( is_wp_error( $tag ) )
  1421 + return $tag;
1418 1422 $this->queried_object = &$tag;
1419 1423 $this->queried_object_id = (int) $tag_id;
1420 1424 } else if ($this->is_posts_page) {
5 wp-includes/taxonomy.php
@@ -391,7 +391,6 @@ function get_term_children( $term, $taxonomy ) {
391 391 function get_term_field( $field, $term, $taxonomy, $context = 'display' ) {
392 392 $term = (int) $term;
393 393 $term = get_term( $term, $taxonomy );
394   -
395 394 if ( is_wp_error($term) )
396 395 return $term;
397 396
@@ -801,6 +800,8 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) {
801 800 // Update children to point to new parent
802 801 if ( is_taxonomy_hierarchical($taxonomy) ) {
803 802 $term_obj = get_term($term, $taxonomy);
  803 + if ( is_wp_error( $term_obj ) )
  804 + return $term_obj;
804 805 $parent = $term_obj->parent;
805 806
806 807 $wpdb->query("UPDATE $wpdb->term_taxonomy SET parent = '$parent' WHERE parent = '$term_obj->term_id' AND taxonomy = '$taxonomy'");
@@ -1252,6 +1253,8 @@ function &_get_term_children($term_id, $terms, $taxonomy) {
1252 1253 $use_id = false;
1253 1254 if ( !is_object($term) ) {
1254 1255 $term = get_term($term, $taxonomy);
  1256 + if ( is_wp_error( $term ) )
  1257 + return $term;
1255 1258 $use_id = true;
1256 1259 }
1257 1260
2  wp-mail.php
@@ -148,6 +148,8 @@
148 148 $post_data = add_magic_quotes($post_data);
149 149
150 150 $post_ID = wp_insert_post($post_data);
  151 + if ( is_wp_error( $post_ID ) )
  152 + echo "\n" . $post_ID->get_error_message();
151 153
152 154 if (!$post_ID) {
153 155 // we couldn't post, for whatever reason. better move forward to the next email
4 xmlrpc.php
@@ -800,6 +800,8 @@ function blogger_newPost($args) {
800 800 $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status');
801 801
802 802 $post_ID = wp_insert_post($post_data);
  803 + if ( is_wp_error( $post_ID ) )
  804 + return new IXR_Error(500, $post_ID->get_error_message());
803 805
804 806 if (!$post_ID) {
805 807 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
@@ -1088,6 +1090,8 @@ function mw_newPost($args) {
1088 1090 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input');
1089 1091
1090 1092 $post_ID = wp_insert_post($postdata);
  1093 + if ( is_wp_error( $post_ID ) )
  1094 + return new IXR_Error(500, $post_ID->get_error_message());
1091 1095
1092 1096 if (!$post_ID) {
1093 1097 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));

0 comments on commit 9bfccd6

Please sign in to comment.
Something went wrong with that request. Please try again.