From 07d71b4c981b8937baeb67a5dd50639b1a8b2042 Mon Sep 17 00:00:00 2001 From: rurban Date: Thu, 12 Oct 2006 06:36:09 +0000 Subject: [PATCH] Guard against unwanted DEBUG="DEBUG" logic. In detail (WikiDB), and generally by forcing all int constants to be defined as int. git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@5174 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/IniConfig.php | 31 ++++++++++++++++++++++++++++--- lib/WikiDB.php | 22 +++++++++++++--------- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/lib/IniConfig.php b/lib/IniConfig.php index c53dc16f0..60395ab00 100644 --- a/lib/IniConfig.php +++ b/lib/IniConfig.php @@ -1,5 +1,5 @@ touch(); // devel checking. - if (DEBUG || _DEBUG_SQL) + if ((int)DEBUG & _DEBUG_SQL) { $this->_backend->check(); } + } /** * Close database connection. @@ -156,7 +157,7 @@ class WikiDB { function getPage($pagename) { static $error_displayed = false; $pagename = (string) $pagename; - if (DEBUG) { + if ((int)DEBUG) { if ($pagename === '') { if ($error_displayed) return false; $error_displayed = true; @@ -669,7 +670,7 @@ class WikiDB_Page function WikiDB_Page(&$wikidb, $pagename) { $this->_wikidb = &$wikidb; $this->_pagename = $pagename; - if (DEBUG) { + if ((int)DEBUG) { if (!(is_string($pagename) and $pagename != '')) { if (function_exists("xdebug_get_function_stack")) { echo "xdebug_get_function_stack(): "; var_dump(xdebug_get_function_stack()); @@ -925,11 +926,11 @@ class WikiDB_Page // // We're doing this here rather than in createRevision because // postgresql can't optimize while locked. - if ((DEBUG & _DEBUG_SQL) + if (((int)DEBUG & _DEBUG_SQL) or (DATABASE_OPTIMISE_FREQUENCY > 0 and (time() % DATABASE_OPTIMISE_FREQUENCY == 0))) { if ($backend->optimize()) { - if (DEBUG) + if ((int)DEBUG) trigger_error(_("Optimizing database"), E_USER_NOTICE); } } @@ -1981,19 +1982,19 @@ class WikiDB_PageRevisionIterator $pagename = $next['pagename']; $version = $next['version']; $versiondata = $next['versiondata']; - if (DEBUG) { + if ((int)DEBUG) { if (!(is_string($pagename) and $pagename != '')) { trigger_error("empty pagename",E_USER_WARNING); return false; } } else assert(is_string($pagename) and $pagename != ''); - if (DEBUG) { + if ((int)DEBUG) { if (!is_array($versiondata)) { trigger_error("empty versiondata",E_USER_WARNING); return false; } } else assert(is_array($versiondata)); - if (DEBUG) { + if ((int)DEBUG) { if (!($version > 0)) { trigger_error("invalid version",E_USER_WARNING); return false; @@ -2271,6 +2272,9 @@ function _sql_debuglog_shutdown_function() { } // $Log: not supported by cvs2svn $ +// Revision 1.143 2006/09/06 05:46:40 rurban +// do db backend check on _DEBUG_SQL +// // Revision 1.142 2006/06/10 11:55:58 rurban // print optimize only when DEBUG // -- 2.45.0