OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Bug: DB Error when creating conference using PostgreSQL

Are you responsible for making OCS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, michael, John

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

Bug: DB Error when creating conference using PostgreSQL

Postby derekp » Wed Oct 10, 2007 1:36 am

When OCS is configured to use a PostgreSQL database, conference creation fails with the following error message and stacktrace:

Code: Select all
DB Error: ERROR: invalid input syntax for integer: ""

Stack Trace:
File: ocs-2.0.0-1/classes/rt/ocs/RTDAO.inc.php line 332
Function: DAO->update("INSERT INTO rt_contexts (version_id, title, abbrev, descripti...", Array(9))

File: ocs-2.0.0-1/classes/rt/ocs/RTDAO.inc.php line 139
Function: RTDAO->insertContext(Object(RTContext))

File: ocs-2.0.0-1/classes/rt/ocs/ConferenceRTAdmin.inc.php line 56
Function: RTDAO->insertVersion("2", Object(RTVersion))

File: ocs-2.0.0-1/classes/admin/form/ConferenceSiteSettingsForm.inc.php line 153
Function: ConferenceRTAdmin->restoreVersions(False)

File: ocs-2.0.0-1/pages/admin/AdminConferenceHandler.inc.php line 70
Function: ConferenceSiteSettingsForm->execute()

File: ocs-2.0.0-1/pages/admin/AdminHandler.inc.php line 90
Function: AdminConferenceHandler::updateConference()

File: (unknown) line (unknown)
Function: AdminHandler::updateConference(Array(0))

File: ocs-2.0.0-1/index.php line 46
Function: call_user_func(Array(2), Array(0))

File: ocs-2.0.0-1/index.php line 57
Function: handleRequest()


The environment was:
  • OCS 2.0.0
  • PHP 5.2.0
  • PostgreSQL (libpq) Version 8.1.9

The problem is that the ADODB PostgreSQL driver does not accept PHP booleans as parameters in an SQL query, i.e. the following will fail:

Code: Select all
DAO->update('SELECT * FROM t WHERE attr=?', Array(false));


The following patch fixes the error:

Code: Select all
--- ocs-2.0.0-1/lib/adodb/drivers/adodb-postgres7.inc.php.datatype      2006-12-17 11:55:28.000000000 -0800
+++ ocs-2.0.0-1/lib/adodb/drivers/adodb-postgres7.inc.php       2007-10-02 02:10:43.059418000 -0700
@@ -108,10 +108,15 @@
                                if ($last < $i) $sql .= $v;
                                else $sql .= $v.' $'.$i;
                                $i++;
                        }
 
+                       foreach($inputarr as $k=>$v) {
+                               if (is_bool($v)) {
+                                       $inputarr[$k] = $v ? 1 : 0;
+                               }
+                       }
                        $rez = pg_query_params($this->_connectionID,$sql, $inputarr);
                } else {
                        $rez = pg_query($this->_connectionID,$sql);
                }
                // check if no data returned, then no need to create real recordset
derekp
 
Posts: 16
Joined: Wed Oct 10, 2007 12:45 am
Location: University of British Columbia

Re: Bug: DB Error when creating conference using PostgreSQL

Postby asmecher » Wed Oct 10, 2007 3:42 pm

Hi Derek,

Thanks -- this has already been fixed in CVS (by adding explicit casting to integers rather than modifying the adodb library) and the fix will be released with the next version of OCS.

FYI, the patch is at http://pkp.sfu.ca/cvs/cvsweb.cgi/ocs2/classes/rt/ocs/RTDAO.inc.php.diff?r1=1.3;r2=1.4.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm


Return to OCS Technical Support

Who is online

Users browsing this forum: No registered users and 1 guest