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->get_col($wpdb->prepare("SELECT post_author FROM " . $wpdb->posts . " WHERE ID = " . intval($postID) . " LIMIT 1");

// New (two argument) function call
global $wpdb;
$authorIDs = $wpdb->get_col($wpdb->prepare("SELECT post_author FROM " . $wpdb->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.

PostgreSQL 9.1 Remote Access

Concise instructions for setting up remote access to a fresh PostgreSQL 9.1 installation on Ubuntu 12.04 because I’m tired of googling every other month for it.

In /etc/postgresql/9.1/main/postgresql.conf

listen_addresses = '*'

And in /etc/postgresql/9.1/main/pg_hba.conf:

host    all     all      0.0.0.0      0.0.0.0.      md5

Note that this is horribly insecure, letting any user connect to any database.. It’s just an example.

Finally, restart Postgres.

sudo service postgresql restart

BBC Article on Betaville

I mentioned a few weeks ago that I had been interviewed by the BBC about Betaville.  I was wondering if – and when – anything would come of it until yesterday when I was told that it was featured in the BBC Technology section.  I’m incredibly humbled that people are not only taking the work we did seriously, but that it is empowering people to be proactive in changing the world around them.

Although not mentioned in the article, I want to thank all of the past contributors (Google Code, Github) who have put something of themselves into Betaville.

http://www.bbc.com/news/technology-19753721

Migrate to new git repository keeping history

I ran into a [potential] problem recently when migrating an application from when repository to another.  I was only switching repo’s because my PaaS provider, as they all do, creates templated application structures for all new applications.  Even though the original application’s repository is gone, its history is still valuable to me.  Luckily, this can be fixed relatively easily with a little git magic!

After the merge operation, you may find that a few of the files included in the application template have some conflicts.  You can simply resolve these by copying over the originals and committing the merge.  Your other option is to merge using the theirs strategy option by including “-Xtheirs” in your merge command:

Nuking WordPress Transients

Occasionally in the WordPress world you come across plugins that just aren’t tidy. One of the nasty things that can happen is that your wp_options table gets filled with transient entries that are never garbage collected after their expiration. If you have a relatively high traffic site, like jMonkeyEngine, this will slow down your site to a crawl especially if new entries are being made on every page view (not naming names but the appropriate developers know the issues if they check their forums).

That said, there’s a pretty easy way to just get rid of all the transient entries in your table regardless of expiration.


Run this if you notice your wp_options table is becoming bloated, or better still, deactivate the suspect plugin.

Interviewed by BBC about Betaville

I was contacted last week by someone from BBC to be interviewed about my work on Betaville. We arranged an interview over Skype for this morning. I had a blast getting to talk about such a great project and look forward to seeing the press coverage.

My thanks to Nastaran for getting in touch and conducting the interview!