From 58ec53d4cf2bfdd538f09421af1297b4ee67d7ec Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 17 Oct 2017 13:00:03 -0400 Subject: [PATCH] Re-activated management debug flags. Added debug output for critical items in front controller. Removed E-Mail feature that was supposed to send an error message from live sites when there was a front controller problem. Didn't work. --- classes/data/settings/dataSettingsGeneral.php | 5 +- config.php | 7 -- controllers/front.php | 97 +++++++++---------- setup/standardTemplateParams.php | 1 - views/admin/management/index.html | 17 ++-- views/front/members/list.html | 6 +- 6 files changed, 60 insertions(+), 73 deletions(-) diff --git a/classes/data/settings/dataSettingsGeneral.php b/classes/data/settings/dataSettingsGeneral.php index b897983d..d42854e0 100644 --- a/classes/data/settings/dataSettingsGeneral.php +++ b/classes/data/settings/dataSettingsGeneral.php @@ -118,7 +118,7 @@ class GlmDataSettingsGeneral extends GlmDataAbstract /* * Debug Options */ -/* Depreciating debug system + // Admin Debug 'admin_debug' => array( 'field' => 'admin_debug', @@ -146,8 +146,7 @@ class GlmDataSettingsGeneral extends GlmDataAbstract 'type' => 'checkbox', 'use' => 'a' ), -*/ - + /* * Misc Settings */ diff --git a/config.php b/config.php index 5c61c0fb..22c2502b 100644 --- a/config.php +++ b/config.php @@ -34,17 +34,10 @@ if ($glmMembersDatabaseDbVersion) { $config['terms'] = $terms; // Add Debug defines - These can't go into the defines.php file - Guess why. - // Depreciating debug system - define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', false); - define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', false); - define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', false); - define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', false); - /* define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', $settings['admin_debug']); define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', $settings['admin_debug_verbose']); define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG', $settings['front_debug']); define('GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE', $settings['front_debug_verbose']); - */ } // Check for config value replacements in the current theme diff --git a/controllers/front.php b/controllers/front.php index 56a7d3fd..146246bd 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -326,6 +326,10 @@ class glmMembersFront extends GlmPluginSupport $cached = $this->wpdb->get_results($sql, ARRAY_A); if (count($cached) == 1) { + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("Using Cached Result: cache code = $cache_code", E_USER_NOTICE); + } + // Currently cached - Return cached content return $cached[0]['html']; @@ -353,21 +357,11 @@ class glmMembersFront extends GlmPluginSupport $defaultTimeZone = date_default_timezone_get(); date_default_timezone_set($this->config['settings']['time_zone']); - $errorMsg = ''; + $controlError = false; if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { - // Also turn on SQL error messages $this->wpdb->show_errors(); - - // Get all defiend constants then if not VERBOSE select out only user contstants - $consts = get_defined_constants(true); - if (!GLM_MEMBERS_PLUGIN_FRONT_DEBUG_VERBOSE) { - $consts = $consts['user']; - } - - } else { - $this->clearNotices(); } /* @@ -397,7 +391,7 @@ class glmMembersFront extends GlmPluginSupport } } else { - $errorMsg .= 'Missing shortcode default values table entry in table '.$shortcodeData['table'].'
'; + $controlError = true; } } @@ -429,12 +423,21 @@ class glmMembersFront extends GlmPluginSupport ) ); + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("Executing Shortcode: $shortcode", E_USER_NOTICE); + } + } else { - $errorMsg .= "Provided short-code is not valid: $shortcode
"; + $controlError = true; + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("Shortcode Not Valid: $shortcode", E_USER_NOTICE); + } + } // If there's been no error so far, try to process the supplied action - if($errorMsg == '') { + if(!$controlError) { /* * Processing loop - Loop till we have a final action @@ -452,14 +455,14 @@ class glmMembersFront extends GlmPluginSupport // Verify that we have the requested menu item in the valid actions if (! isset($this->config['validActions']['frontActions'][$menuItem])) { - $errorMsg .= "Model doesn't exist: " . $modelName; + $controlError = true; } // Verify Menu item and action as valid action if (! isset($this->config['validActions']['frontActions']) || ! isset($action, $this->config['validActions']['frontActions'][$menuItem])) { - $errorMsg = 'Invalid action requested:
'.$action; + $controlError = true; } /* @@ -473,10 +476,14 @@ class glmMembersFront extends GlmPluginSupport $modelName = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/models/front/$menuItem/$action.php"; $className = 'GlmMembersFront_' . $menuItem . '_' . $action; + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("Model: $modelName", E_USER_NOTICE); + } + // If model file doesn't exist - we have an error if (!file_exists($modelName)) { - $errorMsg .= "Model doesn't exist: " . $modelName; + $controlError = true; // Otherwise, load and run the model } else { @@ -491,7 +498,7 @@ class glmMembersFront extends GlmPluginSupport // check for an invalid model class name if (! class_exists($className)) { - $errorMsg .= "Model class doesn't exist: ".$className; + $controlError = true; } else { @@ -508,6 +515,10 @@ class glmMembersFront extends GlmPluginSupport // Set the new model action $action = $results['modelRedirect']; + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("Model Redirect: ".$results['modelRedirect'], E_USER_NOTICE); + } + // Check if there's also a menu item change if ($results['menuItemRedirect']) { $menuItem = $results['menuItemRedirect']; @@ -537,16 +548,28 @@ class glmMembersFront extends GlmPluginSupport $viewFile = $view; // If the view is not found in the theme, fall back to views in the plugin + $inTheme = ' (In Theme)'; if (!is_file($viewPath.'/'.$viewFile)) { + // Next try the plugin/add-on $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH . "$plugIn/views"; $viewFile = $view; if (!is_file($viewPath.'/'.$viewFile)) { // No matching view file found - $errorMsg .= "Bad or missing view file: $viewPath/$viewFile"; + $controlError = true; + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("Bad or missing view file: $viewPath/$viewFile", E_USER_NOTICE); + } } + + $inTheme = ''; + } + + if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { + trigger_error("View$inTheme: $viewPath", E_USER_NOTICE); } } @@ -577,31 +600,8 @@ class glmMembersFront extends GlmPluginSupport } // if errorMsg - // If there was an error - if ($errorMsg != '' && isset($_SERVER['HTTP_REFERER'])) { - $mailMsg = -" -An error occurred while running the request below. - -Error Msg: $errorMsg -Server: ".$_SERVER['SERVER_NAME']." -Method: ".$_SERVER['REQUEST_METHOD']." -Time: ".date('r', $_SERVER['REQUEST_TIME'])." -Query: ".$_SERVER['QUERY_STRING']." -Referrer: ".$_SERVER['HTTP_REFERER']." -User Agent: ".$_SERVER['HTTP_USER_AGENT']." -Remote Addr: ".$_SERVER['REMOTE_ADDR']." -Filename: ".$_SERVER['SCRIPT_FILENAME']." -URL: http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']." -Request Data: ".print_r($_REQUEST,1)." -"; - mail ( - 'errors@gaslightmedia.com', - 'Front-End GLM Associate Error', - $mailMsg - ); -// $viewPath = GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/views'; -// $viewFile = 'front/error/index.html'; + // If there was a controller error - show error page + if ($controlError != '' && isset($_SERVER['HTTP_REFERER'])) { require_once GLM_MEMBERS_WORDPRESS_PLUGIN_PATH.GLM_MEMBERS_PLUGIN_SLUG.'/models/front/error/index.php'; $model = new GlmMembersFront_error_index($this->wpdb, $this->config); $results = $model->modelAction($actionData); @@ -635,15 +635,6 @@ Request Data: ".print_r($_REQUEST,1)." // Generate output from model data and view $out = $smarty->template->fetch($viewFile); - // If debug is requested, create debug window - if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) { - echo " - - "; - } - // Restore timezone that was set before our code was called date_default_timezone_set($defaultTimeZone); diff --git a/setup/standardTemplateParams.php b/setup/standardTemplateParams.php index 295b203b..14310cd2 100644 --- a/setup/standardTemplateParams.php +++ b/setup/standardTemplateParams.php @@ -53,7 +53,6 @@ if (is_admin()) { // Front specific $smarty->templateAssign('frontDebug', GLM_MEMBERS_PLUGIN_FRONT_DEBUG); - $smarty->templateAssign('errorMsg', $errorMsg); $smarty->templateAssign('thisAction', ((isset($action)) ? $action: '' ) ); } diff --git a/views/admin/management/index.html b/views/admin/management/index.html index fa207e98..323cfc42 100644 --- a/views/admin/management/index.html +++ b/views/admin/management/index.html @@ -20,35 +20,40 @@ - +

 

diff --git a/views/front/members/list.html b/views/front/members/list.html index c7c23aa8..1eb8c5dd 100644 --- a/views/front/members/list.html +++ b/views/front/members/list.html @@ -115,7 +115,7 @@ {foreach $mapItems as $m}
- {apply_filters('glm-member-db-front-members-list-mapBubbleTop', '', $m.member_pointer)} + {apply_filters('glm-member-db-front-members-list-mapBubbleTop', '', $m.member)} {if $m.logo && $settings.list_map_show_logo}
@@ -187,7 +187,7 @@
{/if}
- {apply_filters('glm-member-db-front-members-list-mapBubbleBottom', '', $m.member_pointer)} + {apply_filters('glm-member-db-front-members-list-mapBubbleBottom', '', $m.member)} {/foreach} @@ -558,7 +558,7 @@ position: new google.maps.LatLng({$m.lat}, {$m.lon}), draggable: false, animation: google.maps.Animation.DROP, - title: '{$m.member|escape}', + title: '{$m.name|escape:quotes}', descr: $('#map_info_' + {$m.id}).html(), memberID: {$m.member} }); -- 2.17.1