PHP error with certain search strings

Found a bug? Tell us!!
Post Reply
rowi
Regular
Posts: 77
Joined: Fri Mar 16, 2007 9:10 pm
Location: Flensburg / Germany
Contact:

PHP error with certain search strings

Post by rowi »

Hello, I'd like to have a problem please ;)

If one uses the search box on my blog at http://rowi.standardleitweg.de/ it depends on the search string whether one gets a valid result or a PHP error message:

Code: Select all

Warning: Invalid argument supplied for foreach() in /var/www/rowi/include/functions_entries.inc.php on line 855

Fatal error: Cannot create references to/from string offsets nor overloaded objects in /var/www/rowi/include/plugin_api.inc.php on line 1598
For example: "Android" gives 25 hits, "weewar" the PHP error.

I'm running 1.5-beta2 at the moment, my impression is that it got better compared with the 1.4 stable release. PHP Version sadly is 4.3.4
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: PHP error with certain search strings

Post by garvinhicking »

Hi!

Do you know if "weewar" would show you any blog entries? A lot of them? Unusually large ones?

Your PHP crashes rather painfully due to disk/ram space. It could very well be a PHP bug, your PHP version is ancient...

Regards
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
rowi
Regular
Posts: 77
Joined: Fri Mar 16, 2007 9:10 pm
Location: Flensburg / Germany
Contact:

Re: PHP error with certain search strings

Post by rowi »

"weewar" should return one entry exactly. Normal size.
It could very well be a memory issue, the ensim framework gives me very pathetic 8M. I've to increase the limit with ini_set
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: PHP error with certain search strings

Post by onli »

When searching for something with only one result, the search of 1.5 will search again with weewar*. And when searching directly for that one gets this error:

Code: Select all

Suche
Die Suche konnte nicht wie gewünscht ausgeführt werden. Hinweis für den Administrator dieses Blogs: Dieser Fehler kann durch fehlende Index-Schlüssel der Datenbank verursacht werden. Auf MySQL-Systemen muss der Datenbankbenutzer-Account in der Lage sein, Index-Schlüssel zu erstellen und folgende Abfrage auszuführen:

CREATE FULLTEXT INDEX entry_idx on serendipity_entries (title,body,extended)

Die genaue Fehlermeldung der Datenbank bei der Suche lautete:

SELECT 
                            e.id,
                            e.authorid,
                            a.realname AS author,
                            e.allow_comments,
                            e.moderate_comments,
                            a.email,
                            e.timestamp,
                            e.comments,
                            e.title,
                            e.body,
                            e.extended,
                            e.trackbacks,
                            e.exflag,
                            e.isdraft,
                            e.last_modified,
                            a.username AS loginname
                    
                      FROM
                            serendipity_entries e
                 LEFT JOIN  serendipity_authors a
                        ON  e.authorid = a.authorid
                 LEFT JOIN  serendipity_entrycat ec
                        ON  e.id = ec.entryid
                             LEFT OUTER JOIN serendipity_entryproperties ep_access
                                              ON (e.id = ep_access.entryid AND ep_access.property = 'ep_access')
 LEFT JOIN serendipity_entryproperties ep_sticky
                                            ON (e.id = ep_sticky.entryid AND ep_sticky.property = 'ep_is_sticky')
                     WHERE
                            (MATCH(title,body,extended) AGAINST('weewar*' IN BOOLEAN MODE))
                             AND isdraft = 'false'  AND timestamp <= 1258312200 AND  (ep_access.property IS NULL OR ep_access.value = 'public') 
                    GROUP BY e.id
                    
                  ORDER BY  timestamp DESC
                     LIMIT 10

 / You have an error in your SQL syntax near 'BOOLEAN MODE))
                             AND isdraft = 'false'  AND timestamp' at line 30
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: PHP error with certain search strings

Post by garvinhicking »

Hi!

Ah, maybe your mysql is too old and doesn't support "IN BOOLEAN MODE"! :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
rowi
Regular
Posts: 77
Joined: Fri Mar 16, 2007 9:10 pm
Location: Flensburg / Germany
Contact:

Re: PHP error with certain search strings

Post by rowi »

My MySQL version is even more ancient than PHP: "MySQL 3.23.58" :-(
I really need to change my hoster.
singelet
Posts: 3
Joined: Wed Nov 25, 2009 2:19 pm

Re: PHP error with certain search strings

Post by singelet »

I'm having the same error at http://singe.za.net/, full details below, but the pertinent error seems to be:
/ Unknown column 'orderkey' in 'order clause'

I upgrade from 1.4.1 when I was getting unexplained SQL errors (I had made some changes to packages on my side). I looked through the script in /sql and nothing makes a note of the 'orderkey' column.

Additionally, this is a significant amount of debugging info that reveals more to a potential attacker than I am comfortable with. Is there a way to turn debugging output like this off?

Software versions:
* php5/jaunty-security uptodate 5.2.6.dfsg.1-3ubuntu4.2
* php5-mysql/jaunty-security uptodate 5.2.6.dfsg.1-3ubuntu4.2
* mysql Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (i486) using readline 5.2
* serendipity 1.5-beta1

Full error below:

The search function did not work as expected. Notice for the administrator of this blog: This may happen because of missing index keys in your database. On MySQL systems your database user account needs to be privileged to execute this query:

CREATE FULLTEXT INDEX entry_idx on blog_entries (title,body,extended)

The specific error returned by the database was:

SELECT
e.id,
e.authorid,
a.realname AS author,
e.allow_comments,
e.moderate_comments,
a.email,
e.timestamp,
e.comments,
e.title,
e.body,
e.extended,
e.trackbacks,
e.exflag,
e.isdraft,
e.last_modified,
a.username AS loginname

FROM
blog_entries e
LEFT JOIN blog_authors a
ON e.authorid = a.authorid
LEFT JOIN blog_entrycat ec
ON e.id = ec.entryid
LEFT OUTER JOIN blog_entryproperties ep_cache_extended
ON (e.id = ep_cache_extended.entryid AND ep_cache_extended.property = 'ep_cache_extended')
LEFT OUTER JOIN blog_entryproperties ep_cache_body
ON (e.id = ep_cache_body.entryid AND ep_cache_body.property = 'ep_cache_body')
LEFT OUTER JOIN blog_entryproperties ep_access
ON (e.id = ep_access.entryid AND ep_access.property = 'ep_access')
LEFT JOIN blog_entryproperties ep_sticky
ON (e.id = ep_sticky.entryid AND ep_sticky.property = 'ep_is_sticky')
WHERE
(MATCH(title,body,extended) AGAINST('foooo*' IN BOOLEAN MODE))
AND isdraft = 'false' AND timestamp <= 1259155200 AND (ep_access.property IS NULL OR ep_access.value = 'public')
GROUP BY e.id

ORDER BY orderkey DESC, timestamp DESC
LIMIT 15

/ Unknown column 'orderkey' in 'order clause'
kleinerChemiker
Regular
Posts: 765
Joined: Tue Oct 17, 2006 2:36 pm
Location: Vienna/Austria
Contact:

Re: PHP error with certain search strings

Post by kleinerChemiker »

Have you ever read the error message and tried the suggested solution?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: PHP error with certain search strings

Post by garvinhicking »

Hi!

In your case, the serendipity_event_entryproperties plugin seems to be causing a strange error.

Actually, inside the SELECT part, the "orderkey" is missing. Can you tell me your plugin options for the entryproperties plugin, and which other event plugins you use? And when exactly do you get the error message, what is your blog URL?

A quick fix might be to go into the include/functions_entries.inc.php file, functon seredipity_searchEntries() at around line 823:

Code: Select all

    $querystring = "SELECT {$cond['distinct']}
                            e.id,
                            e.authorid,

change to

Code: Select all

    $querystring = "SELECT {$cond['distinct']}
                            {$cond['addkey']}
                            e.id,
                            e.authorid,
HTH,
GArvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
singelet
Posts: 3
Joined: Wed Nov 25, 2009 2:19 pm

Re: PHP error with certain search strings

Post by singelet »

kleinerChemiker wrote:Have you ever read the error message and tried the suggested solution?
No, because the orderkey error does not look like it would be solved by the suggested solution. Additionally, I did a straight upgrade, and this "shouldn't have happened", so we need to make sure beta2 is better ;)
singelet
Posts: 3
Joined: Wed Nov 25, 2009 2:19 pm

Re: PHP error with certain search strings

Post by singelet »

garvinhicking wrote:Hi!

In your case, the serendipity_event_entryproperties plugin seems to be causing a strange error.

Actually, inside the SELECT part, the "orderkey" is missing. Can you tell me your plugin options for the entryproperties plugin, and which other event plugins you use? And when exactly do you get the error message, what is your blog URL?

A quick fix might be to go into the include/functions_entries.inc.php file, functon seredipity_searchEntries() at around line 823:

snip...

HTH,
GArvin
Hi Garvin. Your fix worked perfectly.

Answers to your questions:
* My plugin options for entryproperties display strangely (under 'entry editing screen' there are movable divs crowded on the right of the page, with all checkboxes checked, but when I edit an entry, those options are not checked?)
o Use group-based restrictions - no
o Use user-based restrictions - no
o Use extended database lookups - yes
o Default: Entries can be read by - everyone
o Custom Fields - CustomField1, CustomField2, CustomField3
o Allow to cache entries? - yes
* I've got quite a few event plugins:
o Announce entries
o Extended properties for entries
o Fix common XHTML errors
o Statistics
o Spam Protector
o Markup: NL2BR
o Spartacus
o Creative Commons License
o Spam Protector (RBL)
o Spam Protector (SURBL)
o Autosave entries
o HTML Validator
o [Layout-Plugin: Printerfriendly version]
o HTML Link Metatags
o HTML META-Tags
o Links to next/previous entry
o Show last modification date
o Sitemap Generator (for Crawlers)
o Contact Form
o Dashboard
* My blog URL is http://singe.za.net/ it was in the previous post too.

Finally, is there a way for be to turn the extra debugging off?

Thanks for the help.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: PHP error with certain search strings

Post by garvinhicking »

Hi!

Great, I've committed this fix to SVN then for the upcoming release.

As for the extra debug; we often get reports of SQL errors in the SQL search, so currently this message only displays when a fatal error happens; currently, without hacking the code it can't really be disabled with a switch...

Regards,
GArvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply