Skip to content

Commit fb1e637

Browse files
committed
Some int casts
git-svn-id: https://develop.svn.wordpress.org/branches/2.0@5099 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 32c7c1f commit fb1e637

7 files changed

Lines changed: 53 additions & 51 deletions

File tree

wp-admin/admin-db.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function wp_insert_category($catarr) {
110110

111111
if (!$update) {
112112
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
113-
$cat_ID = $wpdb->insert_id;
113+
$cat_ID = (int) $wpdb->insert_id;
114114
} else {
115115
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
116116
}
@@ -207,7 +207,7 @@ function category_exists($cat_name) {
207207
if (!$category_nicename = sanitize_title($cat_name))
208208
return 0;
209209

210-
return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
210+
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
211211
}
212212

213213
function wp_delete_user($id, $reassign = 'novalue') {
@@ -270,6 +270,8 @@ function wp_insert_link($linkdata) {
270270
if ( !empty($link_id) )
271271
$update = true;
272272

273+
$link_id = (int) $link_id;
274+
273275
if( trim( $link_name ) == '' )
274276
return 0;
275277
$link_name = apply_filters('pre_link_name', $link_name);
@@ -326,7 +328,7 @@ function wp_insert_link($linkdata) {
326328
WHERE link_id='$link_id'");
327329
} else {
328330
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
329-
$link_id = $wpdb->insert_id;
331+
$link_id = (int) $wpdb->insert_id;
330332
}
331333

332334
if ( $update )

wp-admin/edit-comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function checkAll(form)
4444
$i = 0;
4545
foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
4646
$comment = (int) $comment;
47-
$post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
47+
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
4848
$authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
4949
if ( current_user_can('edit_post', $post_id) ) :
5050
wp_set_comment_status($comment, "delete");

wp-admin/import/dotclear.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ function comments2wp($comments='')
430430
extract($comment);
431431

432432
// WordPressify Data
433-
$comment_ID = ltrim($comment_id, '0');
434-
$comment_post_ID = $postarr[$post_id];
433+
$comment_ID = (int) ltrim($comment_id, '0');
434+
$comment_post_ID = (int) $postarr[$post_id];
435435
$comment_approved = "$comment_pub";
436436
$name = $wpdb->escape(csc ($comment_auteur));
437437
$email = $wpdb->escape($comment_email);

wp-admin/import/livejournal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function import_posts() {
8080
$comments = $comments[1];
8181

8282
if ( $comments ) {
83-
$comment_post_ID = $post_id;
83+
$comment_post_ID = (int) $post_id;
8484
$num_comments = 0;
8585
foreach ($comments as $comment) {
8686
preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);

wp-admin/import/mt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function select_authors() {
169169
return;
170170
}
171171
$this->file = $file['file'];
172-
$this->id = $file['id'];
172+
$this->id = (int) $file['id'];
173173

174174
$this->get_entries();
175175
$this->mt_authors_form();
@@ -293,7 +293,7 @@ function process_posts() {
293293
}
294294
}
295295

296-
$comment_post_ID = $post_id;
296+
$comment_post_ID = (int) $post_id;
297297
$comment_approved = 1;
298298

299299
// Now for comments

wp-trackback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function trackback_response($error = 0, $error_message = '') {
8484
$title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
8585
}
8686

87-
$comment_post_ID = $tb_id;
87+
$comment_post_ID = (int) $tb_id;
8888
$comment_author = $blog_name;
8989
$comment_author_email = '';
9090
$comment_author_url = $tb_url;

xmlrpc.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,9 @@ function blogger_getPost($args) {
208208

209209
$this->escape($args);
210210

211-
$post_ID = $args[1];
212-
$user_login = $args[2];
213-
$user_pass = $args[3];
211+
$post_ID = (int) $args[1];
212+
$user_login = $args[2];
213+
$user_pass = $args[3];
214214

215215
if (!$this->login_pass_ok($user_login, $user_pass)) {
216216
return $this->error;
@@ -243,10 +243,10 @@ function blogger_getRecentPosts($args) {
243243

244244
$this->escape($args);
245245

246-
$blog_ID = $args[1]; /* though we don't use it yet */
247-
$user_login = $args[2];
248-
$user_pass = $args[3];
249-
$num_posts = $args[4];
246+
$blog_ID = (int) $args[1]; /* though we don't use it yet */
247+
$user_login = $args[2];
248+
$user_pass = $args[3];
249+
$num_posts = $args[4];
250250

251251
if (!$this->login_pass_ok($user_login, $user_pass)) {
252252
return $this->error;
@@ -291,7 +291,7 @@ function blogger_getTemplate($args) {
291291

292292
$this->escape($args);
293293

294-
$blog_ID = $args[1];
294+
$blog_ID = (int) $args[1];
295295
$user_login = $args[2];
296296
$user_pass = $args[3];
297297
$template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
@@ -325,7 +325,7 @@ function blogger_setTemplate($args) {
325325

326326
$this->escape($args);
327327

328-
$blog_ID = $args[1];
328+
$blog_ID = (int) $args[1];
329329
$user_login = $args[2];
330330
$user_pass = $args[3];
331331
$content = $args[4];
@@ -362,7 +362,7 @@ function blogger_newPost($args) {
362362

363363
$this->escape($args);
364364

365-
$blog_ID = $args[1]; /* though we don't use it yet */
365+
$blog_ID = (int) $args[1]; /* though we don't use it yet */
366366
$user_login = $args[2];
367367
$user_pass = $args[3];
368368
$content = $args[4];
@@ -459,7 +459,7 @@ function blogger_deletePost($args) {
459459

460460
$this->escape($args);
461461

462-
$post_ID = $args[1];
462+
$post_ID = (int) $args[1];
463463
$user_login = $args[2];
464464
$user_pass = $args[3];
465465
$publish = $args[4];
@@ -500,7 +500,7 @@ function mw_newPost($args) {
500500

501501
$this->escape($args);
502502

503-
$blog_ID = $args[0]; // we will support this in the near future
503+
$blog_ID = (int) $args[0]; // we will support this in the near future
504504
$user_login = $args[1];
505505
$user_pass = $args[2];
506506
$content_struct = $args[3];
@@ -668,7 +668,7 @@ function mw_getPost($args) {
668668

669669
$this->escape($args);
670670

671-
$post_ID = $args[0];
671+
$post_ID = (int) $args[0];
672672
$user_login = $args[1];
673673
$user_pass = $args[2];
674674

@@ -723,10 +723,10 @@ function mw_getRecentPosts($args) {
723723

724724
$this->escape($args);
725725

726-
$blog_ID = $args[0];
727-
$user_login = $args[1];
728-
$user_pass = $args[2];
729-
$num_posts = $args[3];
726+
$blog_ID = (int) $args[0];
727+
$user_login = $args[1];
728+
$user_pass = $args[2];
729+
$num_posts = (int) $args[3];
730730

731731
if (!$this->login_pass_ok($user_login, $user_pass)) {
732732
return $this->error;
@@ -789,9 +789,9 @@ function mw_getCategories($args) {
789789

790790
$this->escape($args);
791791

792-
$blog_ID = $args[0];
793-
$user_login = $args[1];
794-
$user_pass = $args[2];
792+
$blog_ID = (int) $args[0];
793+
$user_login = $args[1];
794+
$user_pass = $args[2];
795795

796796
if (!$this->login_pass_ok($user_login, $user_pass)) {
797797
return $this->error;
@@ -823,7 +823,7 @@ function mw_newMediaObject($args) {
823823

824824
global $wpdb;
825825

826-
$blog_ID = $wpdb->escape($args[0]);
826+
$blog_ID = (int) $args[0];
827827
$user_login = $wpdb->escape($args[1]);
828828
$user_pass = $wpdb->escape($args[2]);
829829
$data = $args[3];
@@ -863,10 +863,10 @@ function mt_getRecentPostTitles($args) {
863863

864864
$this->escape($args);
865865

866-
$blog_ID = $args[0];
867-
$user_login = $args[1];
868-
$user_pass = $args[2];
869-
$num_posts = $args[3];
866+
$blog_ID = (int) $args[0];
867+
$user_login = $args[1];
868+
$user_pass = $args[2];
869+
$num_posts = (int) $args[3];
870870

871871
if (!$this->login_pass_ok($user_login, $user_pass)) {
872872
return $this->error;
@@ -908,9 +908,9 @@ function mt_getCategoryList($args) {
908908

909909
$this->escape($args);
910910

911-
$blog_ID = $args[0];
912-
$user_login = $args[1];
913-
$user_pass = $args[2];
911+
$blog_ID = (int) $args[0];
912+
$user_login = $args[1];
913+
$user_pass = $args[2];
914914

915915
if (!$this->login_pass_ok($user_login, $user_pass)) {
916916
return $this->error;
@@ -937,9 +937,9 @@ function mt_getPostCategories($args) {
937937

938938
$this->escape($args);
939939

940-
$post_ID = $args[0];
941-
$user_login = $args[1];
942-
$user_pass = $args[2];
940+
$post_ID = (int) $args[0];
941+
$user_login = $args[1];
942+
$user_pass = $args[2];
943943

944944
if (!$this->login_pass_ok($user_login, $user_pass)) {
945945
return $this->error;
@@ -967,10 +967,10 @@ function mt_setPostCategories($args) {
967967

968968
$this->escape($args);
969969

970-
$post_ID = $args[0];
971-
$user_login = $args[1];
972-
$user_pass = $args[2];
973-
$categories = $args[3];
970+
$post_ID = (int) $args[0];
971+
$user_login = $args[1];
972+
$user_pass = $args[2];
973+
$categories = $args[3];
974974

975975
if (!$this->login_pass_ok($user_login, $user_pass)) {
976976
return $this->error;
@@ -1050,9 +1050,9 @@ function mt_publishPost($args) {
10501050

10511051
$this->escape($args);
10521052

1053-
$post_ID = $args[0];
1054-
$user_login = $args[1];
1055-
$user_pass = $args[2];
1053+
$post_ID = (int) $args[0];
1054+
$user_login = $args[1];
1055+
$user_pass = $args[2];
10561056

10571057
if (!$this->login_pass_ok($user_login, $user_pass)) {
10581058
return $this->error;
@@ -1112,18 +1112,18 @@ function pingback_ping($args) {
11121112
} elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
11131113
// the path defines the post_ID (archives/p/XXXX)
11141114
$blah = explode('/', $match[0]);
1115-
$post_ID = $blah[1];
1115+
$post_ID = (int) $blah[1];
11161116
$way = 'from the path';
11171117
} elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
11181118
// the querystring defines the post_ID (?p=XXXX)
11191119
$blah = explode('=', $match[0]);
1120-
$post_ID = $blah[1];
1120+
$post_ID = (int) $blah[1];
11211121
$way = 'from the querystring';
11221122
} elseif (isset($urltest['fragment'])) {
11231123
// an #anchor is there, it's either...
11241124
if (intval($urltest['fragment'])) {
11251125
// ...an integer #XXXX (simpliest case)
1126-
$post_ID = $urltest['fragment'];
1126+
$post_ID = (int) $urltest['fragment'];
11271127
$way = 'from the fragment (numeric)';
11281128
} elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) {
11291129
// ...a post id in the form 'post-###'

0 commit comments

Comments
 (0)