Addendum to dynamic plugins

Posted on 08 August 2006 by jose

I ran my page through the W3C's validator and discovered that it was not XHTML 1.0 strict. It had several errors, and tracking these down led me to discover that my hack to get Democracy to play nicely with WP-Cache still had a bug: I was getting a MySQL error in the code for the poll form, where the form action would appear. This didn't interfere with the page rendering (as far as I can tell), so it was invisible until I looked at the source or, better yet, had a validator do it.

It turns out that Democracy was trying to get the Wordpress blog URL from the MySQL options table. The get_bloginfo function calls get_settings, which tries to access the options table in MySQL. Somehow, the query syntax was not including the actual table it was trying to select from, leaving me with the incorrect syntax error: SELECT option_value FROM WHERE option_name = '$setting' LIMIT 1

The code in functions.php for the get_settings function looks like this: SELECT option_value FROM $wpdb->options WHERE option_name = '$setting' LIMIT 1

Some additional testing showed me that $wpdb->options was indeed supposed to be assigned the name of the options table, but was instead going unassigned (the value I tested for was NULL); I traced the variable assignment to the wp_settings.php file, which is not loaded by WP-Cache. I then added a check to democracy.php that checks at the start of the jal_democracy function to see if $wpdb->options is NULL, and if so (which means that we're in the WP-Cache environment), to assign the correct option table name to $wpdb->options.


Latest poll

Which do you favor?