Bug in Glossary

Please report bugs here!

Moderator: Thorsten

Post Reply
Bambino
Posts: 11
Joined: Fri Jul 13, 2007 2:50 pm

Bug in Glossary

Post by Bambino »

There is a bug in glossary class. It cause of dissapiering of FAQ text and subject.
See the file Glossary.php, function insertItemsIntoContent, row 122

Your code:

Code: Select all

$item['item'] = preg_quote($item['item'], '/');
Fixed code:

Code: Select all

$item['item'] = preg_quote('/', $item['item']);
ragtek
Posts: 2
Joined: Fri Jul 13, 2007 12:03 pm
Contact:

Post by ragtek »

hi

with this code its for me not working
catmedia
Posts: 55
Joined: Tue Jun 10, 2003 8:59 am
Location: Dillingen-Saar

Post by catmedia »

This is not the reason, the bug is still existing.
MfG
Arthur W. Borens
catmedia
Posts: 55
Joined: Tue Jun 10, 2003 8:59 am
Location: Dillingen-Saar

Post by catmedia »

Use the daily snapshop (CVS 2.0) and it works fine.
MfG
Arthur W. Borens
Bambino
Posts: 11
Joined: Fri Jul 13, 2007 2:50 pm

Post by Bambino »

ragtek wrote:hi

with this code its for me not working
What do you mean?!
My situation: when there were no records in Glossary all works fine, i.e. when I select FAQ I see subject and text. When I added first term in Glossary all text information at selection of any FAQ dissapeared. I find that above mentioned method returns empty values for $content and $thema variables. I see the method and find a bug - parameters of preg_quote were swapped. When I change their place vise versa I see text data again. :)
So... I decided to notify community about this.
bulbasnore
Posts: 6
Joined: Sat Jul 14, 2007 3:34 am

same here

Post by bulbasnore »

I get the same issue, no FAQ Q/A show up if I have a glossary entry. If I remove it, I can see the text.

PHP 5.1.6
MySQL 5.0.27
Apache 2.2.4

[Fri Jul 13 19:25:36 2007] [error] [client x.x.x.x] PHP Warning: preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '=' in /var/www/cpdmtest/inc/Glossary.php on line 134, referer: http://realhost.myrealdomain.com/index.php?
Thorsten
Posts: 15724
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

please try the current stable CVS snapshot. It's fixed there.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Bambino
Posts: 11
Joined: Fri Jul 13, 2007 2:50 pm

Post by Bambino »

Thorsten wrote:Hi,

please try the current stable CVS snapshot. It's fixed there.

bye
Thorsten
I downloaded this version but it also contains errors. For example, if array elements from 3 to 5 does not exist.

Original code:

Code: Select all

    function setAcronyms($matches)
    {
        $itemAsAttrName = $matches[1];
        $itemInAttrValue = $matches[2]; // $matches[3] is the attribute name
        $prefix = $matches[4];
        $item = $matches[5];
        $postfix = $matches[6];

        if (!empty($item)) {
            return '<acronym class="glossary" title="'.$this->definition.'">'.$prefix.$item.$postfix.'</acronym>';
        }

        // Fallback: the original matched string
        return $matches[0];
    }
Fixed code (just for me)

Code: Select all

    function setAcronyms($matches)
    {
        $itemAsAttrName = $matches[1];
        $itemInAttrValue = $matches[2]; // $matches[3] is the attribute name
        if ( isset ( $matches[4] ) ) {
            $prefix = $matches[4];
        }
        if ( isset ( $matches[5] ) ) {
            $item = $matches[5];
        }
        if ( isset ( $matches[6] ) ) {
            $postfix = $matches[6];
        }

        if (!empty($item)) {
            return '<acronym class="glossary" title="'.$this->definition.'">'.$prefix.$item.$postfix.'</acronym>';
        }

        // Fallback: the original matched string
        return $matches[0];
    }
P.S. And Init.php have DEBUG set to true.
Thorsten
Posts: 15724
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

how can I reproduce this? What did you entered?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Bambino
Posts: 11
Joined: Fri Jul 13, 2007 2:50 pm

Post by Bambino »

Thorsten wrote:Hi,

how can I reproduce this? What did you entered?

bye
Thorsten
Just open one FAQ... and it is visible ONLY if DEBUG flag is set to TRUE.

for example just check quickly... If especially comment my code for one variant. This is only for 4th element... the same for 5th and 6th.
tipsen
Posts: 10
Joined: Mon Jul 02, 2007 10:11 am

Re: Bug in Glossary

Post by tipsen »

Bambino wrote:There is a bug in glossary class. It cause of dissapiering of FAQ text and subject.
See the file Glossary.php, function insertItemsIntoContent, row 122
For possible fix see:
viewtopic.php?p=19672
viewtopic.php?t=5036
Post Reply