[freetag] constantly generates PHP warning in the log

Creating and modifying plugins.
Post Reply
wesley
Regular
Posts: 197
Joined: Sun Jul 10, 2005 11:15 am
Contact:

[freetag] constantly generates PHP warning in the log

Post by wesley »

While troubleshooting for a fatal error caused by SPARTACUS (for some reason, the php file was slightly corrupted), I noticed another string of errors stemming from the freetag plugin in the Apache server log:

Code: Select all

PHP Warning: explode() expects parameter 2 to be string, array given in (path)/serendipity_event_freetag.php on line 1037, referer: (site)/plugin/tag/(tag name)/
This seems to be generated quite often, but not always when a page is loaded.
Looking at the code, it seems to be related to the line that goes like this:

Code: Select all

if (!empty($this->tags['show'])) {
    if (is_array($this->tags['show'])) {
        $showtag = array_map('serendipity_db_escape_string', $this->tags['show']);
    } else {
        $showtag = serendipity_db_escape_string($this->tags['show']);
    }
} else if (!empty($serendipity['GET']['tag'])) {
    $showtag = serendipity_db_escape_string(urldecode($serendipity['GET']['tag']));
}
$arr_showtag = explode(';', $showtag);
The code may pass array_map() to $showtag, but explode() doesn't seems to like this. I wonder why it's coded this way, and would there be a way to avoid generating the errors in the log?
I make s9y plugins, too.
My s9y blog depends on them. :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [freetag] constantly generates PHP warning in the log

Post by garvinhicking »

Hi!

Hm I believe this is an actual flaw in the logic; if the array_map is used, explode isn't used.

I would suggest rewriting it to:

Code: Select all

if (!empty($this->tags['show'])) {
    if (is_array($this->tags['show'])) {
        $showtag = array_map('serendipity_db_escape_string', $this->tags['show']);
    } else {
        $showtag = serendipity_db_escape_string($this->tags['show']);
    }
} else if (!empty($serendipity['GET']['tag'])) {
    $showtag = serendipity_db_escape_string(urldecode($serendipity['GET']['tag']));
}

if (is_array($showtag)) {
    $arr_showtag = $showtag;
} else {
    $arr_showtag = explode(';', $showtag);
}
Can you test this? If it works, I'd commit it to the plugin repo...

Thanks,
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/
wesley
Regular
Posts: 197
Joined: Sun Jul 10, 2005 11:15 am
Contact:

Re: [freetag] constantly generates PHP warning in the log

Post by wesley »

The revised code seems to work. The error hasn't been showing up since.
I make s9y plugins, too.
My s9y blog depends on them. :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [freetag] constantly generates PHP warning in the log

Post by garvinhicking »

Cool, thanks! Committed!
# 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/
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: [freetag] constantly generates PHP warning in the log

Post by Lux »

garvinhicking wrote:Can you test this? If it works, I'd commit it to the plugin repo...
With 2.0 beta I do not see a clickable list of tags below my article any more.

Can you please check?

BTW:

Cheers

Dirk
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: [freetag] constantly generates PHP warning in the log

Post by yellowled »

Lux wrote:With 2.0 beta I do not see a clickable list of tags below my article any more.
Might be http://board.s9y.org/viewtopic.php?p=10440023 (German).

YL
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: [freetag] constantly generates PHP warning in the log

Post by Lux »

yellowled wrote:
Lux wrote:With 2.0 beta I do not see a clickable list of tags below my article any more.
Might be http://board.s9y.org/viewtopic.php?p=10440023 (German).
Looks like, I will answer there.

Cheers

Dirk
Post Reply