From b64f960124452301abd69ae3bd7ac4daee420550 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 5 Jul 2010 06:12:49 +0000 Subject: [PATCH] Wrapper function isVerboseSqlEnabled() introduced --- inc/extensions-functions.php | 4 ++-- inc/modules/admin/overview-inc.php | 6 +++--- inc/modules/admin/what-config_extensions.php | 2 +- inc/modules/admin/what-extensions.php | 2 +- inc/wrapper-functions.php | 12 ++++++++++++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index 2cd8a035af..c4e88abaf0 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -741,7 +741,7 @@ function addExtensionVerboseSqlTable ($title = '', $dashed = '', $switch = false $OUT = ''; // Do we have queries? - if ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')) { + if (isVerboseSqlEnabled()) { // Do we have entries? if (countExtensionSqls() > 0) { // Init counter @@ -1076,7 +1076,7 @@ function addExtensionNotes ($ext_ver) { $content = array(); // Is do we have verbose output enabled? - if ((!isExtensionActive('sql_patches')) || (getConfig('verbose_sql') == 'Y')) { + if ((!isExtensionActive('sql_patches')) || (isVerboseSqlEnabled())) { // Update notes found? if (isExtensionUpdateNoteSet($ext_ver)) { // Update notes found diff --git a/inc/modules/admin/overview-inc.php b/inc/modules/admin/overview-inc.php index abeab6b2fe..870c5b277e 100644 --- a/inc/modules/admin/overview-inc.php +++ b/inc/modules/admin/overview-inc.php @@ -195,7 +195,7 @@ LIMIT 1", $title = '{--TASK_NO_TITLE--}'; // Shall I list SQL commands assigned to an extension installation or update task? - if ((getConfig('verbose_sql') == 'Y')) { + if (isVerboseSqlEnabled()) { // Extract extension name from subject $ext_name = substr($taskData['subject'], 1, strpos($taskData['subject'], ':') - 1); @@ -243,7 +243,7 @@ LIMIT 1", } // Add SQLs to a table - if ((!empty($ext_name)) && (isExtensionInstalled('sql_patches')) && (getConfig('verbose_sql') == 'Y')) { + if ((!empty($ext_name)) && (isVerboseSqlEnabled())) { // Add verbose SQL table $taskData['text'] .= addExtensionVerboseSqlTable($title, ' class="admin_table top left right"', true, '100%') . "
\n"; } // END - if @@ -258,7 +258,7 @@ LIMIT 1", $taskData['text'] .= getExtensionNotes(); } else { // This should not normally happen! - debug_report_bug(__FILE__, __LINE__, 'ext_name(' . $ext_name . ') or ext_ver(' . $ext_ver . ') is empty! sql_patches=' . getExtensionVersion('sql_patches') . '/verbose_sql=' . getConfig('verbose_sql')); + debug_report_bug(__FILE__, __LINE__, 'ext_name(' . $ext_name . ') or ext_ver(' . $ext_ver . ') is empty! isVerboseSqlEnabled=' . intval(isVerboseSqlEnabled())); } // Prepare array for the template diff --git a/inc/modules/admin/what-config_extensions.php b/inc/modules/admin/what-config_extensions.php index 2f771ec710..fd4d74d79a 100644 --- a/inc/modules/admin/what-config_extensions.php +++ b/inc/modules/admin/what-config_extensions.php @@ -40,7 +40,7 @@ // Some security stuff... if ((!defined('__SECURITY')) || (!isAdmin())) { die(); -} +} // END - if // Add description as navigation point addMenuDescription('admin', __FILE__); diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index 342fbf86b6..12aeec675f 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -176,7 +176,7 @@ if (isGetRequestParameterSet('reg_ext')) { // Get extension name $ext_name = getExtensionName($taskId); - if (getConfig('verbose_sql') == 'Y') { + if (isVerboseSqlEnabled()) { // Load SQL commands in remove mode if (loadExtension($ext_name, 'remove', '', true)) { // Generate extra table with loaded SQL commands diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 770b350958..6eb8cf1e40 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -1706,5 +1706,17 @@ function ifPostContainsSelections ($element = 'sel') { return $GLOBALS['post_contains_selections'][$element]; } +// Checks wether verbose_sql is Y and returns true/false if so +function isVerboseSqlEnabled () { + // Do we have cache? + if (!isset($GLOBALS['is_verbose_sql_enabled'])) { + // Determine it + $GLOBALS['is_verbose_sql_enabled'] = ((isExtensionInstalledAndNewer('sql_patches', '0.0.7')) && (getConfig('verbose_sql') == 'Y')); + } // END - if + + // Return cache + return $GLOBALS['is_verbose_sql_enabled']; +} + // [EOF] ?> -- 2.39.5