From 4b140ba78e375b61c2e9f22b957fd0e07a5e8722 Mon Sep 17 00:00:00 2001
From: Chuck Scott The last database version set for the ".$a['name']." (V$dbVersion) isn't valid. ";
+ $db_error = true;
+ } else {
- // Get the number of tables for this plugin database version that should exist.
- $tables = $a['database']['dbVersions'][$dbVersion]['tables'];
+ // Get the number of tables for this plugin database version that should exist.
+ $tables = $a['database']['dbVersions'][$dbVersion]['tables'];
- // Since MYSQL considers an underscore (_) to be a single character wild-card, we need to escape them.
- $prefixEscaped = str_replace('_', '\_', $a['database']['dbPrefix']);
+ // Since MYSQL considers an underscore (_) to be a single character wild-card, we need to escape them.
+ $prefixEscaped = str_replace('_', '\_', $a['database']['dbPrefix']);
- // Get the number of tables for this plugin that match the
- $existingTables = $this->wpdb->get_var("
- SELECT COUNT(*)
- FROM information_schema.tables
- WHERE table_schema = '".DB_NAME."'
- AND table_name like '$prefixEscaped%';
- ");
+ // Get the number of tables for this plugin that match the
+ $existingTables = $this->wpdb->get_var("
+ SELECT COUNT(*)
+ FROM information_schema.tables
+ WHERE table_schema = '".DB_NAME."'
+ AND table_name like '$prefixEscaped%';
+ ");
- // If there's no tables, just assume we need to install all new ones.
- if ($existingTables == 0) {
+ // If there's no tables, just assume we need to install all new ones.
+ if ($existingTables == 0) {
- $dbVersion = false;
+ $dbVersion = false;
+
+ // Otherwise check if the number of tables is correct
+ } elseif ($tables != $existingTables) {
+ $startupNotices .= ' We do not have the correct number of tables for the currently set database version (V'.$dbVersion.') for '.$a['name'].'.'
+ ." New database tables installed for the '.$a['name'].' plugin. Failure installing database tables for the '.$a['name']
.'
There should be $tables but there are currently $existingTables. Please call for support.
There should be $tables but there are currently $existingTables. Please call for support."
- );
- return false;
}
}
// If glmMembersDatabaseDbVersion is not set, install current version
- if (!$dbVersion) {
-
- // If $option is not 'install', then don't do it;
- if ($option != 'install') {
- return false;
- }
+ if (!$dbVersion && !$db_error) {
// Get current database version
$dbVersion = $a['database']['dbCurrentVersion'];
@@ -273,7 +269,7 @@ class GlmPluginSupport
if (trim($queryError) == '') {
// Notify the user that the database has been installed
- update_option('glmMembersInstallErrors', 'New database tables installed for the '.$a['name'].' plugin.');
+ $startupNotices .= '
Database Installation Error: '.print_r($queryError,1)
- .''.$q.'
'
- );
+ .''.$q.'
Plugin '.$a['name'].' Deactivated.
'; + + } } // For each plugin return $all_db_setup_status; @@ -519,3 +520,14 @@ function glmMembersAdminNotices($windowed = true) } +/** + * Display Git Branch as an admin warning + * + * @return void + * @access public + */ +function glmMembersInstallErrorsNotice() { + $installErrors = get_option('glmMembersInstallErrors'); + echo '
'.$startupNotices.'
{$a.print_r}-
{$a.print_r}+