Mail FAQ to Friend bug, PMF 2.6.5

Please report bugs here!

Moderator: Thorsten

Post Reply
dajoker
Posts: 59
Joined: Sat Jan 30, 2010 1:01 am

Mail FAQ to Friend bug, PMF 2.6.5

Post by dajoker »

The links below a FAQ entry to e-mail/PDF a FAQ entry are broken (invalid id).

Steps to duplicate:
Find a FAQ
Go to the bottom and put mouse over the e-mail link.

Actual Results, a link like this: http://1.2.3.4/phpmyfaq/index.php?actio ... artlang=en
Notice that 'id=0' is not correct.

Expected Results, a link like this: http://1.2.3.4/phpmyfaq/index.php?actio ... artlang=en

The PDF link is also broken. Anytime this link is followed the resulting page says the doc is in revision and cannot be accessed.
Thorsten
Posts: 15568
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Mail FAQ to Friend bug, PMF 2.6.5

Post by Thorsten »

Hi,

I will check this.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
dajoker
Posts: 59
Joined: Sat Jan 30, 2010 1:01 am

Re: Mail FAQ to Friend bug, PMF 2.6.5

Post by dajoker »

A bit more information. Searching and then selecting a result actually works. Searching by a number which matches a solution_id which takes you directly into the FAQ is what is not working. I did not realize the distinction before and have been doing a lot of tests just going to one TID to look at how it looks between changes so that original description may not have been sufficient to see this bug.

Thanks.
dajoker
Posts: 59
Joined: Sat Jan 30, 2010 1:01 am

Re: Mail FAQ to Friend bug, PMF 2.6.5

Post by dajoker »

Well this has been an interesting one and is a bit bigger than just mailing. I was going through the SQL calls (PostgreSQL has a neat feature to let you log queries via the log_statement command in the postgresql.conf file) and noticed the following while tweaking something else:

<code>
2010-05-29 14:13:37.674 MDT phpmyfaqdb phpmyfaqadmin LOG: statement:
SELECT
visits
FROM
faqvisits
WHERE
id = 7003580
AND
lang = 'en'
2010-05-29 14:13:37.675 MDT phpmyfaqdb phpmyfaqadmin LOG: statement:
UPDATE
faqvisits
SET
visits = visits+1,
last_visit = 1275164017
WHERE
id = 7003580 AND lang = 'en'
2010-05-29 14:13:37.680 MDT phpmyfaqdb phpmyfaqadmin LOG: statement:
SELECT
id, item, definition
FROM
faqglossary
WHERE
lang = 'en'
2010-05-29 14:13:37.952 MDT phpmyfaqdb phpmyfaqadmin LOG: statement:
SELECT
id, item, definition
FROM
faqglossary
WHERE
lang = 'en'
2010-05-29 14:13:37.956 MDT phpmyfaqdb phpmyfaqadmin LOG: statement: SELECT
thema
FROM
faqdata
WHERE
id = 0 AND lang = 'en'
2010-05-29 14:13:37.962 MDT phpmyfaqdb phpmyfaqadmin LOG: statement:
SELECT
id
FROM
faqattachment
WHERE
record_id = 0
AND
record_lang = 'en'
</code>

Notice that the first few queries are looking for a specific id (7003580) and later on they're looking for an id of 0 which is almost definitely wrong in any case. This is not ever being set properly in the artikel.php file by the following line:

$record_id = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);

The URL when going here is the following: http://151.155.134.134/phpmyfaq/index.p ... id=7003580

The problen us that the 'id' GET variable is not present on this page so it returns with a zero. A fix may be to retrieve the record_id when it is zero and the solution_id is known (and possibly vice versa if that's possible) or maybe the page calling this one should be sending in mor evariables, but it'd be nice if you could have just one of the two present to allow for short URLs as otherwise this is a bit redundant.

Looking a bit down I see this snippet of code already in there:

<code>
// Get all data from the FAQ record
if (0 == $solution_id) {
$faq->getRecord($record_id);
} else {
$faq->getRecordBySolutionId($solution_id);
}
</code>

It appears it may be a trivial thing to just set the $record_id and/or $solution_id at this point within here. On the other hand it may make more sense to just remove references to $record_id or $solution_id and instead always use $faq->faqRecord['id'] and $faq->faqRecord['solution_id'] instead so we are always referencing one object which contains everything. Assuming $faq is not overwritten later on in this page of .php it should be fine (doesn't look like it is, but double-check that).

Anyway, that should be an easy fix either way.

Thanks.
dajoker
Posts: 59
Joined: Sat Jan 30, 2010 1:01 am

Re: Mail FAQ to Friend bug, PMF 2.6.5

Post by dajoker »

I made the following change and it seemed to work:

diff artikel.php artikel.php.orig
55d54
< $solution_id = $faq->faqRecord['solution_id'];
58d56
< $record_id = $faq->faqRecord['id'];
Thorsten
Posts: 15568
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Mail FAQ to Friend bug, PMF 2.6.5

Post by Thorsten »

Hi,

I fixed it in my git repo by removing all references to $record_id. Thanks for the hints!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply