Wrong behaviour in serendipity_db_query()?

Found a bug? Tell us!!
Post Reply
WebComPas
Regular
Posts: 101
Joined: Thu Nov 22, 2007 10:14 am
Contact:

Wrong behaviour in serendipity_db_query()?

Post by WebComPas »

Hallo!

Yesterday I found a strange behaviour of the core function serendipity_db_query(): According to the documentation it should return FALSE if an error occurs but in fact it returns the error message.

Can anyone tell me if this is a bug or if I didn't understand this correctly?

Regards,
Pascal
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Wrong behaviour in serendipity_db_query()?

Post by garvinhicking »

Hi!

Which documentation are you referring to? false is returned when no database connection exists; it also returns false when the "expect_error" variable is set to true. Else when an error occurs, it returns a string for the actual error.

I do agree this behaviour is a bit unfortunate, but since some API functions already depend on it, you should best check for an is_string() return code; or set the expect_error accordingly?

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/
WebComPas
Regular
Posts: 101
Joined: Thu Nov 22, 2007 10:14 am
Contact:

Re: Wrong behaviour in serendipity_db_query()?

Post by WebComPas »

I'm referring to the PHPDoc documentation within the mysql.inc.php:
It can return:
* false if there was an error,
* true if the query succeeded but did not generate any rows
* array of field values if it returned a single row and $single is true
* array of array of field values if it returned row(s) [stacked array]
None of these possible return value descriptions says that in case of an error a string containing the error message will be returned.
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Wrong behaviour in serendipity_db_query()?

Post by garvinhicking »

Hi!

Ah, that's true. Then somebody simply messed up documenting, and I'll fix this in SVN :)

Regards,
Garvin
WebComPas wrote:I'm referring to the PHPDoc documentation within the mysql.inc.php:
It can return:
* false if there was an error,
* true if the query succeeded but did not generate any rows
* array of field values if it returned a single row and $single is true
* array of array of field values if it returned row(s) [stacked array]
None of these possible return value descriptions says that in case of an error a string containing the error message will be returned.
# 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/
WebComPas
Regular
Posts: 101
Joined: Thu Nov 22, 2007 10:14 am
Contact:

Re: Wrong behaviour in serendipity_db_query()?

Post by WebComPas »

OK, thank you! Surely this will be helpful for developers which are not familiar with this function.

Regards
Pascal
Interessantes aus den Themenbereichen Computer, Internet und Programmierung unter http://www.it-blog.net
Post Reply