Page 1 of 1
Freetags with apostrophe
Posted: Sat Nov 05, 2005 10:11 pm
by mattsches
I just updated to the latest freetag and tagcloud plugins. Problem is that I have some tags with apostrophes in them; an apostrophe does not seem to be escaped in the SQL query. Consequently, after clicking on one of these tags in the tag cloud, I get an SQL error:
Code: Select all
WHERE isdraft = 'false' AND e.timestamp <= '1131224625' AND entrytags.tag = 'fat freddy's drop' AND
One little question (slightly OT): How can I prevent tags from being displayed in the tag cloud that exist only once ("orphaned tags")?
Re: Freetags with apostrophe
Posted: Sun Nov 06, 2005 2:06 pm
by garvinhicking
Hi!
Thanks a lot for mentioning this. It can be fixed with this patch:
Code: Select all
Index: serendipity_event_freetag.php
===================================================================
RCS file: /cvsroot/php-blog/additional_plugins/serendipity_event_freetag/serendipity_event_freetag.php,v
retrieving revision 1.28
diff -u -r1.28 serendipity_event_freetag.php
--- serendipity_event_freetag.php 3 Nov 2005 12:13:47 -0000 1.28
+++ serendipity_event_freetag.php 6 Nov 2005 13:01:24 -0000
@@ -458,7 +458,7 @@
case 'frontend_fetchentries':
case 'frontend_fetchentry':
if (!empty($this->tags['show'])) {
- $showtag = $this->tags['show'];
+ $showtag = serendipity_db_escape_string($this->tags['show']);
} else if (!empty($serendipity['GET']['tag'])) {
$showtag = serendipity_db_escape_string(strtolower(urldecode($serendipity['GET']['tag'])));
}
I also committed that, of course.
About your orphaned tags, I must admit I'm not much into the code and you might want to ask Jonathan Arkell about that. But in the place where I modified the code above you find this:
Code: Select all
if (!empty($showtag)) {
if (is_string($showtag)) {
$join = "LEFT JOIN {$serendipity['dbPrefix']}entrytags AS entrytags ON (e.id = entrytags.entryid) ";
$cond = "entrytags.tag = '$showtag' ";
}
If you put this into the if-structure:
Code: Select all
$eventData['having'] = " HAVING count(entrytags.tag) > 1";
This might(!) only show tags which have more than one relevance...
HTH,
Garvin
Posted: Sun Nov 06, 2005 7:51 pm
by mattsches
Thanks very much for fixing the bug, works like a charm now.
About the orphaned tags: No, your suggestion does not work. But now I've got an idea about where in the code to look for a solution. As soon as I find the time and changed it, I will post it here. Otherwise I'll have to ask Jonathan Arkell, but I'm pretty confident that I can figure it out myself.
![Wink :wink:](./images/smilies/icon_wink.gif)
Thanks again.
Posted: Sun Nov 06, 2005 9:06 pm
by garvinhicking
That would be great, of course. Good luck!
Regards,
Garvin
Display only tags which have been used >1 times
Posted: Tue Nov 08, 2005 4:20 pm
by mattsches
Well, I found a simple solution. Edited serendipity_plugin_freetag.php:
Code: Select all
87c87,89
< $tags[$r['tag']] = $r['total'];
---
> if ($r['total'] > 1) {
> $tags[$r['tag']] = $r['total'];
> }
I don't know if this is against all good practice, but it works for me
![Wink :wink:](./images/smilies/icon_wink.gif)
Modifying the preceding query using a WHERE clause didn't work, though.