Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 11 years ago

Last modified 8 years ago

#4654 closed defect (bug) (fixed)

incorrect usage of $wpdb->prepare()

Reported by: anointed's profile anointed Owned by:
Milestone: 1.7 Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc: cklosowski@…

Description

Keeping an eye out on my log files for warnings about prepare. I will continue appending new ones as they show up in my log files

1st one:

argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-messages/bp-messages-classes.php on line 558

Change History (31)

#1 @anointed
12 years ago

#2-friends-classes

 Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-friends/bp-friends-classes.php on line 94
Last edited 12 years ago by anointed (previous) (diff)

#2 @anointed
12 years ago

#3 activity-classes

 Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-activity/bp-activity-classes.php on line 219

#3 @anointed
12 years ago

#4 activity-classes

 Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-activity/bp-activity-classes.php on line 231

#4 @anointed
12 years ago

#5 activity-classes line 236, 239

 Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-activity/bp-activity-classes.php on line 236
 mod_fcgid: stderr: PHP Warning:  Missing argument 2 for wpdb::prepare(), called in /buddypress/bp-activity/bp-activity-classes.php on line 239
Last edited 12 years ago by anointed (previous) (diff)

#5 @anointed
12 years ago

#6 activity-classes

 Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-activity/bp-activity-classes.php on line 250

#6 @anointed
12 years ago

#7 friends-classes

 Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-friends/bp-friends-classes.php on line 90

#7 @anointed
12 years ago

#8 #9 #10 bp-blogs-classes Line 116, 117, 296

mod_fcgid: stderr: PHP Warning:  Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-blogs/bp-blogs-classes.php on line 116
mod_fcgid: stderr: PHP Warning:  Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-blogs/bp-blogs-classes.php on line 117
 mod_fcgid: stderr: PHP Warning:  Missing argument 2 for wpdb::prepare(), called in /wp-content/plugins/buddypress/bp-blogs/bp-blogs-classes.php on line 296

#8 @anointed
12 years ago

bp-xprofile line 139, 173, 333

 mod_fcgid: stderr: PHP Warning:  Missing argument 2 for wpdb::prepare(), called in /buddypress/bp-xprofile/bp-xprofile-classes.php on line 139
Missing argument 2 for wpdb::prepare(), called in /buddypress/bp-xprofile/bp-xprofile-classes.php on line 173 
Missing argument 2 for wpdb::prepare(), called in /buddypress/bp-xprofile/bp-xprofile-classes.php on line 333
Last edited 12 years ago by anointed (previous) (diff)

#9 @DJPaul
12 years ago

  • Component changed from Core to All Components
  • Milestone changed from Awaiting Review to 1.7

#10 @DJPaul
12 years ago

JJJ's committed r6492, r6493, r6494, r6495, r6497 against some of these.

#11 @djpaul
12 years ago

(In [6498]) Remove more unneeded prepare() calls in bp-activity-classes.php. See #4654

#12 @djpaul
12 years ago

(In [6499]) Remove more unneeded prepare() calls on the BuddyPress admin screen. See #4654

#13 @djpaul
12 years ago

(In [6500]) Remove unneeded prepare() calls from the group directory screen. See #4654

#14 @companyjuice
12 years ago

Here are 3 that popped up for me on a fresh WordPress 3.5 beta 2 install and svn checkout of BuddyPress on 2012-11-12 ~12:00PM:
---
Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-core\bp-core-functions.php on line 176 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-core\bp-core-options.php on line 296 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-core\admin\bp-core-functions.php on line 220 and defined in \wordpress\wp-includes\wp-db.php on line 990
---

#15 @companyjuice
12 years ago

Others from front-end:
---
Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-groups\bp-groups-classes.php on line 674 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-core\bp-core-classes.php on line 355 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-filters.php on line 237 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-activity\bp-activity-classes.php on line 219 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-activity\bp-activity-classes.php on line 231 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-activity\bp-activity-classes.php on line 236 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-friends\bp-friends-classes.php on line 88 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-friends\bp-friends-classes.php on line 90 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-friends\bp-friends-classes.php on line 94 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-classes.php on line 139 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-classes.php on line 333 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-classes.php on line 173 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-classes.php on line 136 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-classes.php on line 141 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-xprofile\bp-xprofile-classes.php on line 167 and defined in \wordpress\wp-includes\wp-db.php on line 990
---

#16 @companyjuice
12 years ago

These 4 popped up in admin groups page:
---
Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-groups\bp-groups-classes.php on line 761 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-groups\bp-groups-classes.php on line 762 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-groups\bp-groups-classes.php on line 763 and defined in \wordpress\wp-includes\wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in \wordpress\wp-content\plugins\buddypress\bp-groups\bp-groups-classes.php on line 764 and defined in \wordpress\wp-includes\wp-db.php on line 990
---

#17 @companyjuice
12 years ago

For visitors reading this, the workaround/fix for these is to remove the $wpdb->prepare(); function that only has 1 string argument, for example, on line 94 of \wordpress\wp-content\plugins\buddypress\bp-friends\bp-friends-classes.php:

$friends = $wpdb->get_results( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" ) );

BECOMES:

$friends = $wpdb->get_results( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" );

---
Thanks -- Marty McGee (companyjuice)

#18 @djpaul
12 years ago

(In [6518]) Fix more prepare() warnings. See #4654

#19 @djpaul
12 years ago

(In [6521]) Fix more prepare() warnings in Activity. See #4654

#20 @nexia
12 years ago

Warning: Missing argument 2 for wpdb::prepare(), called in /home/nexialys/public_html/core/wp-content/plugins/buddypress/bp-core/bp-core-functions.php on line 176 and defined in /home/nexialys/public_html/core/wp-includes/wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in /home/nexialys/public_html/core/wp-content/plugins/buddypress/bp-core/bp-core-options.php on line 296 and defined in /home/nexialys/public_html/core/wp-includes/wp-db.php on line 990

Warning: Missing argument 2 for wpdb::prepare(), called in /home/nexialys/public_html/core/wp-content/plugins/buddypress/bp-core/admin/bp-core-functions.php on line 217 and defined in /home/nexialys/public_html/core/wp-includes/wp-db.php on line 990

########

btw, just add $args = "" in the proper line 990 in wp-db.php would avoid all these alerts with no problem...

Last edited 12 years ago by nexia (previous) (diff)

#21 @djpaul
12 years ago

(In [6533]) Fix a prepare() warning when filtering comments. See #4654

#22 @cklosows
12 years ago

  • Cc cklosowski@… added

#23 @johnjamesjacoby
12 years ago

(In [6539]) Fix incorrect prepare() usages in Blogs component. See #4654. (trunk)

#24 @djpaul
12 years ago

(In [6557]) Fix alot of WPDB->Prepare() warnings in the 1.6 branch. See #4654

#25 @r-a-y
12 years ago

(In [6573]) Fix wpdb::prepare() warnings in BP_Groups_Group::get_group_type_ids(). See #4654.

#26 @johnjamesjacoby
12 years ago

(In [6575]) Query variable and prepare() usage audit. See #4654. (1.6 branch)

#27 @johnjamesjacoby
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Looks all fixed up to me. Closing as fixed.

#28 @chrisclayton
11 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
  1. Fresh install, with (current) trunk
  2. custom profile fields.
  3. add details to the profile field and change the visibility to, for example 'friends only'.
  4. log out and view profile.
  5. profit:

[07-Feb-2013 08:07:31] PHP Notice: wpdb::prepare was called <strong>incorrectly</strong>. wpdb::prepare() requires at least two arguments. Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.5.) in wp-includes/functions.php on line 2959

From a quick glance, I'm pretty sure it's the exclude_fields_sql http://buddypress.trac.wordpress.org/browser/trunk/bp-xprofile/bp-xprofile-classes.php#L167 but don't have time to look into it at the moment.

Last edited 11 years ago by chrisclayton (previous) (diff)

#29 @johnjamesjacoby
11 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [6775]) Remove unneeded prepare() call in bp-xprofile-classes.php. Fixes #4654.

#30 @johnjamesjacoby
9 years ago

  • Component changed from Component - Any/All to Tools - Warnings/Notices

#31 @DJPaul
8 years ago

  • Component changed from Tools - Warnings/Notices to Core
Note: See TracTickets for help on using tickets.