Question and Bugreport for freetag plugin

Creating and modifying plugins.
Post Reply
WebComPas
Regular
Posts: 101
Joined: Thu Nov 22, 2007 10:14 am
Contact:

Question and Bugreport for freetag plugin

Post by WebComPas »

Hallo!

Today I tried the automated tag generation. After saving an entry, the corresponding tags were generated. But the next time I saved it the tags appeared more than once in the tags field. One tag was there even four times. I think this should be fixed.

Additionally I have a feature request, which I implemented in my blog manually: I'd like to have an option in the freetag plugin configuration for turning on/off the automated generation of tags. If someone can tell me, how I can add this feature to the official plugin version, I'll do that. Otherwise I'd be glad if someone would do this instead of mine.


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: Question and Bugreport for freetag plugin

Post by garvinhicking »

Hi!

Can you give examples what you actually did? What other options did you set, maybe it's a problem of automatic upper/lowercasing? I can't reproduce the tags being doubled here.

Also please tell us your s9y/plugin versions.

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

Re: Question and Bugreport for freetag plugin

Post by WebComPas »

Hi!

Actually I'm using S9Y v1.4 and freetag plugin v3.0. The options upper/lowercasing and tags-from-categories are disabled.

The problem occured after I had done the following things:
  • First I created a new entry and added the corresponding tags.
  • After that I assigned keywords to the tags which should be added automatically.
  • Then I saved the before created entry and after that the tags were in the tags field more than once.
Regards,
Pascal
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Question and Bugreport for freetag plugin

Post by garvinhicking »

Hi!

I cannot reproduce this. I created an automatic keyword "garvin" which tags entries with "default" and "general".

I then created a new entry and assigned the tag "test" to it, also using the word "garvin" in it. I saved the entry. The two tags where autoassigned.

Then I clicked on "edit entries" and in the list of tags I saw "test, general, garvin". I saved the entry (without changing anything) and the tags do not duplicate themselves.

Can you please describe which actual tags you used so that I can get a way to reproduce the behaviour you describe?

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

Re: Question and Bugreport for freetag plugin

Post by WebComPas »

Hi!

The problem even occurs when there were no tags selected when saving the entry for the first time. When I save it a second time without changing anything the automatically added tags are added a second time. So the tags field for example contains "Blog,S9Y,Serendipity,Blog,S9Y,Serendipity" instead of "Blog,S9Y,Serendipity". Does this help you?

What about my feature suggestion for an option to enable/disable autmatic tag assigning?


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: Question and Bugreport for freetag plugin

Post by garvinhicking »

Hi!

IMHO an option for automatted keywords is a bit strange; either I use keywords, or I don't -- why should it be disabled?

Could it be that your patch of the plugin is the reason why you get problems? Try it with an umodified version of the plugin in its recent version.

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

Re: Question and Bugreport for freetag plugin

Post by WebComPas »

Hi!

The idea was to have the possibility to prevent such strange behaviours temporarily. Otherwise it can only be disabled by removing the keywords for all tags, which is'n very comfortable.

I've tried it already with an unmodified version, because I applied the patch only to my develop system. But the problem also occurs in the live system which isn't modified.

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: Question and Bugreport for freetag plugin

Post by garvinhicking »

Hi!
The idea was to have the possibility to prevent such strange behaviours temporarily.
I'd rather like to find the reason why you get duplicate tags in first place, which shouldn't happen. :-)
I've tried it already with an unmodified version, because I applied the patch only to my develop system. But the problem also occurs in the live system which isn't modified.
Can you record a video of how this is happening, and/or describe the steps to reproduce it in detail? With the steps I mentioned, I get no problems.

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

Re: Question and Bugreport for freetag plugin

Post by WebComPas »

Hi Garvin,

unfortunately I can't record a video but I hope these screenshots will help you too.

Regards,
Pascal

PS: At the moment it wasn't not possible to attach the screenshots directly to this post, because any time I tried it the HTTP connection was reset. This somtimes also happened when submitting a normal post. I also tried it with other attachments and another computer (also using another internet connection).
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Question and Bugreport for freetag plugin

Post by garvinhicking »

Hi!

NOW we are talking.

This happens because you use multiple keywords that each assign the same Tag! This is completely different than what you actually reported previously. This is why telling me the exact steps is very important to find any actual bugs. :-)

Can you please search for this code in your serendipity_event_freetag.php file:

Code: Select all

$tags = $this->makeTagsFromTagList($serendipity['POST']['properties']['freetag_tagList']);

$searchtext = $eventData['body'] . $eventData['extended'];
foreach($automatted AS $keyword => $ktags) {
    $keyword = trim($keyword);
    if (empty($keyword)) continue;
    if (!is_array($ktags) || count($ktags) < 1) continue;
    if (stristr($searchtext, $keyword)) {
        foreach($ktags AS $tag => $is_assigned) {
            if (!is_array($tags) || !in_array(strtolower($tag), $tags)) {
                if ($to_lower) {
                    if (function_exists("mb_strtolower")) {
                        $tag = mb_strtolower($tag);
                    } else {
                        $tag = strtolower($tag);
                    }
                }

                $tags[] = $tag;
                printf(PLUGIN_EVENT_FREETAG_KEYWORDS_ADD, htmlspecialchars($keyword), htmlspecialchars($tag));
            }
        }
    }
}
and replace it with:

Code: Select all

$tags = $this->makeTagsFromTagList($serendipity['POST']['properties']['freetag_tagList']);

echo "Current: <pre>" . print_r($tags, true) . "</pre><br />\n";

$searchtext = $eventData['body'] . $eventData['extended'];
foreach($automatted AS $keyword => $ktags) {
    $keyword = trim($keyword);
    if (empty($keyword)) continue;
    if (!is_array($ktags) || count($ktags) < 1) continue;
    if (stristr($searchtext, $keyword)) {
        foreach($ktags AS $tag => $is_assigned) {
            if (!is_array($tags) || !in_array(strtolower($tag), $tags)) {
                if (!is_array($tags)) echo "Inserting $tag because no array<br />";
                if (!in_array(strtolower($tag), $tags)) echo "Inserting $tag because no lower match<br />";
                if (!in_array($tag, $tags)) echo "Inserting $tag because no actual match<br />";

                if ($to_lower) {
                    if (function_exists("mb_strtolower")) {
                        $tag = mb_strtolower($tag);
                    } else {
                        $tag = strtolower($tag);
                    }
                }

                $tags[] = $tag;
                printf(PLUGIN_EVENT_FREETAG_KEYWORDS_ADD, htmlspecialchars($keyword), htmlspecialchars($tag));
            } else {
                echo "Skipping $tag because already in array<br />\n";
            }
        }
    }
}
And then try again to post a duplicate tagged entry and tell me the extra output you get.

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

Re: Question and Bugreport for freetag plugin

Post by WebComPas »

OK, I already suspected, that the problem could be something like that.

I replaced the code as you told me to. The extra output is:

Code: Select all

Current:

Array
(
    [0] => Apache
    [1] => Blog
    [2] => CMS
    [3] => Office
    [4] => openSource
    [5] => S9Y
    [6] => Serendipity
)


Inserting Blog because no lower match
Schlüsselwort Serendipity gefunden, Tag Blog automatisch zugewiesen.
Inserting openSource because no lower match
Schlüsselwort Serendipity gefunden, Tag openSource automatisch zugewiesen.
Inserting S9Y because no lower match
Schlüsselwort Serendipity gefunden, Tag S9Y automatisch zugewiesen.
Inserting Serendipity because no lower match
Schlüsselwort Serendipity gefunden, Tag Serendipity automatisch zugewiesen.
Inserting S9Y because no lower match
Schlüsselwort S9Y gefunden, Tag S9Y automatisch zugewiesen.
Inserting Serendipity because no lower match
Schlüsselwort S9Y gefunden, Tag Serendipity automatisch zugewiesen.
Inserting Office because no lower match
Schlüsselwort Word gefunden, Tag Office automatisch zugewiesen.
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: Question and Bugreport for freetag plugin

Post by garvinhicking »

Hi!

Ah. The problem seems to be that the plugin code checks for lowercased tags everywhere; it is not built to deal with mixed-case tags.

I've patched the code like this:

http://php-blog.cvs.sourceforge.net/vie ... 9&r2=1.130

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

Re: Question and Bugreport for freetag plugin

Post by WebComPas »

Hi Garvin,

I just updated the plugin to th new version. Now it works, as it should.
Thanks a lot!

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