Page 1 of 1

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

Posted: Sat Jun 21, 2014 12:40 am
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         }

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

Posted: Mon Jun 23, 2014 9:38 am
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