diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 4232b0509..013e37502 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -204,8 +204,11 @@ case 'add-meta' : $now = current_time('timestamp', 1); if ( $pid = wp_insert_post( array( 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now)) - ) ) ) + ) ) ) { + if ( is_wp_error( $pid ) ) + return $pid; $mid = add_meta( $pid ); + } else die('0'); } else if ( !$mid = add_meta( $id ) ) { diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php index 20585d5c5..b518cd73a 100644 --- a/wp-admin/import/blogger.php +++ b/wp-admin/import/blogger.php @@ -380,7 +380,9 @@ class Blogger_Import { $entry = "$entry"; $AtomParser = new AtomParser(); $AtomParser->parse( $entry ); - $this->import_post($AtomParser->entry); + $result = $this->import_post($AtomParser->entry); + if ( is_wp_error( $result ) ) + return $result; unset($AtomParser); } } else break; @@ -518,6 +520,8 @@ class Blogger_Import { $post = compact('post_date', 'post_content', 'post_title', 'post_status'); $post_id = wp_insert_post($post); + if ( is_wp_error( $post_id ) ) + return $post_id; wp_create_categories( array_map( 'addslashes', $entry->categories ), $post_id ); @@ -531,6 +535,7 @@ class Blogger_Import { ++$this->blogs[$importing_blog]['posts_done']; } $this->save_vars(); + return; } function import_comment( $entry ) { @@ -767,7 +772,9 @@ class Blogger_Import { if ( isset( $_REQUEST['blog'] ) ) { $blog = is_array($_REQUEST['blog']) ? array_shift( array_keys( $_REQUEST['blog'] ) ) : $_REQUEST['blog']; $blog = (int) $blog; - $this->import_blog( $blog ); + $result = $this->import_blog( $blog ); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); } elseif ( isset($_GET['token']) ) $this->auth(); elseif ( $this->token && $this->token_is_valid() ) diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php index 27b4785d8..d85fd9210 100644 --- a/wp-admin/import/blogware.php +++ b/wp-admin/import/blogware.php @@ -91,6 +91,9 @@ class BW_Import { printf(__('Importing post %s...'), stripslashes($post_title)); $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); $post_id = wp_insert_post($postdata); + if ( is_wp_error( $post_id ) ) { + return $post_id; + } if (!$post_id) { _e("Couldn't get post ID"); echo ''; @@ -155,7 +158,9 @@ class BW_Import { } $this->file = $file['file']; - $this->import_posts(); + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + return $result; wp_import_cleanup($file['id']); echo '

'; @@ -176,7 +181,9 @@ class BW_Import { $this->greet(); break; case 1 : - $this->import(); + $result = $this->import(); + if ( is_wp_error( $result ) ) + $result->get_error_message(); break; } diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php index f17df9d8e..1bf048601 100644 --- a/wp-admin/import/dotclear.php +++ b/wp-admin/import/dotclear.php @@ -364,6 +364,8 @@ class Dotclear_Import { 'ping_status' => $comment_status_map[$post_open_tb], 'comment_count' => $post_nb_comment + $post_nb_trackback) ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; } else { @@ -382,6 +384,8 @@ class Dotclear_Import { 'ping_status' => $comment_status_map[$post_open_tb], 'comment_count' => $post_nb_comment + $post_nb_trackback) ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; } $dcposts2wpposts[$post_id] = $ret_id; @@ -562,7 +566,9 @@ class Dotclear_Import { { // Post Import $posts = $this->get_dc_posts(); - $this->posts2wp($posts); + $result = $this->posts2wp($posts); + if ( is_wp_error( $result ) ) + return $result; echo '
'; wp_nonce_field('import-dotclear'); @@ -710,7 +716,9 @@ class Dotclear_Import { $this->import_users(); break; case 3 : - $this->import_posts(); + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); break; case 4 : $this->import_comments(); diff --git a/wp-admin/import/greymatter.php b/wp-admin/import/greymatter.php index 4305cd18c..6e92235dd 100644 --- a/wp-admin/import/greymatter.php +++ b/wp-admin/import/greymatter.php @@ -233,6 +233,8 @@ class GM_Import { $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'); $post_ID = wp_insert_post($postdata); + if ( is_wp_error( $post_ID ) ) + return $post_ID; } $c=count($entry); @@ -287,6 +289,7 @@ class GM_Import {

footer(); + return; } function dispatch() { @@ -301,7 +304,9 @@ class GM_Import { break; case 1: check_admin_referer('import-greymatter'); - $this->import(); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); break; } } diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php index c3b821a00..81f0365ac 100644 --- a/wp-admin/import/livejournal.php +++ b/wp-admin/import/livejournal.php @@ -71,6 +71,8 @@ class LJ_Import { printf(__('Importing post %s...'), stripslashes($post_title)); $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); $post_id = wp_insert_post($postdata); + if ( is_wp_error( $post_id ) ) + return $post_id; if (!$post_id) { _e("Couldn't get post ID"); echo ''; @@ -132,7 +134,9 @@ class LJ_Import { } $this->file = $file['file']; - $this->import_posts(); + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + return $result; wp_import_cleanup($file['id']); echo '

'; @@ -154,7 +158,9 @@ class LJ_Import { break; case 1 : check_admin_referer('import-upload'); - $this->import(); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); break; } diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php index 182b56981..c4b855b8e 100644 --- a/wp-admin/import/mt.php +++ b/wp-admin/import/mt.php @@ -215,6 +215,8 @@ class MT_Import { $post->post_author = $this->checkauthor($post->post_author); //just so that if a post already exists, new users are not created by checkauthor $post_id = wp_insert_post($post); + if ( is_wp_error( $post_id ) ) + return $post_id; // Add categories. if ( 0 != count($post->categories) ) { @@ -291,7 +293,9 @@ class MT_Import { } else if ( '--------' == $line ) { // Finishing a post. $context = ''; - $this->save_post($post, $comments, $pings); + $result = $this->save_post($post, $comments, $pings); + if ( is_wp_error( $result ) ) + return $result; $post = new StdClass; $comment = new StdClass(); $ping = new StdClass(); @@ -415,7 +419,9 @@ class MT_Import { else $this->file = get_attached_file($this->id); $this->get_authors_from_post(); - $this->process_posts(); + $result = $this->process_posts(); + if ( is_wp_error( $result ) ) + return $result; } function dispatch() { @@ -434,7 +440,9 @@ class MT_Import { break; case 2: check_admin_referer('import-mt'); - $this->import(); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); break; } } diff --git a/wp-admin/import/rss.php b/wp-admin/import/rss.php index f46caa16a..11fc7702d 100644 --- a/wp-admin/import/rss.php +++ b/wp-admin/import/rss.php @@ -110,6 +110,8 @@ class RSS_Import { _e('Post already imported'); } else { $post_id = wp_insert_post($post); + if ( is_wp_error( $post_id ) ) + return $post_id; if (!$post_id) { _e("Couldn't get post ID"); return; @@ -135,7 +137,9 @@ class RSS_Import { $this->file = $file['file']; $this->get_posts(); - $this->import_posts(); + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + return $result; wp_import_cleanup($file['id']); echo '

'; @@ -157,7 +161,9 @@ class RSS_Import { break; case 1 : check_admin_referer('import-upload'); - $this->import(); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); break; } diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php index ee4744110..1fe54c8ce 100644 --- a/wp-admin/import/textpattern.php +++ b/wp-admin/import/textpattern.php @@ -305,6 +305,8 @@ class Textpattern_Import { 'post_name' => $url_title, 'comment_count' => $comments_count) ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; } else { @@ -321,6 +323,8 @@ class Textpattern_Import { 'post_name' => $url_title, 'comment_count' => $comments_count) ); + if ( is_wp_error( $ret_id ) ) + return $ret_id; } $txpposts2wpposts[$ID] = $ret_id; @@ -498,7 +502,9 @@ class Textpattern_Import { { // Post Import $posts = $this->get_txp_posts(); - $this->posts2wp($posts); + $result = $this->posts2wp($posts); + if ( is_wp_error( $result ) ) + return $result; echo ''; wp_nonce_field('import-textpattern'); @@ -638,7 +644,9 @@ class Textpattern_Import { $this->import_users(); break; case 3 : - $this->import_posts(); + $result = $this->import_posts(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); break; case 4 : $this->import_comments(); diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 5f8ce8195..4ed6e8dd1 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -250,8 +250,11 @@ class WP_Import { $i = -1; echo '
    '; - foreach ($this->posts as $post) - $this->process_post($post); + foreach ($this->posts as $post) { + $result = $this->process_post($post); + if ( is_wp_error( $result ) ) + return $result; + } echo '
'; @@ -303,7 +306,11 @@ class WP_Import { // If it has parent, process parent first. $post_parent = (int) $post_parent; if ($parent = $this->posts_processed[$post_parent]) { - if (!$parent[1]) $this->process_post($parent[0]); // If not yet, process the parent first. + if (!$parent[1]) { + $result = $this->process_post($parent[0]); // If not yet, process the parent first. + if ( is_wp_error( $result ) ) + return $result; + } $post_parent = $parent[1]; // New ID of the parent; } @@ -314,6 +321,8 @@ class WP_Import { $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'); $comment_post_ID = $post_id = wp_insert_post($postdata); + if ( is_wp_error( $post_id ) ) + return $post_id; // Memorize old and new ID. if ( $post_id && $post_ID && $this->posts_processed[$post_ID] ) @@ -382,7 +391,9 @@ class WP_Import { $this->get_authors_from_post(); $this->get_entries(); $this->process_categories(); - $this->process_posts(); + $result = $this->process_posts(); + if ( is_wp_error( $result ) ) + return $result; } function dispatch() { @@ -402,7 +413,9 @@ class WP_Import { break; case 2: check_admin_referer('import-wordpress'); - $this->import(); + $result = $this->import(); + if ( is_wp_error( $result ) ) + echo $result->get_error_message(); break; } $this->footer(); diff --git a/wp-admin/includes/import.php b/wp-admin/includes/import.php index 22a8aa144..9835bb14d 100644 --- a/wp-admin/includes/import.php +++ b/wp-admin/includes/import.php @@ -8,7 +8,8 @@ function get_importers() { function register_importer( $id, $name, $description, $callback ) { global $wp_importers; - + if ( is_wp_error( $callback ) ) + return $callback; $wp_importers[$id] = array ( $name, $description, $callback ); } diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 7f595178d..e27482c57 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -284,6 +284,8 @@ function wp_write_post() { // Create the post. $post_ID = wp_insert_post( $_POST ); + if ( is_wp_error( $post_ID ) ) + return $post_ID; if ( empty($post_ID) ) return 0; diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 9fa3b22c2..be86875d4 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -992,7 +992,7 @@ function dbDelta($queries, $execute = true) { } // Add the column list to the index create string $index_string .= ' ('.$index_columns.')'; - + error_log("Index string: $index_string", 0); if(!(($aindex = array_search($index_string, $indices)) === false)) { unset($indices[$aindex]); //echo "
{$table}:
Found index:".$index_string."
\n"; diff --git a/wp-admin/link-manager.php b/wp-admin/link-manager.php index 0033835cf..ade31431e 100644 --- a/wp-admin/link-manager.php +++ b/wp-admin/link-manager.php @@ -159,6 +159,8 @@ if ( $links ) { $cat_names = array(); foreach ($link->link_category as $category) { $cat = get_term($category, 'link_category', OBJECT, 'display'); + if ( is_wp_error( $cat ) ) + echo $cat->get_error_message(); $cat_name = $cat->name; if ( $cat_id != $category ) $cat_name = "$cat_name"; diff --git a/wp-app.php b/wp-app.php index 0ddcabdf1..44846a797 100644 --- a/wp-app.php +++ b/wp-app.php @@ -262,6 +262,8 @@ EOD; log_app('Inserting Post. Data:', print_r($post_data,true)); $postID = wp_insert_post($post_data); + if ( is_wp_error( $postID ) ) + $this->internal_error($postID->get_error_message()); if (!$postID) { $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 0aee639b5..cd8dbcb17 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -12,6 +12,8 @@ function get_category_children($id, $before = '/', $after = '') { continue; $category = get_category($cat_id); + if ( is_wp_error( $category ) ) + return $category; if ( $category->parent == $id ) { $chain .= $before.$category->term_id.$after; $chain .= get_category_children($category->term_id, $before, $after); @@ -29,6 +31,8 @@ function get_category_link($category_id) { $catlink = $file . '?cat=' . $category_id; } else { $category = &get_category($category_id); + if ( is_wp_error( $category ) ) + return $category; $category_nicename = $category->slug; if ( $parent = $category->parent ) @@ -43,6 +47,8 @@ function get_category_link($category_id) { function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){ $chain = ''; $parent = &get_category($id); + if ( is_wp_error( $parent ) ) + return $parent; if ( $nicename ) $name = $parent->slug; @@ -98,6 +104,8 @@ function _usort_terms_by_ID($a, $b) { function get_the_category_by_ID($cat_ID) { $cat_ID = (int) $cat_ID; $category = &get_category($cat_ID); + if ( is_wp_error( $category ) ) + return $category; return $category->name; } @@ -313,7 +321,10 @@ function wp_tag_cloud( $args = '' ) { return; $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args - echo apply_filters( 'wp_tag_cloud', $return, $args ); + if ( is_wp_error( $return ) ) + return false; + else + echo apply_filters( 'wp_tag_cloud', $return, $args ); } // $tags = prefetched tag array ( get_tags() ) @@ -334,6 +345,8 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { foreach ( (array) $tags as $tag ) { $counts[$tag->name] = $tag->count; $tag_links[$tag->name] = get_tag_link( $tag->term_id ); + if ( is_wp_error( $tag_links[$tag->name] ) ) + return $tag_links[$tag->name]; $tag_ids[$tag->name] = $tag->term_id; } @@ -410,6 +423,8 @@ function get_tag_link( $tag_id ) { $taglink = $wp_rewrite->get_tag_permastruct(); $tag = &get_term($tag_id, 'post_tag'); + if ( is_wp_error( $tag ) ) + return $tag; $slug = $tag->slug; if ( empty($taglink) ) { @@ -450,8 +465,12 @@ function get_the_tag_list( $before = '', $sep = '', $after = '' ) { return false; $tag_list = $before; - foreach ( $tags as $tag ) - $tag_links[] = ''; + foreach ( $tags as $tag ) { + $link = get_tag_link($tag->term_id); + if ( is_wp_error( $link ) ) + return $link; + $tag_links[] = ''; + } $tag_links = join( $sep, $tag_links ); $tag_links = apply_filters( 'the_tags', $tag_links ); @@ -463,7 +482,11 @@ function get_the_tag_list( $before = '', $sep = '', $after = '' ) { } function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) { - echo get_the_tag_list($before, $sep, $after); + $return = get_the_tag_list($before, $sep, $after); + if ( is_wp_error( $return ) ) + return false; + else + echo $return; } ?> diff --git a/wp-includes/category.php b/wp-includes/category.php index 9fa9d1f15..71e5be8bd 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -30,6 +30,8 @@ function &get_categories($args = '') { // Handles category caching. function &get_category($category, $output = OBJECT, $filter = 'raw') { $category = get_term($category, 'category', $output, $filter); + if ( is_wp_error( $category ) ) + return $category; _make_cat_compat($category); @@ -58,6 +60,8 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE $curcategory = $category; while ( ($curcategory->parent != 0) && ($curcategory->parent != $curcategory->term_id) ) { $curcategory = get_term($curcategory->parent, 'category'); + if ( is_wp_error( $curcategory ) ) + return $curcategory; $path = '/' . $curcategory->slug . $path; } diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 549e749a7..8f9219c59 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -12,6 +12,8 @@ function bloginfo_rss($show = '') { function get_wp_title_rss($sep = '»') { $title = wp_title($sep, false); + if ( is_wp_error( $title ) ) + return $title->get_error_message(); $title = apply_filters('get_wp_title_rss', $title); return $title; } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 0b1e28de3..30a71086d 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -195,6 +195,8 @@ function wp_title($sep = '»', $display = true) { if ( !empty($tag) ) { $tag = get_term($tag, 'post_tag', OBJECT, 'display'); + if ( is_wp_error( $tag ) ) + return $tag; if ( ! empty($tag->name) ) $title = apply_filters('single_tag_title', $tag->name); } diff --git a/wp-includes/query.php b/wp-includes/query.php index fa7a9d10d..4983fe51c 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -940,6 +940,8 @@ class WP_Query { if ( !empty($q['category__not_in']) ) { $ids = get_objects_in_term($q['category__not_in'], 'category'); + if ( is_wp_error( $ids ) ) + return $ids; if ( is_array($ids) && count($ids > 0) ) { $out_posts = "'" . implode("', '", $ids) . "'"; $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)"; @@ -1415,6 +1417,8 @@ class WP_Query { } else if ($this->is_tag) { $tag_id = $this->get('tag_id'); $tag = &get_term($tag_id, 'post_tag'); + if ( is_wp_error( $tag ) ) + return $tag; $this->queried_object = &$tag; $this->queried_object_id = (int) $tag_id; } else if ($this->is_posts_page) { diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 2d4ac9317..b23552c20 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -391,7 +391,6 @@ function get_term_children( $term, $taxonomy ) { function get_term_field( $field, $term, $taxonomy, $context = 'display' ) { $term = (int) $term; $term = get_term( $term, $taxonomy ); - if ( is_wp_error($term) ) return $term; @@ -801,6 +800,8 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) { // Update children to point to new parent if ( is_taxonomy_hierarchical($taxonomy) ) { $term_obj = get_term($term, $taxonomy); + if ( is_wp_error( $term_obj ) ) + return $term_obj; $parent = $term_obj->parent; $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) { $use_id = false; if ( !is_object($term) ) { $term = get_term($term, $taxonomy); + if ( is_wp_error( $term ) ) + return $term; $use_id = true; } diff --git a/wp-mail.php b/wp-mail.php index c78ff97eb..5f11cb17e 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -148,6 +148,8 @@ for ($i=1; $i <= $count; $i++) : $post_data = add_magic_quotes($post_data); $post_ID = wp_insert_post($post_data); + if ( is_wp_error( $post_ID ) ) + echo "\n" . $post_ID->get_error_message(); if (!$post_ID) { // we couldn't post, for whatever reason. better move forward to the next email diff --git a/xmlrpc.php b/xmlrpc.php index 89f80e9ab..5cd080ac2 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -800,6 +800,8 @@ class wp_xmlrpc_server extends IXR_Server { $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); $post_ID = wp_insert_post($post_data); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error(500, $post_ID->get_error_message()); if (!$post_ID) { return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); @@ -1088,6 +1090,8 @@ class wp_xmlrpc_server extends IXR_Server { $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'); $post_ID = wp_insert_post($postdata); + if ( is_wp_error( $post_ID ) ) + return new IXR_Error(500, $post_ID->get_error_message()); if (!$post_ID) { return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));