From 7aaaa0a3c75723f6e264fda81b580545c799eb55 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Sun, 20 Nov 2016 09:50:14 +0100 Subject: [PATCH] Show a warning message in the admin panel when MyISAM is still in use --- mod/admin.php | 12 +++++++++++- util/convert_innodb.sql | 4 ++++ view/global.css | 8 ++++++++ view/templates/admin_summary.tpl | 5 +++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 util/convert_innodb.sql diff --git a/mod/admin.php b/mod/admin.php index 5443285001..ecb394b0ef 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -428,6 +428,14 @@ function admin_page_queue(&$a) { * @return string */ function admin_page_summary(&$a) { + // are there MyISAM tables in the DB? If so, trigger a warning message + $r = q("select `engine` from `information_schema`.`tables` where `engine`='myisam' limit 1"); + $showwarning = false; + $warningtext = ""; + if (dbm::is_result($r)) { + $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 convert_innodb.sql in the /util directory of your Friendica installation.
'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html'); + } $r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`"); $accounts = array( array(t('Normal Account'), 0), @@ -478,7 +486,9 @@ function admin_page_summary(&$a) { '$platform' => FRIENDICA_PLATFORM, '$codename' => FRIENDICA_CODENAME, '$build' => get_config('system','build'), - '$plugins' => array(t('Active plugins'), $a->plugins) + '$plugins' => array(t('Active plugins'), $a->plugins), + '$showwarning' => $showwarning, + '$warningtext' => $warningtext )); } diff --git a/util/convert_innodb.sql b/util/convert_innodb.sql new file mode 100644 index 0000000000..6b065f3b25 --- /dev/null +++ b/util/convert_innodb.sql @@ -0,0 +1,4 @@ + +SELECT CONCAT('ALTER TABLE ',table_schema,'.',table_name,' engine=InnoDB;') +FROM information_schema.tables +WHERE engine = 'MyISAM'; diff --git a/view/global.css b/view/global.css index e3cbf08c3b..85e45db006 100644 --- a/view/global.css +++ b/view/global.css @@ -473,3 +473,11 @@ td.pendingnote { td.pendingnote > p > span { font-weight: bold; } + +/* warning message */ +.warning-message { + padding: 10px; + margin: 5px; + border-left: 5px solid #f00; + font-weight: bold; +} diff --git a/view/templates/admin_summary.tpl b/view/templates/admin_summary.tpl index 08e84b0085..34df0db510 100644 --- a/view/templates/admin_summary.tpl +++ b/view/templates/admin_summary.tpl @@ -1,6 +1,11 @@

{{$title}} - {{$page}}

+{{if $showwarning}} +
+

{{$warningtext}}

+
+{{/if}}
{{$queues.label}}