[geeklog-cvs] geeklog: trigger_error() only throws an E_USER_NOTICE by default...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Dec 28 05:40:15 EST 2009
changeset 7538:45315295756f
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/45315295756f
user: Dirk Haun <dirk at haun-online.de>
date: Mon Dec 28 11:37:47 2009 +0100
description:
trigger_error() only throws an E_USER_NOTICE by default, which we won't catch due to the error_reporting() in lib-common.php. Throw & catch E_USER_ERROR instead.
diffstat:
public_html/lib-common.php | 2 +-
system/classes/template.class.php | 2 +-
system/databases/mssql.class.php | 2 +-
system/databases/mysql.class.php | 2 +-
system/databases/pgsql.class.php | 1608 +++++++++++++++++++++---------------------
5 files changed, 808 insertions(+), 808 deletions(-)
diffs (truncated from 1660 to 300 lines):
diff -r 795da50ed8b6 -r 45315295756f public_html/lib-common.php
--- a/public_html/lib-common.php Sun Dec 20 18:05:06 2009 +0100
+++ b/public_html/lib-common.php Mon Dec 28 11:37:47 2009 +0100
@@ -34,7 +34,7 @@
// +---------------------------------------------------------------------------+
// Prevent PHP from reporting uninitialized variables
-error_reporting( E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR );
+error_reporting(E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR | E_USER_ERROR);
/**
* This is the common library for Geeklog. Through our code, you will see
diff -r 795da50ed8b6 -r 45315295756f system/classes/template.class.php
--- a/system/classes/template.class.php Sun Dec 20 18:05:06 2009 +0100
+++ b/system/classes/template.class.php Mon Dec 28 11:37:47 2009 +0100
@@ -918,7 +918,7 @@
*/
function haltmsg($msg) {
if ($this->halt_on_error == 'yes') {
- trigger_error(sprintf("Template Error: %s", $msg));
+ trigger_error(sprintf("Template Error: %s", $msg), E_USER_ERROR);
} else {
printf("<b>Template Error:</b> %s<br" . XHTML . ">\n", $msg);
}
diff -r 795da50ed8b6 -r 45315295756f system/databases/mssql.class.php
--- a/system/databases/mssql.class.php Sun Dec 20 18:05:06 2009 +0100
+++ b/system/databases/mssql.class.php Mon Dec 28 11:37:47 2009 +0100
@@ -448,7 +448,7 @@
} else {
- $result = @mssql_query($sql,$this->_db) or trigger_error($this->dbError($sql) . ' - ' . $sql);
+ $result = @mssql_query($sql,$this->_db) or trigger_error($this->dbError($sql) . ' - ' . $sql, E_USER_ERROR);
if($result==FALSE){
echo "Query Failed: ";
echo "<pre>".$this->dbError($sql) . "</pre><hr" . XHTML . ">";
diff -r 795da50ed8b6 -r 45315295756f system/databases/mysql.class.php
--- a/system/databases/mysql.class.php Sun Dec 20 18:05:06 2009 +0100
+++ b/system/databases/mysql.class.php Mon Dec 28 11:37:47 2009 +0100
@@ -257,7 +257,7 @@
if ($ignore_errors == 1) {
$result = @mysql_query($sql,$this->_db);
} else {
- $result = @mysql_query($sql,$this->_db) or trigger_error($this->dbError($sql));
+ $result = @mysql_query($sql,$this->_db) or trigger_error($this->dbError($sql), E_USER_ERROR);
}
// If OK, return otherwise echo error
diff -r 795da50ed8b6 -r 45315295756f system/databases/pgsql.class.php
--- a/system/databases/pgsql.class.php Sun Dec 20 18:05:06 2009 +0100
+++ b/system/databases/pgsql.class.php Mon Dec 28 11:37:47 2009 +0100
@@ -1,804 +1,804 @@
-<?php
-
-/* Reminder: always indent with 4 spaces (no tabs). */
-// +---------------------------------------------------------------------------+
-// | Geeklog 1.6 |
-// +---------------------------------------------------------------------------+
-// | mysql.class.php |
-// | |
-// | mysql database class |
-// +---------------------------------------------------------------------------+
-// | Copyright (C) 2000-2009 by the following authors: |
-// | |
-// | Authors: Stanislav Palatnik, spalatnikk AT gmail DoT com |
-// +---------------------------------------------------------------------------+
-// | |
-// | This program is free software; you can redistribute it and/or |
-// | modify it under the terms of the GNU General Public License |
-// | as published by the Free Software Foundation; either version 2 |
-// | of the License, or (at your option) any later version. |
-// | |
-// | This program is distributed in the hope that it will be useful, |
-// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-// | GNU General Public License for more details. |
-// | |
-// | You should have received a copy of the GNU General Public License |
-// | along with this program; if not, write to the Free Software Foundation, |
-// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
-// | |
-// +---------------------------------------------------------------------------+
-
-/**
-* This file is the pgsql implementation of the Geeklog abstraction layer.
-* Unfortunately the Geeklog abstraction layer isn't 100% abstract because a few
-* key functions use MySQL's REPLACE INTO syntax which is not a SQL standard.
-* This issue will need to be resolved some time ...
-*
-*/
-
-class DataBase
-{
- // PRIVATE PROPERTIES
- /**
- * @access private
- */
- private $_host = '';
- /**
- * @access private
- */
- private $_name = '';
- /**
- * @access private
- */
- private $_user = '';
- /**
- * @access private
- */
- private $_pass = '';
- /**
- * @access private
- */
- private $_db = '';
- /**
- * @access private
- */
- private $_verbose = false;
- /**
- * @access private
- */
- private $_display_error = false;
- /**
- * @access private
- */
- private $_errorlog_fn = '';
- /**
- * @access private
- */
- private $_charset = '';
- /**
- * @access private
- */
- private $_pgsql_version = 0;
-
- // PRIVATE METHODS
-
- /**
- * Logs messages
- *
- * Logs messages by calling the function held in $_errorlog_fn
- *
- * @param string $msg Message to log
- */
- function _errorlog($msg)
- {
- $function = $this->_errorlog_fn;
- if (function_exists($function)) {
- $function($msg);
- }
- }
-
- /**
- * Creates a connection string, the way pgSQL likes it
- * Doesn't show the port because it isnt being provided in class default assumed'
- *
- */
- function buildString()
- {
- $conn_string = '';
- $conn_string .= (!empty($this->_host))? 'host='.$this->_host:'localhost';
- $conn_string .= (!empty($this->_name))? ' dbname='.$this->_name:'';
- $conn_string .= (!empty($this->_user))? ' user='.$this->_user:'';
- $conn_string .= (!empty($this->_pass))? ' password='.$this->_pass:'';
-
- return $conn_string;
- }
-
- /**
- * Connects to the pgSQL database server
- *
- * This function connects to the MySQL server and returns the connection object
- *
- * @return object Returns connection object
- *
- */
- function _connect()
- {
- if ($this->isVerbose()) {
- $this->_errorlog("\n*** Inside database->_connect ***");
- }
-
- // Connect to pgSQL server
- $this->_db = pg_connect($this->buildString()) or die('Cannot connect to DB server');
-
- if ($this->_pgsql_version == 0) {
- $v = pg_version($this->_db);
- $this->_pgsql_version = $v['client'];
- }
-
- if (!($this->_db)) {
- if(pg_connection_busy($this->_db))
- {
- if ($this->isVerbose()) {
- $this->_errorlog("\n*** The current connection is busy ***");
- }
- }
- else
- {
- if ($this->isVerbose()) {
- $this->_errorlog("\n*** Error in database->_connect ***");
- }
- }
- }
-
- if ($this->_pgsql_version >= 7.4) {
- if ($this->_charset == 'utf-8') {
- pg_query($this->_db,"SET NAMES 'UTF8'"); //only pgsql > 7.4 supports utf8
- }
- }
-
- if ($this->isVerbose()) {
- $this->_errorlog("\n***leaving database->_connect***");
- }
- }
-
-
-
- // PUBLIC METHODS
-
- /**
- * constructor for database
- *
- * This initializes an instance of the database object
- *
- * @param string $dbhost Database host
- * @param string $dbname Name of database
- * @param sring $dbuser User to make connection as
- * @param string $pass Password for dbuser
- * @param string $errorlogfn Name of the errorlog function
- * @param string $charset character set to use
- *
- */
- function database($dbhost,$dbname,$dbuser,$dbpass,$errorlogfn='',$charset='')
- {
- $this->_host = $dbhost;
- $this->_name = $dbname;
- $this->_user = $dbuser;
- $this->_pass = $dbpass;
- $this->_verbose = false;
- $this->_errorlog_fn = $errorlogfn;
- $this->_charset = strtolower($charset);
- $this->_pgsql_version = 0;
-
- $this->_connect();
- }
-
- /**
- * Retrieves returns the number of effected rows for last query
- *
- * Retrieves returns the number of effected rows for last query
- *
- * @param object $recordset The recordset to operate on
- * @return int Number of rows affected by last query
- *
- */
- function dbAffectedRows($recordset)
- {
- if(!isset($recordset))
- {
- $recordset = pg_get_result($this->_db);
- }
- return @pg_affected_rows($recordset);
- }
-
- /**
- * Returns the contents of one cell from a MySQL result set
- *
- * @param object $recordset The recordset to operate on
- * @param int $row row to get data from
- * @param string $field field to return
- * @return (depends on field content)
- *
- */
- function dbResult($recordset,$row,$field=0)
- {
- if ($this->isVerbose()) {
- $this->_errorlog("\n*** Inside database->dbResult ***");
- if (empty($recordset)) {
- $this->_errorlog("\n*** Passed recordset isn't valid ***");
- } else {
- $this->_errorlog("\n*** Everything looks good ***");
- }
- $this->_errorlog("\n*** Leaving database->dbResult ***");
- }
- return @pg_fetch_result($recordset,$row,$field);
- }
-
- /**
- * Retrieves record from a recordset
- *
- * Gets the next record in a recordset and returns in array
- *
- * @param object $recordset The recordset to operate on
- * @param boolean $both get both assoc and numeric indices
- * @return array Returns data array of current row from recordset
- *
- */
- function dbFetchArray($recordset, $both = false)
- {
More information about the geeklog-cvs
mailing list