diff --git a/phpgwapi/inc/class.db_pgsql.inc.php b/phpgwapi/inc/class.db_pgsql.inc.php
index ec23449ea6..28aa29b0a6 100644
--- a/phpgwapi/inc/class.db_pgsql.inc.php
+++ b/phpgwapi/inc/class.db_pgsql.inc.php
@@ -43,6 +43,10 @@
// PostgreSQL changed somethings from 6.x -> 7.x
var $db_version;
+ // For our error handling
+ var $xmlrpc = False;
+ var $soap = False;
+
function ifadd($add, $me)
{
if('' != $add)
@@ -55,6 +59,16 @@
function db($query = '')
{
$this->query($query);
+
+ if (ereg('xmlrpc.php',$GLOBALS['PHP_SELF']))
+ {
+ $this->xmlrpc = True;
+ }
+
+ if (ereg('soap.php',$GLOBALS['PHP_SELF']))
+ {
+ $this->soap = True;
+ }
}
function connect()
@@ -193,7 +207,7 @@
/* printf("
Debug: query = %s
\n", $Query_String); */
- $this->Query_ID = pg_Exec($this->Link_ID, $Query_String);
+ $this->Query_ID = @pg_Exec($this->Link_ID, $Query_String);
$this->Row = 0;
$this->Error = pg_ErrorMessage($this->Link_ID);
@@ -463,31 +477,75 @@
print $this->Record[$Name];
}
- function halt($msg, $line = "", $file = "")
+ function halt($msg, $line = '', $file = '')
{
- if($this->Halt_On_Error == "no")
+ if ($this->Halt_On_Error == 'no')
{
return;
}
- /* Just in case there is a table currently locked */
- $this->unlock();
- printf("Database error: %s
\n", $msg);
- printf("PostgreSQL Error: %s (%s)
\n",
- $this->Errno,
- $this->Error);
+ /* Just in case there is a table currently locked */
+ $this->transaction_abort();
+
+
+ if ($this->xmlrpc || $this->soap)
+ {
+ $s = sprintf("Database error: %s\n", $msg);
+ $s .= sprintf("PostgreSQL Error: %s\n\n (%s)\n\n",$this->Errno,$this->Error);
+ }
+ else
+ {
+ $s = sprintf("Database error: %s
\n", $msg);
+ $s .= sprintf("PostgreSQL Error: %s (%s)
\n",$this->Errno,$this->Error);
+ }
+
if ($file)
{
- printf("
File: %s",$file);
+ if ($this->xmlrpc || $this->soap)
+ {
+ $s .= sprintf("File: %s\n",$file);
+ }
+ else
+ {
+ $s .= sprintf("
File: %s",$file);
+ }
}
+
if ($line)
{
- printf("
Line: %s",$line);
+ if ($this->xmlrpc || $this->soap)
+ {
+ $s .= sprintf("Line: %s\n",$line);
+ }
+ else
+ {
+ $s .= sprintf("
Line: %s",$line);
+ }
}
if ($this->Halt_On_Error == 'yes')
{
- echo '
Session halted.'; + if (! $this->xmlrpc && ! $this->soap) + { + $s .= '
Session halted.'; + } + } + + if ($this->xmlrpc || $this->soap) + { + $r = CreateObject('phpgwapi.xmlrpcresp', + CreateObject('phpgwapi.xmlrpcval'), + $GLOBALS['xmlrpcerr']['unknown_method'], + $s + ); + $payload = "\n" . $r->serialize(); + Header("Content-type: text/xml\r\nContent-length: " . strlen($payload)); + print $payload; + $GLOBALS['phpgw']->common->phpgw_exit(False); + } + else + { + echo $s; $GLOBALS['phpgw']->common->phpgw_exit(True); } }