• WPDB::Prepare Warning in WordPress 3.5

    I just today upgraded the jMonkeyEngine site to WordPress 3.5 and noticed that one of our plugins was causing errors.  The exact error looks like Missing argument 2 for wpdb::prepare().  Looking at the wp-db.php file that ships with WordPress 3.5, we can see that there is indeed a second argument and it is documented as an array for options:

    @param array|mixed $args The array of variables to substitute into the query’s placeholders if being called like
    {@link http://php.net/vsprintf vsprintf()}, or the first variable to substitute into the query’s placeholders if being called like {@link http://php.net/sprintf sprintf()}.

    Cool, so let’s change the code that calls the prepare method to have an empty array as a second argument:

    <?php
    // Old (single argument) function call
    global $wpdb;
    $authorIDs = $wpdb-&gt;get_col($wpdb-&gt;prepare("SELECT post_author FROM " . $wpdb->posts . " WHERE ID = " . intval($postID) . " LIMIT 1");
    
    // New (two argument) function call
    global $wpdb;
    $authorIDs = $wpdb-&gt;get_col($wpdb-&gt;prepare("SELECT post_author FROM " . $wpdb-&gt;posts . " WHERE ID = " . intval($postID) . " LIMIT 1", array()));
    ?>

    If your queries were previously working, they will indeed continue to wok with the addition of this simple fix (though you may want to investigate using the functionality provided by WP in this new functionality)

  • Cure for your iPad's Safari Slowness Blues

    My iPad 2 has been serving me well for a year and a half but I recently noticed it getting sluggish.  More specifically, using Safari became like pedaling in hummus.  Opening a new tab or selecting the Search or URL bar seemed to be consistently taking two or three seconds.  I resigned myself to life like this for a while until I accidentally clicked the double arrow on the right side of the OS X Safari’s Bookmarks Bar.

    The bookmarks grow fast when all you have to do is hit Command-D

    Having too many links in the bookmarks bar will wreak havoc everywhere if you're syncing over iCloud

    It took a few seconds for my laptop to display all the entries.  At that point I reasoned that my bookmarks, synced via iCloud, were causing the sluggishness.  A trip to the Bookmark Manager showed that there were roughly 700(?!?!) first level items in my Bookmarks Bar, along with a dozen or so nested folders with a few hundred more items.  I dragged nearly everything in to the Bookmarks Menu and it instantly solved the problem.  I opened the iPad and the problem was indeed solved there as well, all was lightning quick again.  Interestingly enough, the ‘normal’ bookmarks menu in both the OS X and iOS versions of Safari seem to have no trouble with a large quantity of links.

    TL;DR – Too many links in the Safari Bookmarks Bar slows everything down.

  • Getting NSNumberFormatter to Display Currency

    When working on a little cocoa app today, I ran in to a somewhat perplexing problem where I could not get currency-formatted values to display in my NSTableView.  Using interface builder to add a number formatter to my text field and set the style to currency, I set the text value and… nothing.  Turns out that the formatter only wants double values, so use double values

  • BitCoin, Now Accepted by WordPress

    Just saw an interesting post on the official WordPress.com blog that they are now accepting payment in BitCoin.  Interesting.  This definitely brings the technology a huge step closer to legitimacy (and much-needed public debate) and comes right on the heels of an article this week that made mention of Reddit looking into accepting BitCoin for its Gold accounts.

  • Betaville Media Coverage

    Since the BBC published an article on Betaville last week, we’ve gotten a good bit of Media coverage.  Some pieces have just been snippets of the original BBC piece while others have really explored the ideas behind Betaville and provided genuine reflection; Cool stuff!  I was invited to give another interview about the project last week, this time to The Metro (London).  This morning I was greeted by their article and figured it was probably time to put links to a few of these articles in the same place.