Skip to:
Content

#4654 closed defect (bug) (fixed)

incorrect usage of $wpdb->prepare()

Reported by: anointed Owned by:
Milestone: 1.7 Priority: normal
Severity: normal Version:
Component: All Components 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 (29)

comment:1 anointed18 months 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 18 months ago by anointed (previous) (diff)

comment:2 anointed18 months 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

comment:3 anointed18 months 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

comment:4 anointed18 months 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 17 months ago by anointed (previous) (diff)

comment:5 anointed18 months 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

comment:6 anointed18 months 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

comment:7 anointed18 months 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

comment:8 anointed17 months 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 17 months ago by anointed (previous) (diff)

comment:9 DJPaul17 months ago

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

comment:10 DJPaul17 months ago

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

comment:11 djpaul17 months ago

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

comment:12 djpaul17 months ago

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

comment:13 djpaul17 months ago

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

comment:14 companyjuice17 months 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
---

comment:15 companyjuice17 months 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
---

comment:16 companyjuice17 months 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
---

comment:17 companyjuice17 months 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)

comment:18 djpaul17 months ago

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

comment:19 djpaul17 months ago

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

comment:20 nexia17 months 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 17 months ago by nexia (previous) (diff)

comment:21 djpaul17 months ago

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

comment:22 cklosows17 months ago

  • Cc cklosowski@… added

comment:23 johnjamesjacoby17 months ago

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

comment:24 djpaul17 months ago

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

comment:25 r-a-y17 months ago

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

comment:26 johnjamesjacoby16 months ago

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

comment:27 johnjamesjacoby16 months ago

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

Looks all fixed up to me. Closing as fixed.

comment:28 chrisclayton14 months 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 14 months ago by chrisclayton (previous) (diff)

comment:29 johnjamesjacoby14 months ago

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

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

Note: See TracTickets for help on using tickets.