From 9968064eb050891128c30cb3d79fb768468a81eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 13 Jun 2010 13:49:47 +0000 Subject: [PATCH] Even more fixes for SQL problems :-( --- inc/db/lib-mysql3.php | 8 ++------ inc/filters.php | 2 +- inc/wrapper-functions.php | 12 ++++++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 73bdd9004d..a851367cb6 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -545,12 +545,8 @@ function SQL_HASZERONUMS ($result) { function SQL_PREPARE_SQL_STRING ($sqlString) { // Is it already cached? if (!isset($GLOBALS['sql_strings'][$sqlString])) { - // No, generate the eval() command - $eval = '$sql = "' . FILTER_COMPILE_EXPRESSION_CODE(FILTER_COMPILE_CONFIG($sqlString)) . '";'; - eval($eval); - - // ... and set it - $GLOBALS['sql_strings'][$sqlString] = $sql; + // No, so compile and set it + $GLOBALS['sql_strings'][$sqlString] = FILTER_COMPILE_EXPRESSION_CODE(compileSqlConfig($sqlString)); } // END - if // Return it diff --git a/inc/filters.php b/inc/filters.php index 424fe9f104..fa28dba400 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -107,7 +107,7 @@ function FILTER_FLUSH_FILTERS () { } // END - if // Shall we update usage counters (ONLY FOR DEBUGGING!) - if ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (getConfig('update_filter_usage') == 'Y')) { + if ((isExtensionInstalledAndNewer('sql_patches', '0.6.0')) && (isConfigEntrySet('update_filter_usage')) && (getConfig('update_filter_usage') == 'Y')) { // Update all counters foreach ($GLOBALS['cache_array']['filter']['counter'] as $filterName => $filterArray) { // Walk through all filters diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 8877bcc150..a184c20331 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -956,5 +956,17 @@ function getHttpStatus () { return $GLOBALS['http_status']; } +// Compiles config entries for SQL queries +function compileSqlConfig ($sqlString) { + // Replace all + foreach (array('_MYSQL_PREFIX', '_TABLE_TYPE') as $configEntry) { + // "Compile" it + $sqlString = str_replace('{?' . $configEntry . '?}', getConfig($configEntry), $sqlString); + } // END - foreach + + // Return the compiled SQL string + return $sqlString; +} + // [EOF] ?> -- 2.39.5