"value too long" in serendipity_suppress

Found a bug? Tell us!!
Post Reply
ads
Regular
Posts: 93
Joined: Sun Oct 29, 2006 11:39 am

"value too long" in serendipity_suppress

Post by ads »

I found the following error in my logfile:
2010-03-28 21:53:58 CEST ERROR: value too long for type character varying(255)
2010-03-28 21:53:58 CEST STATEMENT: INSERT INTO serendipity_suppress
(ip, last, scheme, host, port, path, query)
VALUES (
'xxx.xxx.xxx.xxx',
NOW(),
'http',
'suche.t-online.de',
'',
'/fast-cgi/tsc',
'portallanguage=de&dia=portal&suchraum=1&userlanguage=de&more=variante0x&moreold=variante0x&y=0&x=0&q=tischschmuck&device=html&classification=internet-tab_internet_std&mandant=toi&wo=&context=internet-tab&tpc=internet&ptl=std&adpage=3&www_start=20&www_num=10'
)
What is the reason for having the "query" column limited to 255 characters? In PostgreSQL (my database) there is no such limit. In MySQL this should be a column type with more than 255 chars.


I modified this column to "TEXT" in my database:

Code: Select all

ALTER TABLE serendipity_suppress ALTER COLUMN query TYPE TEXT;
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: "value too long" in serendipity_suppress

Post by garvinhicking »

Hi!

The 255 char limit is more a table size/query speed issue... While your solution should work pretty fine, it also increases the overhead of every data row on the table, and very often longer URLs are from spammers and when large URLs would be displayed in the output of the plugin they could much impact the layout. I'm a bit undecissive whether to change this in the core s9y structure, or to leave it at only supporting "smaller" URLs...?

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/
ads
Regular
Posts: 93
Joined: Sun Oct 29, 2006 11:39 am

Re: "value too long" in serendipity_suppress

Post by ads »

In PostgreSQL there is no difference in data types between VARCHAR(255) and VARCHAR(256) and VARCHAR(500).

I know that MySQL just throws away anything after the 255th byte ;-) and as usual PostgreSQL is more picky and throws an error, because the text does not fit into the column.

So one possible solution could be: just insert the first 255 bytes of the query string, cut them in PHP using the substr() function.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: "value too long" in serendipity_suppress

Post by garvinhicking »

Hi!

A patch for the substr() truncation is committed:

Code: Select all

Index: include/functions.inc.php
===================================================================
--- include/functions.inc.php   (revision 2646)
+++ include/functions.inc.php   (working copy)
@@ -739,6 +739,8 @@

         $ts       = serendipity_db_get_interval('ts');
         $interval = serendipity_db_get_interval('interval', 900);
+
+        $url_parts['query'] = substr($url_parts['query'], 0, 255);

         $suppressq = "SELECT count(1)
                       FROM $serendipity[dbPrefix]suppress
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/
ads
Regular
Posts: 93
Joined: Sun Oct 29, 2006 11:39 am

Re: "value too long" in serendipity_suppress

Post by ads »

Applied. Should work, it's simple.

A quick search in this file shows another function which uses the same functionality: serendipity_track_url()
Should'nt this one also get a substr() call?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: "value too long" in serendipity_suppress

Post by garvinhicking »

Hi!

True that! Thanks for mentioning :)

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/
ads
Regular
Posts: 93
Joined: Sun Oct 29, 2006 11:39 am

Re: "value too long" in serendipity_suppress

Post by ads »

Another table with the same problem: "serendipity_exits", the "query" column again.
Post Reply