Skip to content

Commit 0ccfef0

Browse files
author
Till Brehm
committed
Added silent sql update option in updater.
1 parent f3cc7cd commit 0ccfef0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

install/lib/update.lib.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ function updateDbAndIni() {
164164
$next_db_version = intval($current_db_version + 1);
165165
$sql_patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
166166
$php_patch_filename = realpath(dirname(__FILE__).'/../').'/patches/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.php';
167+
168+
// comma separated list of version numbers were a update has to be done silently
169+
$silent_update_versions = '75';
167170

168171
if(is_file($sql_patch_filename)) {
169172

@@ -186,10 +189,14 @@ function updateDbAndIni() {
186189

187190
//* Load patch file into database
188191
if( !empty($conf["mysql"]["admin_password"]) ) {
189-
system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename);
192+
$cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename;
190193
} else {
191-
system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename);
194+
$cmd = "mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename;
192195
}
196+
197+
if(in_array($next_db_version,explode(',',$silent_update_versions))) $cmd .= ' > /dev/null 2> /dev/null';
198+
system($cmd);
199+
193200
swriteln($inst->lng('Loading SQL patch file').': '.$sql_patch_filename);
194201

195202
//* Exec onAfterSQL function

0 commit comments

Comments
 (0)