Ryan slays the dragon. (Some of these return WP_Error objects.)

git-svn-id: http://svn.automattic.com/wordpress/trunk@5089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2007-03-23 02:05:29 +00:00
parent 4cfeed615c
commit 3d21925922
10 changed files with 25 additions and 25 deletions

View File

@ -430,7 +430,7 @@ EOD;
log_app('Inserting Post. Data:', print_r($post_data,true));
$postID = (int) wp_insert_post($post_data);
$postID = wp_insert_post($post_data);
if (!$postID) {
$this->internal_error('Sorry, your entry could not be posted. Something wrong happened.');
@ -582,7 +582,7 @@ EOD;
);
// Save the data
$postID = (int) wp_insert_attachment($attachment, $file, $post);
$postID = wp_insert_attachment($attachment, $file, $post);
if (!$postID) {
$this->internal_error('Sorry, your entry could not be posted. Something wrong happened.');

View File

@ -115,8 +115,8 @@ case 'add-category' : // On the Fly
$cat_name = trim($cat_name);
if ( !$category_nicename = sanitize_title($cat_name) )
die('0');
if ( !$cat_id = (int) category_exists( $cat_name ) )
$cat_id = (int) wp_create_category( $cat_name );
if ( !$cat_id = category_exists( $cat_name ) )
$cat_id = wp_create_category( $cat_name );
$cat_name = wp_specialchars(stripslashes($cat_name));
$x->add( array(
'what' => 'category',
@ -156,13 +156,13 @@ case 'add-meta' :
die('-1');
if ( $id < 0 ) {
$now = current_time('timestamp', 1);
if ( $pid = (int) wp_insert_post( array(
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))
) ) )
$mid = (int) add_meta( $pid );
$mid = add_meta( $pid );
else
die('0');
} else if ( !$mid = (int) add_meta( $id ) ) {
} else if ( !$mid = add_meta( $id ) ) {
die('0');
}
@ -204,7 +204,7 @@ case 'add-user' :
if ( !current_user_can('edit_users') )
die('-1');
require_once(ABSPATH . WPINC . '/registration.php');
if ( !$user_id = (int) add_user() )
if ( !$user_id = add_user() )
die('0');
elseif ( is_wp_error( $user_id ) ) {
foreach( $user_id->get_error_messages() as $message )
@ -230,8 +230,8 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
if($_POST['post_ID'] < 0) {
$_POST['temp_ID'] = $_POST['post_ID'];
$id = (int) wp_write_post();
if(is_wp_error($id))
$id = wp_write_post();
if( is_wp_error($id) )
die($id->get_error_message());
else
die("$id");

View File

@ -562,9 +562,9 @@ function edit_user( $user_id = 0 ) {
return $errors;
if ( $update ) {
$user_id = (int) wp_update_user( get_object_vars( $user ));
$user_id = wp_update_user( get_object_vars( $user ));
} else {
$user_id = (int) wp_insert_user( get_object_vars( $user ));
$user_id = wp_insert_user( get_object_vars( $user ));
wp_new_user_notification( $user_id );
}
return $user_id;
@ -1969,7 +1969,7 @@ function wp_import_handle_upload() {
);
// Save the data
$id = (int) wp_insert_attachment( $object, $file );
$id = wp_insert_attachment( $object, $file );
return array( 'file' => $file, 'id' => $id );
}

View File

@ -215,7 +215,7 @@ Event.observe( window, 'load', hide_text );
'guid' => $url);
// Save the data
$id = (int) wp_insert_attachment($object, $file);
$id = wp_insert_attachment($object, $file);
$upload = array('file' => $file, 'id' => $id);

View File

@ -201,7 +201,7 @@ class WP_Import {
if ( empty($parent) )
$category_parent = '0';
else
$category_parent = (int) category_exists($parent);
$category_parent = category_exists($parent);
$catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name');

View File

@ -54,7 +54,7 @@ if ( '' == $comment_content )
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID');
$comment_id = (int) wp_new_comment( $commentdata );
$comment_id = wp_new_comment( $commentdata );
$comment = get_comment($comment_id);
if ( !$user->ID ) :

View File

@ -392,7 +392,7 @@ function wp_new_comment( $commentdata ) {
$commentdata['comment_approved'] = wp_allow_comment($commentdata);
$comment_ID = (int) wp_insert_comment($commentdata);
$comment_ID = wp_insert_comment($commentdata);
do_action('comment_post', $comment_ID, $commentdata['comment_approved']);

View File

@ -242,7 +242,7 @@ case 'register' :
if ( empty( $errors ) ) {
$user_pass = substr( md5( uniqid( microtime() ) ), 0, 7);
$user_id = (int) wp_create_user( $user_login, $user_pass, $user_email );
$user_id = wp_create_user( $user_login, $user_pass, $user_email );
if ( !$user_id )
$errors['registerfail'] = sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email'));
else {

View File

@ -136,7 +136,7 @@ for ($i=1; $i <= $count; $i++) :
$post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
$post_data = add_magic_quotes($post_data);
$post_ID = (int) wp_insert_post($post_data);
$post_ID = wp_insert_post($post_data);
if (!$post_ID) {
// we couldn't post, for whatever reason. better move forward to the next email

View File

@ -512,7 +512,7 @@ class wp_xmlrpc_server extends IXR_Server {
"category_description" => $category["description"]
);
$cat_id = (int) wp_insert_category($new_category);
$cat_id = wp_insert_category($new_category);
if(!$cat_id) {
return(new IXR_Error(500, "Sorry, the new category failed."));
}
@ -802,7 +802,7 @@ 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 = (int) wp_insert_post($post_data);
$post_ID = wp_insert_post($post_data);
if (!$post_ID) {
return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
@ -1030,7 +1030,7 @@ class wp_xmlrpc_server extends IXR_Server {
// We've got all the data -- post it:
$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');
$post_ID = (int) wp_insert_post($postdata);
$post_ID = wp_insert_post($postdata);
if (!$post_ID) {
return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
@ -1447,7 +1447,7 @@ class wp_xmlrpc_server extends IXR_Server {
);
// Save the data
$id = (int) wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
$id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ) );
@ -1837,7 +1837,7 @@ class wp_xmlrpc_server extends IXR_Server {
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type');
$comment_ID = (int) wp_new_comment($commentdata);
$comment_ID = wp_new_comment($commentdata);
do_action('pingback_post', $comment_ID);
return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
@ -1855,7 +1855,7 @@ class wp_xmlrpc_server extends IXR_Server {
$url = $args;
$post_ID = (int) url_to_postid($url);
$post_ID = url_to_postid($url);
if (!$post_ID) {
// We aren't sure that the resource is available and/or pingback enabled
return new IXR_Error(33, 'The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');