From 104acec09cc9f1b371a109cb75c7471e69b1d81f Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 08:39:41 +0000 Subject: [PATCH] The database structure is now checked ad the admin summary page --- include/dbstructure.php | 10 ++++++++++ mod/admin.php | 13 +++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index c9c37c9390..413395905d 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -8,6 +8,10 @@ require_once("include/text.php"); define('NEW_UPDATE_ROUTINE_VERSION', 1170); +const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before +const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful +const DB_UPDATE_FAILED = 2; // Database check failed + /* * Converts all tables from MyISAM to InnoDB */ @@ -480,6 +484,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) { Config::set('system', 'maintenance_reason', ''); } + if ($errors) { + Config::set('system', 'dbupdate', DB_UPDATE_FAILED); + } else { + Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL); + } + return $errors; } diff --git a/mod/admin.php b/mod/admin.php index d9f2d95760..d9684d6a4f 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -545,11 +545,16 @@ function admin_page_summary(App $a) { $showwarning = true; $warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See here for a guide that may be helpful converting the table engines. You may also use the command php include/dbstructure.php toinnodb of your Friendica installation for an automatic conversion.
'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html'); } - // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements - if ((version_compare($db->server_info(), '5.7.4') >= 0) AND - !(strpos($db->server_info(), 'MariaDB') !== false)) { - $warningtext[] = t('You are using a MySQL version which does not support all features that Friendica uses. You should consider switching to MariaDB.'); + + if (Config::get('system', 'dbupdate', DB_UPDATE_NOT_CHECKED) == DB_UPDATE_NOT_CHECKED) { + require_once("include/dbstructure.php"); + update_structure(false, true); } + if (Config::get('system', 'dbupdate') == DB_UPDATE_FAILED) { + $showwarning = true; + $warningtext[] = t('The database update failed. Please run "php include/dbstructure.php update" from the command line and have a look at the errors that might appear.'); + } + $r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`"); $accounts = array( array(t('Normal Account'), 0),