Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 3d219259222d771e5f3add9ce501f5cf45f5be8c 1 parent 4cfeed6
matt authored
View
4 app.php
@@ -430,7 +430,7 @@ function create_post() {
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 @@ function create_attachment() {
);
// 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
16 wp-admin/admin-ajax.php
@@ -115,8 +115,8 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
$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 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
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 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
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 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
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
6 wp-admin/admin-functions.php
@@ -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
2  wp-admin/custom-header.php
@@ -215,7 +215,7 @@ function step_2() {
'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
2  wp-admin/import/wordpress.php
@@ -201,7 +201,7 @@ function process_categories() {
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
2  wp-comments-post.php
@@ -54,7 +54,7 @@
$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
2  wp-includes/comment.php
@@ -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
2  wp-login.php
@@ -242,7 +242,7 @@ function focusit() {
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
2  wp-mail.php
@@ -136,7 +136,7 @@
$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
12 xmlrpc.php
@@ -512,7 +512,7 @@ function wp_newCategory($args) {
"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 @@ function blogger_newPost($args) {
$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 @@ function mw_newPost($args) {
// 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 @@ function mw_newMediaObject($args) {
);
// 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 @@ function pingback_ping($args) {
$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 @@ function pingback_extensions_getPingbacks($args) {
$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.');
Please sign in to comment.
Something went wrong with that request. Please try again.