mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Add some prophylactic int casts and quoting.
git-svn-id: https://develop.svn.wordpress.org/trunk@3740 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -365,7 +365,7 @@ function wp_delete_attachment($postid) {
|
||||
global $wpdb;
|
||||
$postid = (int) $postid;
|
||||
|
||||
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
|
||||
if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$postid'") )
|
||||
return $post;
|
||||
|
||||
if ( 'attachment' != $post->post_type )
|
||||
@@ -374,17 +374,17 @@ function wp_delete_attachment($postid) {
|
||||
$meta = get_post_meta($postid, '_wp_attachment_metadata', true);
|
||||
$file = get_post_meta($postid, '_wp_attached_file', true);
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
|
||||
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = '$postid'");
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid");
|
||||
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = '$postid'");
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid");
|
||||
$wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = '$postid'");
|
||||
|
||||
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
|
||||
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$postid'");
|
||||
|
||||
if ( ! empty($meta['thumb']) ) {
|
||||
// Don't delete the thumb if another attachment uses it
|
||||
if (! $foo = $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> $postid"))
|
||||
if (! $foo = $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> '$postid'"))
|
||||
@ unlink(str_replace(basename($file), $meta['thumb'], $file));
|
||||
}
|
||||
|
||||
@@ -481,9 +481,11 @@ function wp_publish_post($post_id) {
|
||||
function wp_get_post_cats($blogid = '1', $post_ID = 0) {
|
||||
global $wpdb;
|
||||
|
||||
$post_ID = (int) $post_ID;
|
||||
|
||||
$sql = "SELECT category_id
|
||||
FROM $wpdb->post2cat
|
||||
WHERE post_id = $post_ID
|
||||
WHERE post_id = '$post_ID'
|
||||
ORDER BY category_id";
|
||||
|
||||
$result = $wpdb->get_col($sql);
|
||||
|
||||
Reference in New Issue
Block a user