Permalink
Browse files

(int)er the dragon.

git-svn-id: http://svn.automattic.com/wordpress/trunk@5087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent 46fa88b commit 7602d178993fdb07b3175cdaa659ad85a5f2576c matt committed Mar 23, 2007
View
14 app.php
@@ -417,9 +417,9 @@ function create_post() {
if(!current_user_can($cap))
$this->auth_required('Sorry, you do not have the right to edit/publish new posts.');
- $blog_ID = $current_blog->blog_id;
+ $blog_ID = (int )$current_blog->blog_id;
$post_status = ($publish) ? 'publish' : 'draft';
- $post_author = $user->ID;
+ $post_author = (int) $user->ID;
$post_title = $entry->title;
$post_content = $entry->content;
$post_excerpt = $entry->summary;
@@ -430,7 +430,7 @@ function create_post() {
log_app('Inserting Post. Data:', print_r($post_data,true));
- $postID = wp_insert_post($post_data);
+ $postID = (int) 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 = wp_insert_attachment($attachment, $file, $post);
+ $postID = (int) wp_insert_attachment($attachment, $file, $post);
if (!$postID) {
$this->internal_error('Sorry, your entry could not be posted. Something wrong happened.');
@@ -788,7 +788,7 @@ function get_entry_url($postID = NULL) {
global $use_querystring;
if(!isset($postID)) {
global $post;
- $postID = $GLOBALS['post']->ID;
+ $postID = (int) $GLOBALS['post']->ID;
}
if ($use_querystring) {
@@ -810,7 +810,7 @@ function get_media_url($postID = NULL) {
global $use_querystring;
if(!isset($postID)) {
global $post;
- $postID = $GLOBALS['post']->ID;
+ $postID = (int) $GLOBALS['post']->ID;
}
if ($use_querystring) {
@@ -885,7 +885,7 @@ function get_feed($page = 1, $post_type = 'post') {
$wp = $GLOBALS['wp'];
$wp_query = $GLOBALS['wp_query'];
$wpdb = $GLOBALS['wpdb'];
- $blog_id = $GLOBALS['blog_id'];
+ $blog_id = (int) $GLOBALS['blog_id'];
$post_cache = $GLOBALS['post_cache'];
View
@@ -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 = category_exists( $cat_name ) )
- $cat_id = wp_create_category( $cat_name );
+ if ( !$cat_id = (int) category_exists( $cat_name ) )
+ $cat_id = (int) 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 = wp_insert_post( array(
+ if ( $pid = (int) 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 = add_meta( $pid );
+ $mid = (int) add_meta( $pid );
else
die('0');
- } else if ( !$mid = add_meta( $id ) ) {
+ } else if ( !$mid = (int) 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 = add_user() )
+ if ( !$user_id = (int) add_user() )
die('0');
elseif ( is_wp_error( $user_id ) ) {
foreach( $user_id->get_error_messages() as $message )
@@ -230,7 +230,7 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
if($_POST['post_ID'] < 0) {
$_POST['temp_ID'] = $_POST['post_ID'];
- $id = wp_write_post();
+ $id = (int) wp_write_post();
if(is_wp_error($id))
die($id->get_error_message());
else
View
@@ -123,7 +123,7 @@ function wp_insert_category($catarr) {
if (!$update) {
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
- $cat_ID = $wpdb->insert_id;
+ $cat_ID = (int) $wpdb->insert_id;
} else {
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
}
@@ -360,7 +360,7 @@ function wp_insert_link($linkdata) {
WHERE link_id='$link_id'");
} else {
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
- $link_id = $wpdb->insert_id;
+ $link_id = (int) $wpdb->insert_id;
}
wp_set_link_cats($link_id, $link_category);
@@ -114,7 +114,7 @@ function wp_write_post() {
// Reunite any orphaned attachments with their parent
if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
$draft_ids = array();
- if ( $draft_temp_id = array_search( $post_ID, $draft_ids ) )
+ if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
relocate_children( $draft_temp_id, $post_ID );
if ( $temp_id && $temp_id != $draft_temp_id )
relocate_children( $temp_id, $post_ID );
@@ -157,7 +157,7 @@ function fix_attachment_links( $post_ID ) {
if ( 0 == preg_match( $search, $anchor, $id_matches ) )
continue;
- $id = $id_matches[3];
+ $id = (int) $id_matches[3];
// While we have the attachment ID, let's adopt any orphans.
$attachment = & get_post( $id, ARRAY_A );
@@ -290,7 +290,7 @@ function edit_post() {
// Reunite any orphaned attachments with their parent
if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
$draft_ids = array();
- if ( $draft_temp_id = array_search( $post_ID, $draft_ids ) )
+ if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
relocate_children( $draft_temp_id, $post_ID );
// Now that we have an ID we can fix any attachment anchor hrefs
@@ -447,7 +447,7 @@ function get_user_to_edit( $user_id ) {
function add_user() {
if ( func_num_args() ) { // The hackiest hack that ever did hack
global $current_user, $wp_roles;
- $user_id = func_get_arg( 0 );
+ $user_id = (int) func_get_arg( 0 );
if ( isset( $_POST['role'] ) ) {
if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ) ) {
@@ -465,7 +465,7 @@ function edit_user( $user_id = 0 ) {
global $current_user, $wp_roles, $wpdb;
if ( $user_id != 0 ) {
$update = true;
- $user->ID = $user_id;
+ $user->ID = (int) $user_id;
$userdata = get_userdata( $user_id );
$user->user_login = $wpdb->escape( $userdata->user_login );
} else {
@@ -562,9 +562,9 @@ function edit_user( $user_id = 0 ) {
return $errors;
if ( $update ) {
- $user_id = wp_update_user( get_object_vars( $user ));
+ $user_id = (int) wp_update_user( get_object_vars( $user ));
} else {
- $user_id = wp_insert_user( get_object_vars( $user ));
+ $user_id = (int) wp_insert_user( get_object_vars( $user ));
wp_new_user_notification( $user_id );
}
return $user_id;
@@ -793,8 +793,8 @@ function _cat_row( $category, $level, $name_override = false ) {
$pad = str_repeat( '&#8212; ', $level );
if ( current_user_can( 'manage_categories' ) ) {
$edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__( 'Edit' )."</a></td>";
- $default_cat_id = get_option( 'default_category' );
- $default_link_cat_id = get_option( 'default_link_category' );
+ $default_cat_id = (int) get_option( 'default_category' );
+ $default_link_cat_id = (int) get_option( 'default_link_category' );
if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) )
$edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>";
@@ -833,7 +833,7 @@ function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
$post->post_title = wp_specialchars( $post->post_title );
$pad = str_repeat( '&#8212; ', $level );
- $id = $post->ID;
+ $id = (int) $post->ID;
$class = ('alternate' == $class ) ? '' : 'alternate';
?>
<tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
@@ -1969,7 +1969,7 @@ function wp_import_handle_upload() {
);
// Save the data
- $id = wp_insert_attachment( $object, $file );
+ $id = (int) wp_insert_attachment( $object, $file );
return array( 'file' => $file, 'id' => $id );
}
Oops, something went wrong.

0 comments on commit 7602d17

Please sign in to comment.