Gengo & WordPress – submit comment database error fix

Posted by MadPole on 24th April 2009

SEVERE WARNING!

This is a nasty temporary hack – not even close a temporary solution. It might cause other issues and side effects so use only if You know what You are doing and backup your database and plugin code first of all. Apparently Gengo is not compatible with WordPress 2.7+ yet, so even if the fix works without causing any damage – it might still be a drop of water in an ocean.

The issue

When submitting a comment to the page (as opposed to the post) the following PHP warnings and SQL syntax error occur:

Warning: implode() [function.implode]: Bad arguments. in …./wp-content/plugins/gengo/gengo.php on line 1484

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND p2l1.post_id = 7 AND p2l1.translation_group != 0' at line 1]
SELECT p2l2.post_id, p2l2.language_id FROM wp_post2lang AS p2l1 INNER JOIN wp_post2lang AS p2l2 ON (p2l1.translation_group = p2l2.translation_group) WHERE p2l2.language_id IN () AND p2l1.post_id = 7 AND p2l1.translation_group != 0

Warning: Cannot modify header information – headers already sent by (output started at …./wp-content/plugins/gengo/gengo.php:1484) in …./wp-comments-post.php on line 79

Warning: Cannot modify header information – headers already sent by (output started at …./wp-content/plugins/gengo/gengo.php:1484) in …./wp-comments-post.php on line 80

Warning: Cannot modify header information – headers already sent by (output started at …./wp-content/plugins/gengo/gengo.php:1484) in …./wp-comments-post.php on line 81

Warning: Cannot modify header information – headers already sent by (output started at …./wp-content/plugins/gengo/gengo.php:1484) in …./wp-includes/pluggable.php on line 850

The Fix

Edit gengo.php and go to line 1484. Put following code above implode statement, so it looks like this (including implode statement):

if (! is_array ($ids) )
{
$ids[0] = '1';
}
$language_ids = implode(",", $ids);

Posted in Geek | No Comments »