[2.0.0-beta 2] spamblock table updates fail on pgsql

Found a bug? Tell us!!
Post Reply
rohdef
Posts: 4
Joined: Sat Jun 14, 2014 6:08 pm

[2.0.0-beta 2] spamblock table updates fail on pgsql

Post by rohdef »

Just had the following error:

Code: Select all

Fatal error:  Uncaught exception 'ErrorException' with message 'pg_query(): Query failed: ERROR:  syntax error at or near "CHANGE"
LINE 1: ALTER TABLE serendipity_spamblocklog CHANGE COLUMN ip ip VAR...
                                             ^' in /usr/home/rohdef/www/armchair/include/compat.inc.php:126
Stack trace:
#0 [internal function]: errorToExceptionHandler(2, 'pg_query(): Que...', '/usr/home/rohde...', 222, Array)
#1 /usr/home/rohdef/www/armchair/include/db/postgres.inc.php(222): pg_query(Resource id #22, 'ALTER TABLE ser...')
#2 /usr/home/rohdef/www/armchair/include/db/postgres.inc.php(298): serendipity_db_query('ALTER TABLE ser...')
#3 /usr/home/rohdef/www/armchair/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php(706): serendipity_db_schema_import('ALTER TABLE ser...')
#4 /usr/home/rohdef/www/armchair/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php(849): serendipity_event_spamblock->checkScheme()
#5 /usr/home/rohdef/www/armchair/include/plugin_api.inc.php(1107 in /usr/home/rohdef/www/armchair/include/compat.inc.php on line 126
Could like it's due to mysql-specific code in plugins/serendipit_event_spamblock/serendipity_event_spamblock.php line 705 and 708 where the following lines is:

Code: Select all

 704         if ($dbversion == '2') {
 705             $q = "ALTER TABLE {$serendipity['dbPrefix']}spamblocklog CHANGE COLUMN ip ip VARCHAR(45)";
 706             $sql = serendipity_db_schema_import($q);
 707 
 708             $q = "ALTER TABLE {$serendipity['dbPrefix']}spamblock_htaccess CHANGE COLUMN ip ip VARCHAR(45)";
 709             $sql = serendipity_db_schema_import($q);
 710 
 711             $this->set_config('dbversion', '3');
 712         }
Per specs (http://www.postgresql.org/docs/9.1/stat ... table.html) Posgresql want it to be: ALTER TABLE ... ALTER COLUMN ip TYPE VARCHAR(45), it worked for me by changing the lines to:

Code: Select all

 704         if ($dbversion == '2') {
 705             $q = "ALTER TABLE {$serendipity['dbPrefix']}spamblocklog ALTER COLUMN ip TYPE VARCHAR(45)";
 706             $sql = serendipity_db_schema_import($q);
 707 
 708             $q = "ALTER TABLE {$serendipity['dbPrefix']}spamblock_htaccess ALTER COLUMN ip TYPE VARCHAR(45)";
 709             $sql = serendipity_db_schema_import($q);
 710 
 711             $this->set_config('dbversion', '3');
 712         }
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: [2.0.0-beta 2] spamblock table updates fail on pgsql

Post by garvinhicking »

Hi!

Great, thanks for reporting. This was actually happening in 4 of the 2.0 plugins when we introduced a change to the "ip" field. I've now added a switch that performs the proper SQL for pgsql in those cases.

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/
Post Reply