From bf1e7c2822116cde5e6d87aebafab2d573a9f326 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 29 Apr 2016 12:53:02 -0500 Subject: [PATCH] Three new validate.php checks * Check that $config['install_dir'] is set correctly by checking that config.php exists there. * Check if the local branch is not master, warn that it will prevent updates * Check for modified files and list them (this will not include staged files) --- includes/common.php | 8 +++++++- validate.php | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/includes/common.php b/includes/common.php index a1a7ab38d5..5e55b76122 100644 --- a/includes/common.php +++ b/includes/common.php @@ -1041,7 +1041,13 @@ function version_info($remote=true) { curl_setopt($api, CURLOPT_RETURNTRANSFER, 1); $output['github'] = json_decode(curl_exec($api),true); } - $output['local_sha'] = chop(`git rev-parse HEAD`); + $output['local_sha'] = rtrim(`git rev-parse HEAD`); + $output['local_branch'] = rtrim(`git rev-parse --abbrev-ref HEAD`); + + exec('git diff --name-only --exit-code', $cmdoutput, $code); + $output['git_modified'] = ($code !== 0); + $output['git_modified_files'] = $cmdoutput; + $output['db_schema'] = dbFetchCell('SELECT version FROM dbSchema'); $output['php_ver'] = phpversion(); $output['mysql_ver'] = dbFetchCell('SELECT version()'); diff --git a/validate.php b/validate.php index afc28a8660..1decda751e 100755 --- a/validate.php +++ b/validate.php @@ -59,6 +59,14 @@ if ($username !== 'root') { // load config.php now require_once 'includes/defaults.inc.php'; require_once 'config.php'; + +// make sure install_dir is set correctly, or the next includes will fail +if(!file_exists($config['install_dir'].'/config.php')) { + print_fail('$config[\'install_dir\'] is not set correctly. It should probably be set to: ' . getcwd()); + exit; +} + +// continue loading includes require_once 'includes/definitions.inc.php'; require_once 'includes/functions.php'; require_once 'includes/common.php'; @@ -73,6 +81,14 @@ if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sh else { echo "Commit SHA: $cur_sha\n"; } +if($versions['local_branch'] != 'master') { + print_warn("Your local git branch is not master, this will prevent automatic updates."); +} +if($versions['git_modified'] === true) { + print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:"); + echo(implode("\n", $versions['git_modified_files']) . "\n"); +} + echo "DB Schema: ".$versions['db_schema']."\n"; echo "PHP: ".$versions['php_ver']."\n"; echo "MySQL: ".$versions['mysql_ver']."\n";