Support » Plugin: Achievements for WordPress » Bug Report: Needs updating for WP 3.5

  • Resolved Prometheus Fire

    (@prometheus-fire)


    Just updated to WP 3.5 and Achievements is now throwing the same error that a lot of other plugins started giving with 3.5. Reporting this so it can hopefully get a quick fix to get it back on track.

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/myaccoutn/public_html/wp-content/plugins/achievements/includes/achievements-core.php on line 453 and defined in /home/myaccount/public_html/wp-includes/wp-db.php on line 990

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/myaccount/public_html/wp-content/plugins/achievements/includes/achievements-classes.php on line 676 and defined in /home/myaccount/public_html/wp-includes/wp-db.php on line 990

    http://wordpress.org/extend/plugins/achievements/

Viewing 14 replies - 1 through 14 (of 14 total)
  • I have had a few plugins trigger these errors with 3.5. The author needs to read this:

    PHP Warning: Missing argument 2 for wpdb::prepare()

    Just jumping in to offer an update. On another thread Paul (dev for Achievements) notified another user with the same problem, that he is in the process for updating the plugin for WP 3.5 and BP 1.6/1.7

    The recent changes in WP and BP were extremely large and apparently have caused a significant amount of conflicts with several plugins. Paul is very active in BP Community, so I’m sure a fix is only a very short time away.

    The fix is easy:

    Edit achievements-classes.php line 676 from

    $admin_sql = $wpdb->prepare( "AND (is_active = 1 OR is_active = 2)" );

    to be

    $admin_sql = $wpdb->prepare( "AND (is_active = 1 OR is_active = 2)", NULL );

    And Edit
    achievements-core.php line 453 from

    $actions = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT action.name FROM {$bp->achievements->table_achievements} as achievement, {$bp->achievements->table_actions} as action WHERE achievement.action_id = action.id AND achievement.action_id != -1 AND (achievement.is_active = 1 OR achievement.is_active = 2)" ) );

    to

    $actions = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT action.name FROM {$bp->achievements->table_achievements} as achievement, {$bp->achievements->table_actions} as action WHERE achievement.action_id = action.id AND achievement.action_id != -1 AND (achievement.is_active = 1 OR achievement.is_active = 2)",NULL ) );

    The $wpdb->prepare expects an additional parameter to adding the NULL makes to work as it did previously.

    Norm

    (@casualmagic)

    FYI.

    There are many other instances of the prepare expectations. But if you add “, NULL” in similar places where the errors occur then the plugin gets back to work. If the plugin author wants a copy of my updated files to push toward an update I’d be happy to pass along.

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    If you want to email me a copy of the modified versions of the 2.* version of Achievements to clear these notices, I’ll gladly release the version. paul@byotos.com

    From a 99.9% Newb perspective (I use WP to build a teaching tool for my classroom and am moving it to WP after using ELGG for a couple of years) Charlielove’s method above worked perfectly for me. I have not thoroughly tested Achievements and their use yet, but the error messages on top of the screen are gone, and the plugin SEEMS to be functioning correctly as of right now…. just FYI.

    Thank you all for the plugin and support!

    I’ve done the above fix and it all worked fine until I navigated to the achievements directory. There it shows the familiar error with a few different details.

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/84/7713384/html/wp-content/plugins/achievements/includes/achievements-classes.php on line 448 and defined in /home/content/84/7713384/html/wp-includes/wp-db.php on line 990

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/content/84/7713384/html/wp-content/plugins/achievements/includes/achievements-classes.php on line 449 and defined in /home/content/84/7713384/html/wp-includes/wp-db.php on line 990

    Any workaround for these errors?

    Yup, I’ve got the same issue as teorourke, all errors disappear and functionality seems to work fine, but the errors due show yup in the achievements directory…

    everything worked for me after editing the achievements-core and achievements-classes, THANK YOU SO MUCH for posting this fix. it was so bad before i fixed it, i couldn’t even access my wp-admin. i ended up going through my ftp file manager to make the changes. it was tense, but ultimately smoothly implemented. thanks again, hope this helps other people, and welcome to wordpress 3.5 everybody 😀

    Not wanting to dig in and randomly place , NULL into the 30-some odd “prepare expectations” (which ones to edit or not is WAY beyond me…) looking at maineyak’s link the first section:

    First, if you’re a user and you want to get rid of these errors, you should turn off the displaying of errors in PHP. There are many ways to do this, such as in php.ini, .htaccess, etc. For this, you can just put this in wp-config.php. (Note that hiding errors on production sites is good practice anyway.)

    @ini_set(‘display_errors’, 0);

    This SEEMS to have worked… BUT I am not 100% sure this is a good idea? Correct me if I am wrong, but this is basically telling the ENTIRE WP site to turn OFF error messages? Is this an OK fix until an Achievements update is put out? Thanks,

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    I’ve just released version 2.4 of achievements which fixes these errors. Thanks for everyone’s patience.

    Paul, thanks, please see my reply from 2 days ago, I’ve already edited the achievements-core and achievements-classes, is there anything I should do or change before updating to 2.4?

    thx

    Plugin Author Paul Wong-Gibbs

    (@djpaul)

    Hi maxgoldberg,

    As long as you didn’t make any other changes to files in the Achievements plugin, you should be safe to update.

    Great, I updated and seems to be working fine.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Bug Report: Needs updating for WP 3.5’ is closed to new replies.