WordPress 3.5 – PHP Warning: Missing argument 2 for wpdb::prepare()
I just updated a work in progress to WordPress 3.5, and ended up with broken permalinks (to fix that: reset to default permalinks, then set the custom permalinks again), and my favorite plugin "Network Shared Posts" gave a super-long error message on each page, something along the lines of
PHP Warning: Missing argument 2 for wpdb::prepare()…blablabla…
So, after doing some research I found out that the root of all evil are the WordPress developers! Or to be more precise, they decided to make their functions more strict, resulting in a lot of plugins now showing the error "PHP Warning: Missing argument 2 for wpdb::prepare()", after someone updates to WordPress 3.5 and before the author has the chance to update, or in some cases totally rewrite their plugin. Read this article for more on this.
Here is my work-around to literally hide all "PHP Warning: Missing argument 2 for wpdb::prepare()" error messages:
So, since I can't wait for the plugin author to update the plugin so that it complies with WP requirements, I had to come up with a way to fix this annoying "PHP Warning: Missing argument 2 for wpdb::prepare()" warning in WordPress 3.5 stuffstuff
Simply modify each line that produces the error message like this:
Add a @ infront of wpdb->prepare !
So, instead of changing for example this line:
to this:
I simply did this:
Either way, you would end up with one less "PHP Warning: Missing argument 2 for wpdb::prepare()" error message showing up, just work your way through the file that was mentioned in the error message, and you'll end up with everything being as before updating to WordPress 3.5
1348