Page 1 of 2
freetag plugin generates SQL error
Posted: Wed Feb 24, 2010 1:58 pm
by ads
Hi,
i'm using the freetag plugin and can see the following error in my database log:
2010-02-24 13:27:08 CET ERROR: syntax error at or near ")" at character 66
2010-02-24 13:27:08 CET STATEMENT: SELECT entryid, tag from serendipity_entrytags WHERE entryid IN () order by entryid, tag
In addition there's a nasty PHP warning, if i create a new blog posting. But i'm not not sure, if that's related:
Warning: Invalid argument supplied for foreach() in /www/blog/plugins/serendipity_event_microformats/serendipity_event_microformats.php on line 137
Warning: Invalid argument supplied for foreach() in /www/blog/plugins/serendipity_event_microformats/serendipity_event_microformats.php on line 251
Re: freetag plugin generates SQL error
Posted: Wed Feb 24, 2010 3:43 pm
by garvinhicking
Hi!
Hm, the first error should not occur. Are you using the most recent version of the plugin?
The same applies to the microformats plugin, are you using a recent version there as well?
In both places you mentioned, current versions check if the input data is an array or not...
Regards,
Garvin
Re: freetag plugin generates SQL error
Posted: Wed Feb 24, 2010 3:49 pm
by ads
Yes, plugins are up to date, according to spartacus (i wrote this script which checks regularly for plugin updates). For what code should i look to find out, if the changes you mentioned are applied to my plugins?
Note that the database in question is PostgreSQL and the "()" really looks like empty values.
I remember, that i have seen the php warnings before, just the database error is new to me.
Re: freetag plugin generates SQL error
Posted: Thu Feb 25, 2010 10:31 am
by garvinhicking
Hi!
The first one would be in serendipity_event_freetag.php at around line 1456. The code says:
Code: Select all
function getTagsForEntries($entries) {
global $serendipity;
if (!is_array($entries) || count($entries) < 1) {
return false;
}
$q = "SELECT entryid, tag from {$serendipity['dbPrefix']}entrytags WHERE entryid IN (".implode(',', $entries).") order by entryid, tag";
So if $entries is empty, it should bail out due to the is_array check at the beginning.
You might want to modify it like this:
Code: Select all
function getTagsForEntries($entries) {
global $serendipity;
if (!is_array($entries) || count($entries) < 1) {
return false;
}
$string = implode(',', $entries);
$string = trim($string);
if (empty($string)) { $fp = fopen('/tmp/s9y.log', 'a'); fwrite($fp, print_r($entries, true)); fclose($fp); }
$q = "SELECT entryid, tag from {$serendipity['dbPrefix']}entrytags WHERE entryid IN (".implode(',', $entries).") order by entryid, tag";
Then this would log possible empty strings and give the input array into the logfile /tmp/s9y.log (make sure you pick a file/dir thats writable).
Inside serendipity_event_microformats.php there's a similar thing. The actual error happens in the "getSupportedProperties()" method. This is called with an input parameter called "mf_type".
But all references to this really specify a proper input array:
line 165:
Code: Select all
$supported_formats = array('hReview', 'hCalendar');
$supported_properties =& $this->getSupportedProperties($supported_formats);
line 234:
Code: Select all
$supported_formats = array('hReview', 'hCalendar');
$supported_properties =& $this->getSupportedProperties($supported_formats);
line 250:
Code: Select all
if (is_array($serendipity['POST']['properties']) && count($serendipity['POST']['properties']) > 0){
$supported_properties =& $this->getSupportedProperties($serendipity['POST']['properties']['mf_type']);
line 288:
Code: Select all
$supported_formats = array('hReview', 'hCalendar');
$supported_properties =& $this->getSupportedProperties($supported_formats);
Which PHP version are you running? Some PHP versions had a bug when a bytecode cache was used that did not properly pass along arrays...
Regards,
Garvin
Re: freetag plugin generates SQL error
Posted: Thu Feb 25, 2010 12:12 pm
by ads
First of all, before i try to debug and add your code:
I found two serendipity_event_freetag.php files:
./plugins/freetag/serendipity_event_freetag.php
./plugins/serendipity_event_freetag/serendipity_event_freetag.php
The first one is:
$Id: serendipity_event_freetag.php,v 1.124 2008/12/10 10:34:52 lstrojny Exp $
The second one is:
$Id: serendipity_event_freetag.php,v 1.136 2010/01/06 23:37:08 onli Exp $
Is this correct? If no, which one should i remove, if yes: which one should i add your debugging code?
Re: freetag plugin generates SQL error
Posted: Thu Feb 25, 2010 3:35 pm
by onli
Which one gets used? The one in /plugins/serendipity_event_freetag/ is newer and should be the only one.
sincerely
Re: freetag plugin generates SQL error
Posted: Thu Feb 25, 2010 4:56 pm
by ads
Both contain the array checks which garvin posted earlier in this thread.
I don't know which one get's used - and/or if the other one get's used if i remove one.
Which one is the official one?
Re: freetag plugin generates SQL error
Posted: Thu Feb 25, 2010 7:33 pm
by onli
The one in /plugins/serendipity_event_freetag/ is the official one, it's the one in
spartacus.
Re: freetag plugin generates SQL error
Posted: Thu Feb 25, 2010 9:22 pm
by ads
I moved away the "freetag" directory and added some debugging code. From what i can see, this happens if i press the "preview" button:
Code: Select all
empty array: Array
(
[0] =>
)
query string:
SELECT entryid, tag from serendipity_entrytags WHERE entryid IN () order by entryid, tag
Re: freetag plugin generates SQL error
Posted: Fri Feb 26, 2010 10:58 am
by garvinhicking
Hi!
Ah, great. In fact we didn't check for that, thanks for helping the debugging. I committed a patch to the freetag plugin so that this case will now also be checked.
Regards,
Garvin
Re: freetag plugin generates SQL error
Posted: Fri Feb 26, 2010 12:26 pm
by ads
Ah, fine
I will wait for the module update and then check again if the php warnings are gone.
Andreas
Re: freetag plugin generates SQL error
Posted: Sun Feb 28, 2010 6:11 pm
by ads
Ok, the SQL bug is gone.
There is still the PHP warning:
Code: Select all
Warning: Invalid argument supplied for foreach() in /www/blog/plugins/serendipity_event_microformats/serendipity_event_microformats.php on line 137
Warning: Invalid argument supplied for foreach() in /www/blog/plugins/serendipity_event_microformats/serendipity_event_microformats.php on line 251
In addition, the microformats output is buggy:
http://base.wars-nicht.de/microformats_2010-02-28.jpg
Short PHP tags are NOT allowed on this host
![Wink ;-)](./images/smilies/icon_wink.gif)
Re: freetag plugin generates SQL error
Posted: Mon Mar 01, 2010 12:52 pm
by garvinhicking
Hi!
I removed the short-open required code in the latest version, maybe this can also corret your problem with the line 137/251 bug?
Regards,
Garvin
Re: freetag plugin generates SQL error
Posted: Mon Mar 01, 2010 9:47 pm
by ads
Version 3.10.4 is installed here. Should there be a newer version?
Re: freetag plugin generates SQL error
Posted: Tue Mar 02, 2010 11:23 am
by garvinhicking
Hi!
ads wrote:Version 3.10.4 is installed here. Should there be a newer version?
I'm talking about Microformats, there 0.44 is the now recent version
Regards,
Garvin