[F I X E D] exit.php not redirecting (CVS)

Found a bug? Tell us!!
Post Reply
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

[F I X E D] exit.php not redirecting (CVS)

Post by stephanb »

I used a html-nugget sidebar to put in some websites I visit. The html content are only simple <a> tags. S9y generates invalid content:

It generates: http:// <weblog url> /exit.php?url_id=Y for every entry.

mysql> select * from serendipity_references; does not list the html nugget urls, which makes sense.

So I assume I cannot track exits throughout my htmlnugget.
Any idea how to fix this by either disabling the tracking for the html nugget, or to fix tracking?

/Stephan
Last edited by stephanb on Fri Jul 09, 2004 11:41 pm, edited 1 time in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: exit.php not redirecting

Post by garvinhicking »

I guess you're using latest CVS snapshot then?

That's quite weird your getting this behaviour. In case a link is not found inside the references table, it should use old style redirection with the ?url= parameter instead of ?url_id.

Could you please open plugins/serendipity_event_trackexits/serendipity_event_trackexits.php and locate this line:

Code: Select all

        if (isset($this->links[$url])) {
            return sprintf(
                '<a%shref="%sexit.php?url_id=%s%s" title="%s" onmouseover="window.status=\'%s\';return true;" onmouseout="window.status=\'\';return true;"',
                $buffer[1],
                $serendipity['baseURL'],
                $this->links[$url],
                ($entry_id != 0) ? '&entry_id=' . $entry_id : '',
                $url,
                $url
            );
        } else {
            return sprintf(
                '<a%shref="%sexit.php?url=%s%s" title="%s" onmouseover="window.status=\'%s\';return true;" onmouseout="window.status=\'\';return true;"',
                $buffer[1],
                $serendipity['baseURL'],
                base64_encode($url),
                ($entry_id != 0) ? '&entry_id=' . $entry_id : '',
                $url,
                $url
            );
        }
Then please change it temporarily to:

Code: Select all

        if (isset($this->links[$url])) {
echo 'Found URL <u>' . $url . '</u> in array ' . $this->links[$url] . '!<br />';
echo 'Buffer is: ' . print_r($buffer, true) . '<br />';
            return sprintf(
                '<a%shref="%sexit.php?url_id=%s%s" title="%s" onmouseover="window.status=\'%s\';return true;" onmouseout="window.status=\'\';return true;"',
                $buffer[1],
                $serendipity['baseURL'],
                $this->links[$url],
                ($entry_id != 0) ? '&entry_id=' . $entry_id : '',
                $url,
                $url
            );
        } else {
echo 'Using old style.<br />';
echo 'Buffer is: ' . print_r($buffer, true) . '<br />';
            return sprintf(
                '<a%shref="%sexit.php?url=%s%s" title="%s" onmouseover="window.status=\'%s\';return true;" onmouseout="window.status=\'\';return true;"',
                $buffer[1],
                $serendipity['baseURL'],
                base64_encode($url),
                ($entry_id != 0) ? '&entry_id=' . $entry_id : '',
                $url,
                $url
            );
        }
And please report the output. And please tell which database you are using (postgre, mysql, sqlite). Thanks!

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/
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

Post by stephanb »

Found URL http://www.rtp.org/ in array Y!
Buffer is: Array ( [0] => [2] => " [3] => www.rtp.org/ [4] => " )

I'm using mysql.
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

Post by stephanb »

stephanb wrote:Found URL http://www.rtp.org/ in array Y!
Buffer is: Array ( [0] => [2] => " [3] => www.rtp.org/ [4] => " )

I'm using mysql.
Hold on, looking further I found that $this->links is not filled correctly. Somehow the SQL statement that is supposed to fill this array in serendipity_db_query() is erroring.

$this->links is defined as the mysql 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 '' at line 1

Lemme see where serendipity_db_query() goes wrong here:

Code: Select all

$this->links = serendipity_db_query("SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = {$serendipity['encodeExitsCallback_entry_id']}", false, 'both', false, 'link', 'id');
/Stephan
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

Post by stephanb »

Code: Select all

"SELECT id, link FROM serendipity_references WHERE entry_id = "
This is how that code evals. There is a definite 'quotation error' there.
Correct me if I'm misinterpreting things here :)

./Stephan
Last edited by stephanb on Fri Jul 09, 2004 8:12 pm, edited 2 times in total.
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

SOLUTION ?

Post by stephanb »

Code: Select all

$this->links = serendipity_db_query("SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = {$serendipity['encodeExitsCallback_entry_id']}", false, 'both', false, 'link', 'id');
needs to be replaced with

Code: Select all

$this->links = serendipity_db_query("SELECT id, link FROM {$serendipity['dbPrefix']}references WHERE entry_id = '{$serendipity['encodeExitsCallback_entry_id']}'", false, 'both', false, 'link', 'id');
The only difference is that I quoted the $serendipity['encodeExitsCallback_entry_id'] variable so the SQL string will eval into:

Code: Select all

"SELECT id, link FROM serendipity_references WHERE entry_id = '' "
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: SOLUTION ?

Post by garvinhicking »

Hi Stephan!

Thanks a lot for your debugging! I have commited a different patch (http://garv.info/files/te.diff) to CVS now, which should be somehwat 'cleaner', but basically achieves the same like you coded.

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/
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

Post by stephanb »

You're welcome :) glad I could be of help.

I just started to use s9y two days ago to document my move to the USA, and I have to day I really really like it. Keep up the good work!

/Stephan
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

Re: SOLUTION ?

Post by stephanb »

garvinhicking wrote:Hi Stephan!

Thanks a lot for your debugging! I have commited a different patch (http://garv.info/files/te.diff) to CVS now, which should be somehwat 'cleaner', but basically achieves the same like you coded.
Is there a delay in the CVS reproductions ?
When I try to checkout the newer entry, I still get :

Code: Select all

<?php # $Id: serendipity_event_trackexits.php,v 1.10 2004/07/05 08:25:50 garvinhicking Exp $
and this is not your updated version with the patch in it.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: SOLUTION ?

Post by garvinhicking »

Yes, there sadly is a 24hour delay for anonymous CVS access, so you sadly have to wait. But if you're familar with patch/diff utils you could download the link I gave you and you'll have the patch I committed.

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/
stephanb
Regular
Posts: 16
Joined: Thu Jul 08, 2004 8:14 pm
Contact:

Post by stephanb »

I have it already, just wondered :)
Post Reply