# HG changeset patch # User Dan # Date 1231727796 18000 # Node ID ae4ef502f7425fe47630d5d25ed003f5ba92f538 # Parent 97cd1a3229d0e802c45036d4b1c6516560b4b21c DBAL: Fixed issues with die_json() and multiline responses from {mysql,pg_last}_error() diff -r 97cd1a3229d0 -r ae4ef502f742 includes/dbal.php --- a/includes/dbal.php Sun Jan 11 21:35:39 2009 -0500 +++ b/includes/dbal.php Sun Jan 11 21:36:36 2009 -0500 @@ -41,6 +41,7 @@ var $row = array(); var $rowset = array(); var $errhandler; + var $dbms_name = 'MySQL'; function enable_errorhandler() { @@ -105,7 +106,7 @@ function die_json($loc = false) { - $e = addslashes(htmlspecialchars(mysql_error())); + $e = str_replace("\n", "\\n", addslashes(htmlspecialchars(mysql_error()))); $q = str_replace("\n", "\\n", addslashes($this->latest_query)); $loc = ( $loc ) ? addslashes("\n\nDescription or location of error: $loc") : ""; $loc .= "\n\nPlease report the full text of this error to the administrator of the site. If you believe that this is a bug with the software, please contact support@enanocms.org."; @@ -771,6 +772,7 @@ var $row = array(); var $rowset = array(); var $errhandler; + var $dbms_name = 'PostgreSQL'; function sql_backtrace() { @@ -809,9 +811,12 @@ function die_json() { - $e = addslashes(htmlspecialchars(pg_last_error())); - $q = addslashes($this->latest_query); - $t = "{'mode':'error','error':'An error occurred during database query.\nQuery was:\n $q\n\nError returned by PostgreSQL: $e'}"; + $e = str_replace("\n", "\\n", addslashes(htmlspecialchars(pg_last_error()))); + $q = str_replace("\n", "\\n", addslashes($this->latest_query)); + $loc = ( $loc ) ? addslashes("\n\nDescription or location of error: $loc") : ""; + $loc .= "\n\nPlease report the full text of this error to the administrator of the site. If you believe that this is a bug with the software, please contact support@enanocms.org."; + $loc = str_replace("\n", "\\n", $loc); + $t = "{\"mode\":\"error\",\"error\":\"An error occurred during database query.\\nQuery was:\\n $q\\n\\nError returned by MySQL: $e$loc\"}"; die($t); }