Ticket #4809: errors.diff
| File errors.diff, 23.2 kB (added by filosofo, 1 year ago) |
|---|
-
wp-app.php
old new 280 280 log_app('Inserting Post. Data:', print_r($post_data,true)); 281 281 282 282 $postID = wp_insert_post($post_data); 283 if ( is_wp_error( $postID ) ) 284 $this->internal_error($postID->get_error_message()); 283 285 284 286 if (!$postID) { 285 287 $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); -
wp-includes/query.php
old new 907 907 908 908 if ( !empty($q['category__not_in']) ) { 909 909 $ids = get_objects_in_term($q['category__not_in'], 'category'); 910 if ( is_wp_error( $ids ) ) 911 return $ids; 910 912 if ( is_array($ids) && count($ids > 0) ) { 911 913 $out_posts = "'" . implode("', '", $ids) . "'"; 912 914 $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)"; … … 1311 1313 } else if ($this->is_tag) { 1312 1314 $tag_id = $this->get('tag_id'); 1313 1315 $tag = &get_term($tag_id, 'post_tag'); 1316 if ( is_wp_error( $tag ) ) 1317 return $tag; 1314 1318 $this->queried_object = &$tag; 1315 1319 $this->queried_object_id = (int) $tag_id; 1316 1320 } else if ($this->is_posts_page) { -
wp-includes/link-template.php
old new 376 376 if ( !empty($excluded_categories) ) { 377 377 $blah = explode(' and ', $excluded_categories); 378 378 $posts_in_ex_cats = get_objects_in_term($blah, 'category'); 379 if ( is_wp_error( $posts_in_ex_cats ) ) 380 return $posts_in_ex_cats; 379 381 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 380 382 } 381 383 … … 409 411 if ( !empty($excluded_categories) ) { 410 412 $blah = explode(' and ', $excluded_categories); 411 413 $posts_in_ex_cats = get_objects_in_term($blah, 'category'); 414 if ( is_wp_error( $posts_in_ex_cats ) ) 415 return $posts_in_ex_cats; 412 416 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 413 417 } 414 418 -
wp-includes/category.php
old new 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 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 -
wp-includes/taxonomy.php
old new 342 342 function get_term_field( $field, $term, $taxonomy, $context = 'display' ) { 343 343 $term = (int) $term; 344 344 $term = get_term( $term, $taxonomy ); 345 346 345 if ( is_wp_error($term) ) 347 346 return $term; 348 347 … … 666 665 // Update children to point to new parent 667 666 if ( is_taxonomy_hierarchical($taxonomy) ) { 668 667 $term_obj = get_term($term, $taxonomy); 668 if ( is_wp_error( $term_obj ) ) 669 return $term_obj; 669 670 $parent = $term_obj->parent; 670 671 671 672 $wpdb->query("UPDATE $wpdb->term_taxonomy SET parent = '$parent' WHERE parent = '$term_obj->term_id' AND taxonomy = '$taxonomy'"); … … 1085 1086 $use_id = false; 1086 1087 if ( !is_object($term) ) { 1087 1088 $term = get_term($term, $taxonomy); 1089 if ( is_wp_error( $term ) ) 1090 return $term; 1088 1091 $use_id = true; 1089 1092 } 1090 1093 -
wp-includes/general-template.php
old new 193 193 194 194 if ( !empty($tag) ) { 195 195 $tag = get_term($tag, 'post_tag', OBJECT, 'display'); 196 if ( is_wp_error( $tag ) ) 197 return $tag; 196 198 if ( ! empty($tag->name) ) 197 199 $title = apply_filters('single_tag_title', $tag->name); 198 200 } … … 281 283 $tag_id = intval( get_query_var('tag_id') ); 282 284 if ( !empty($tag_id) ) { 283 285 $my_tag = &get_term($tag_id, 'post_tag'); 286 if ( is_wp_error( $my_tag ) ) 287 return false; 284 288 $my_tag_name = apply_filters('single_tag_title', $my_tag->name); 285 289 if ( !empty($my_tag_name) ) { 286 290 if ( $display ) -
wp-includes/feed.php
old new 12 12 13 13 function get_wp_title_rss($sep = '»') { 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 } -
wp-includes/widgets.php
old new 388 388 } 389 389 390 390 function wp_widget_links($args) { 391 global $wp_db_version;392 391 extract($args, EXTR_SKIP); 393 if ( $wp_db_version < 3582 ) { 394 // This ONLY works with li/h2 sidebars. 395 get_links_list(); 396 } else { 397 wp_list_bookmarks(array( 398 'title_before' => $before_title, 'title_after' => $after_title, 399 'category_before' => $before_widget, 'category_after' => $after_widget, 400 'show_images' => true, 'class' => 'linkcat widget' 401 )); 402 } 392 wp_list_bookmarks(array( 393 'title_before' => $before_title, 'title_after' => $after_title, 394 'category_before' => $before_widget, 'category_after' => $after_widget, 395 'show_images' => true, 'class' => 'linkcat widget' 396 )); 403 397 } 404 398 405 399 function wp_widget_search($args) { -
wp-includes/category-template.php
old new 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 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 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 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 … … 307 315 return; 308 316 309 317 $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args 310 echo apply_filters( 'wp_tag_cloud', $return, $args ); 318 if ( is_wp_error( $return ) ) 319 return false; 320 else 321 echo apply_filters( 'wp_tag_cloud', $return, $args ); 311 322 } 312 323 313 324 // $tags = prefetched tag array ( get_tags() ) … … 328 339 foreach ( (array) $tags as $tag ) { 329 340 $counts[$tag->name] = $tag->count; 330 341 $tag_links[$tag->name] = get_tag_link( $tag->term_id ); 342 if ( is_wp_error( $tag_links[$tag->name] ) ) 343 return $tag_links[$tag->name]; 331 344 $tag_ids[$tag->name] = $tag->term_id; 332 345 } 333 346 … … 404 417 $taglink = $wp_rewrite->get_tag_permastruct(); 405 418 406 419 $tag = &get_term($tag_id, 'post_tag'); 420 if ( is_wp_error( $tag ) ) 421 return $tag; 407 422 $slug = $tag->slug; 408 423 409 424 if ( empty($taglink) ) { … … 444 459 return false; 445 460 446 461 $tag_list = $before; 447 foreach ( $tags as $tag ) 448 $tag_links[] = '<a href="' . get_tag_link($tag->term_id) . '" rel="tag">' . $tag->name . '</a>'; 462 foreach ( $tags as $tag ) { 463 $link = get_tag_link($tag->term_id); 464 if ( is_wp_error( $link ) ) 465 return $link; 466 $tag_links[] = '<a href="' . $link . '" rel="tag">' . $tag->name . '</a>'; 467 } 449 468 450 469 $tag_links = join( $sep, $tag_links ); 451 470 $tag_links = apply_filters( 'the_tags', $tag_links ); … … 457 476 } 458 477 459 478 function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) { 460 echo get_the_tag_list($before, $sep, $after); 479 $return = get_the_tag_list($before, $sep, $after); 480 if ( is_wp_error( $return ) ) 481 return false; 482 else 483 echo $return; 461 484 } 462 485 463 486 ?> -
xmlrpc.php
old new 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.')); … … 1086 1088 $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'); 1087 1089 1088 1090 $post_ID = wp_insert_post($postdata); 1091 if ( is_wp_error( $post_ID ) ) 1092 return new IXR_Error(500, $post_ID->get_error_message()); 1089 1093 1090 1094 if (!$post_ID) { 1091 1095 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); -
wp-mail.php
old new 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 -
wp-admin/admin-ajax.php
old new 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 ) ) { -
wp-admin/includes/import.php
old new 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 -
wp-admin/includes/post.php
old new 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 add_meta( $post_ID ); 289 291 -
wp-admin/import/livejournal.php
old new 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 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 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 -
wp-admin/import/dotclear.php
old new 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 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 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&step=4" method="post">'; 568 574 wp_nonce_field('import-dotclear'); … … 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(); -
wp-admin/import/mt.php
old new 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 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 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 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 } -
wp-admin/import/blogger.php
old new 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 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 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 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() ) -
wp-admin/import/blogware.php
old new 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 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 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 -
wp-admin/import/textpattern.php
old new 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 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 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&step=4" method="post">'; 504 510 wp_nonce_field('import-textpattern'); … … 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(); -
wp-admin/import/greymatter.php
old new 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 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 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 } -
wp-admin/import/rss.php
old new 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 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 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 -
wp-admin/import/wordpress.php
old new 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 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 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 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 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(); -
wp-admin/link-manager.php
old new 159 159 $cat_names = array(); 160 160 foreach ($link->link_category as $category) { 161 161 $cat = get_term($category, 'link_category', OBJECT, 'display'); 162 if ( is_wp_error( $cat ) ) 163 echo $cat->get_error_message(); 162 164 $cat_name = $cat->name; 163 165 if ( $cat_id != $category ) 164 166 $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
