summaryrefslogtreecommitdiffstats
path: root/wp-admin
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-03-23 17:46:02 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-03-23 17:46:02 +0000
commit2e96b99ceb195735a641e299f3209840cc101052 (patch)
tree374954833d10017ae7adb6a031d54fd0dc36f3a2 /wp-admin
parentbf6a271edebcceb76d6e378156e92fe72c1fbb18 (diff)
Ryan casts an int and catches a fish, someone buy him a pint! merge to 5092
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@933 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin')
-rw-r--r--wp-admin/admin-ajax.php2
-rw-r--r--wp-admin/admin-db.php13
-rw-r--r--wp-admin/admin-functions.php16
-rw-r--r--wp-admin/edit-comments.php2
-rw-r--r--wp-admin/import/blogger.php2
-rw-r--r--wp-admin/import/blogware.php2
-rw-r--r--wp-admin/import/dotclear.php4
-rw-r--r--wp-admin/import/livejournal.php2
-rw-r--r--wp-admin/import/mt.php4
-rw-r--r--wp-admin/import/wordpress.php4
-rw-r--r--wp-admin/user-edit.php2
11 files changed, 28 insertions, 25 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index d3103d8..2ad2469 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -231,7 +231,7 @@ case 'autosave' : // The name of this action is hardcoded in edit_post()
if($_POST['post_ID'] < 0) {
$_POST['temp_ID'] = $_POST['post_ID'];
$id = wp_write_post();
- if(is_wp_error($id))
+ if( is_wp_error($id) )
die($id->get_error_message());
else
die("$id");
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
index 26bb2e5..d4df176 100644
--- a/wp-admin/admin-db.php
+++ b/wp-admin/admin-db.php
@@ -250,7 +250,7 @@ function category_exists($cat_name) {
if (!$category_nicename = sanitize_title($cat_name))
return 0;
- return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
+ return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
}
function wp_delete_user($id, $reassign = 'novalue') {
@@ -303,6 +303,8 @@ function wp_insert_link($linkdata) {
if ( !empty($link_id) )
$update = true;
+ $link_id = (int) $link_id;
+
if( trim( $link_name ) == '' )
return 0;
$link_name = apply_filters('pre_link_name', $link_name);
@@ -364,7 +366,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);
@@ -447,7 +449,7 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
$old_categories = $wpdb->get_col("
SELECT category_id
FROM $wpdb->link2cat
- WHERE link_id = $link_ID");
+ WHERE link_id = '$link_ID'");
if (!$old_categories) {
$old_categories = array();
@@ -460,10 +462,11 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
if ($delete_cats) {
foreach ($delete_cats as $del) {
+ $del = (int) $del;
$wpdb->query("
DELETE FROM $wpdb->link2cat
- WHERE category_id = $del
- AND link_id = $link_ID
+ WHERE category_id = '$del'
+ AND link_id = '$link_ID'
");
}
}
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 732d146..7b9507c 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -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 {
@@ -803,8 +803,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>";
@@ -843,7 +843,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; ?>'>
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index 9307b90..0557270 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -56,7 +56,7 @@ if ( !empty( $_POST['delete_comments'] ) ) :
$i = 0;
foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
$comment = (int) $comment;
- $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
+ $post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
// $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
if ( current_user_can('edit_post', $post_id) ) {
if ( !empty( $_POST['spam_button'] ) )
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
index 4614bf6..fdc6004 100644
--- a/wp-admin/import/blogger.php
+++ b/wp-admin/import/blogger.php
@@ -546,7 +546,7 @@ class Blogger_Import {
}
}
- $comment_post_ID = $this->blogs[$importing_blog]['posts'][$entry->old_post_permalink];
+ $comment_post_ID = (int) $this->blogs[$importing_blog]['posts'][$entry->old_post_permalink];
preg_match('#<name>(.+?)</name>.*(?:\<uri>(.+?)</uri>)?#', $entry->author, $matches);
$comment_author = addslashes( $this->no_apos( strip_tags( (string) $matches[1] ) ) );
$comment_author_url = addslashes( $this->no_apos( strip_tags( (string) $matches[2] ) ) );
diff --git a/wp-admin/import/blogware.php b/wp-admin/import/blogware.php
index 2cbf75f..c9e281c 100644
--- a/wp-admin/import/blogware.php
+++ b/wp-admin/import/blogware.php
@@ -104,7 +104,7 @@ class BW_Import {
$comments = $comments[1];
if ( $comments ) {
- $comment_post_ID = $post_id;
+ $comment_post_ID = (int) $post_id;
$num_comments = 0;
foreach ($comments as $comment) {
preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
index 0eb092b..9a32e3a 100644
--- a/wp-admin/import/dotclear.php
+++ b/wp-admin/import/dotclear.php
@@ -437,8 +437,8 @@ class Dotclear_Import {
extract($comment);
// WordPressify Data
- $comment_ID = ltrim($comment_id, '0');
- $comment_post_ID = $postarr[$post_id];
+ $comment_ID = (int) ltrim($comment_id, '0');
+ $comment_post_ID = (int) $postarr[$post_id];
$comment_approved = "$comment_pub";
$name = $wpdb->escape(csc ($comment_auteur));
$email = $wpdb->escape($comment_email);
diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php
index e1389cd..690005b 100644
--- a/wp-admin/import/livejournal.php
+++ b/wp-admin/import/livejournal.php
@@ -82,7 +82,7 @@ class LJ_Import {
$comments = $comments[1];
if ( $comments ) {
- $comment_post_ID = $post_id;
+ $comment_post_ID = (int) $post_id;
$num_comments = 0;
foreach ($comments as $comment) {
preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);
diff --git a/wp-admin/import/mt.php b/wp-admin/import/mt.php
index 733c7fa..1effb5c 100644
--- a/wp-admin/import/mt.php
+++ b/wp-admin/import/mt.php
@@ -154,7 +154,7 @@ class MT_Import {
return;
}
$this->file = $file['file'];
- $this->id = $file['id'];
+ $this->id = (int) $file['id'];
$this->get_entries();
$this->mt_authors_form();
@@ -278,7 +278,7 @@ class MT_Import {
}
}
- $comment_post_ID = $post_id;
+ $comment_post_ID = (int) $post_id;
$comment_approved = 1;
// Now for comments
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index 78d972f..90b616b 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -157,7 +157,7 @@ class WP_Import {
return;
}
$this->file = $file['file'];
- $this->id = $file['id'];
+ $this->id = (int) $file['id'];
$this->get_entries();
$this->wp_authors_form();
@@ -184,7 +184,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');
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
index 6feba01..9760864 100644
--- a/wp-admin/user-edit.php
+++ b/wp-admin/user-edit.php
@@ -13,7 +13,7 @@ wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer
$wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
// Only allow site admins to edit every user.
if ( !is_site_admin() && ($user_id != $current_user->ID) )
- $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
+ wp_die('You do not have permission to edit this user.');
$user_id = (int) $user_id;