Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

git-svn-id: http://core.svn.wordpress.org/trunk@5089 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit a738b423d7f270882a9d486637b318aa3da72c67 1 parent 9ff77c4
Matt Mullenweg m authored
4 app.php
@@ -430,7 +430,7 @@ function create_post() {
430 430
431 431 log_app('Inserting Post. Data:', print_r($post_data,true));
432 432
433   - $postID = (int) wp_insert_post($post_data);
  433 + $postID = wp_insert_post($post_data);
434 434
435 435 if (!$postID) {
436 436 $this->internal_error('Sorry, your entry could not be posted. Something wrong happened.');
@@ -582,7 +582,7 @@ function create_attachment() {
582 582 );
583 583
584 584 // Save the data
585   - $postID = (int) wp_insert_attachment($attachment, $file, $post);
  585 + $postID = wp_insert_attachment($attachment, $file, $post);
586 586
587 587 if (!$postID) {
588 588 $this->internal_error('Sorry, your entry could not be posted. Something wrong happened.');
16 wp-admin/admin-ajax.php
@@ -115,8 +115,8 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
115 115 $cat_name = trim($cat_name);
116 116 if ( !$category_nicename = sanitize_title($cat_name) )
117 117 die('0');
118   - if ( !$cat_id = (int) category_exists( $cat_name ) )
119   - $cat_id = (int) wp_create_category( $cat_name );
  118 + if ( !$cat_id = category_exists( $cat_name ) )
  119 + $cat_id = wp_create_category( $cat_name );
120 120 $cat_name = wp_specialchars(stripslashes($cat_name));
121 121 $x->add( array(
122 122 'what' => 'category',
@@ -156,13 +156,13 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
156 156 die('-1');
157 157 if ( $id < 0 ) {
158 158 $now = current_time('timestamp', 1);
159   - if ( $pid = (int) wp_insert_post( array(
  159 + if ( $pid = wp_insert_post( array(
160 160 'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
161 161 ) ) )
162   - $mid = (int) add_meta( $pid );
  162 + $mid = add_meta( $pid );
163 163 else
164 164 die('0');
165   - } else if ( !$mid = (int) add_meta( $id ) ) {
  165 + } else if ( !$mid = add_meta( $id ) ) {
166 166 die('0');
167 167 }
168 168
@@ -204,7 +204,7 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
204 204 if ( !current_user_can('edit_users') )
205 205 die('-1');
206 206 require_once(ABSPATH . WPINC . '/registration.php');
207   - if ( !$user_id = (int) add_user() )
  207 + if ( !$user_id = add_user() )
208 208 die('0');
209 209 elseif ( is_wp_error( $user_id ) ) {
210 210 foreach( $user_id->get_error_messages() as $message )
@@ -230,8 +230,8 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
230 230
231 231 if($_POST['post_ID'] < 0) {
232 232 $_POST['temp_ID'] = $_POST['post_ID'];
233   - $id = (int) wp_write_post();
234   - if(is_wp_error($id))
  233 + $id = wp_write_post();
  234 + if( is_wp_error($id) )
235 235 die($id->get_error_message());
236 236 else
237 237 die("$id");
6 wp-admin/admin-functions.php
@@ -562,9 +562,9 @@ function edit_user( $user_id = 0 ) {
562 562 return $errors;
563 563
564 564 if ( $update ) {
565   - $user_id = (int) wp_update_user( get_object_vars( $user ));
  565 + $user_id = wp_update_user( get_object_vars( $user ));
566 566 } else {
567   - $user_id = (int) wp_insert_user( get_object_vars( $user ));
  567 + $user_id = wp_insert_user( get_object_vars( $user ));
568 568 wp_new_user_notification( $user_id );
569 569 }
570 570 return $user_id;
@@ -1969,7 +1969,7 @@ function wp_import_handle_upload() {
1969 1969 );
1970 1970
1971 1971 // Save the data
1972   - $id = (int) wp_insert_attachment( $object, $file );
  1972 + $id = wp_insert_attachment( $object, $file );
1973 1973
1974 1974 return array( 'file' => $file, 'id' => $id );
1975 1975 }
2  wp-admin/custom-header.php
@@ -215,7 +215,7 @@ function step_2() {
215 215 'guid' => $url);
216 216
217 217 // Save the data
218   - $id = (int) wp_insert_attachment($object, $file);
  218 + $id = wp_insert_attachment($object, $file);
219 219
220 220 $upload = array('file' => $file, 'id' => $id);
221 221
2  wp-admin/import/wordpress.php
@@ -201,7 +201,7 @@ function process_categories() {
201 201 if ( empty($parent) )
202 202 $category_parent = '0';
203 203 else
204   - $category_parent = (int) category_exists($parent);
  204 + $category_parent = category_exists($parent);
205 205
206 206 $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name');
207 207
2  wp-comments-post.php
@@ -54,7 +54,7 @@
54 54
55 55 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID');
56 56
57   -$comment_id = (int) wp_new_comment( $commentdata );
  57 +$comment_id = wp_new_comment( $commentdata );
58 58
59 59 $comment = get_comment($comment_id);
60 60 if ( !$user->ID ) :
2  wp-includes/comment.php
@@ -392,7 +392,7 @@ function wp_new_comment( $commentdata ) {
392 392
393 393 $commentdata['comment_approved'] = wp_allow_comment($commentdata);
394 394
395   - $comment_ID = (int) wp_insert_comment($commentdata);
  395 + $comment_ID = wp_insert_comment($commentdata);
396 396
397 397 do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
398 398
2  wp-login.php
@@ -242,7 +242,7 @@ function focusit() {
242 242 if ( empty( $errors ) ) {
243 243 $user_pass = substr( md5( uniqid( microtime() ) ), 0, 7);
244 244
245   - $user_id = (int) wp_create_user( $user_login, $user_pass, $user_email );
  245 + $user_id = wp_create_user( $user_login, $user_pass, $user_email );
246 246 if ( !$user_id )
247 247 $errors['registerfail'] = sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email'));
248 248 else {
2  wp-mail.php
@@ -136,7 +136,7 @@
136 136 $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status');
137 137 $post_data = add_magic_quotes($post_data);
138 138
139   - $post_ID = (int) wp_insert_post($post_data);
  139 + $post_ID = wp_insert_post($post_data);
140 140
141 141 if (!$post_ID) {
142 142 // we couldn't post, for whatever reason. better move forward to the next email
12 xmlrpc.php
@@ -512,7 +512,7 @@ function wp_newCategory($args) {
512 512 "category_description" => $category["description"]
513 513 );
514 514
515   - $cat_id = (int) wp_insert_category($new_category);
  515 + $cat_id = wp_insert_category($new_category);
516 516 if(!$cat_id) {
517 517 return(new IXR_Error(500, "Sorry, the new category failed."));
518 518 }
@@ -802,7 +802,7 @@ function blogger_newPost($args) {
802 802
803 803 $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status');
804 804
805   - $post_ID = (int) wp_insert_post($post_data);
  805 + $post_ID = wp_insert_post($post_data);
806 806
807 807 if (!$post_ID) {
808 808 return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
@@ -1030,7 +1030,7 @@ function mw_newPost($args) {
1030 1030 // We've got all the data -- post it:
1031 1031 $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');
1032 1032
1033   - $post_ID = (int) wp_insert_post($postdata);
  1033 + $post_ID = wp_insert_post($postdata);
1034 1034
1035 1035 if (!$post_ID) {
1036 1036 return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
@@ -1447,7 +1447,7 @@ function mw_newMediaObject($args) {
1447 1447 );
1448 1448
1449 1449 // Save the data
1450   - $id = (int) wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
  1450 + $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $post_id );
1451 1451 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
1452 1452
1453 1453 return apply_filters( 'wp_handle_upload', array( 'file' => $name, 'url' => $upload[ 'url' ], 'type' => $type ) );
@@ -1837,7 +1837,7 @@ function pingback_ping($args) {
1837 1837
1838 1838 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type');
1839 1839
1840   - $comment_ID = (int) wp_new_comment($commentdata);
  1840 + $comment_ID = wp_new_comment($commentdata);
1841 1841 do_action('pingback_post', $comment_ID);
1842 1842
1843 1843 return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
@@ -1855,7 +1855,7 @@ function pingback_extensions_getPingbacks($args) {
1855 1855
1856 1856 $url = $args;
1857 1857
1858   - $post_ID = (int) url_to_postid($url);
  1858 + $post_ID = url_to_postid($url);
1859 1859 if (!$post_ID) {
1860 1860 // We aren't sure that the resource is available and/or pingback enabled
1861 1861 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.');

0 comments on commit a738b42

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