Skip to content
Permalink
Browse files

Improve error handling in setup in case config dir is not present

We do not show these options in UI, but the scripts should handle it
gracefully.

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information...
nijel committed Jun 17, 2016
1 parent cd229d7 commit 331c560fbfa0e7d2dce674b5e88e983c5f2a451d
Showing with 42 additions and 5 deletions.
  1. +28 −5 setup/config.php
  2. +14 −0 setup/frames/index.inc.php
@@ -15,6 +15,24 @@
require './libraries/config/setup.forms.php';
/**
* Loads configuration file path
*
* Do this in a function to avoid messing up with global $cfg
*
* @param string $config_file_path
*
* @return array
*/
function loadConfig($config_file_path)
{
$cfg = array();
if (file_exists($config_file_path)) {
include $config_file_path;
}
return $cfg;
}
$form_display = new FormDisplay($GLOBALS['ConfigFile']);
$form_display->registerForm('_config.php', $forms['_config.php']);
$form_display->save('_config.php');
@@ -44,20 +62,25 @@
//
// Save generated config file on the server
//
file_put_contents(
$result = @file_put_contents(
$config_file_path,
ConfigGenerator::getConfigFile($GLOBALS['ConfigFile'])
);
if ($result === false) {
$state = 'config_not_saved';
} else {
$state = 'config_saved';
}
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon() . '&action_done=config_saved');
header('Location: index.php' . PMA_URL_getCommon() . '&action_done=' . $state);
exit;
} elseif (PMA_ifSetOr($_POST['submit_load'], '')) {
//
// Load config file from the server
//
$cfg = array();
include $config_file_path;
$GLOBALS['ConfigFile']->setConfigData($cfg);
$GLOBALS['ConfigFile']->setConfigData(
loadConfig($config_file_path)
);
header('HTTP/1.1 303 See Other');
header('Location: index.php' . PMA_URL_getCommon());
exit;
@@ -126,6 +126,20 @@
)
);
break;
case 'config_not_saved':
/* Use uniqid to display this message every time configuration is saved */
PMA_messagesSet(
'notice', uniqid('config_not_saved'), __('Configuration not saved!'),
PMA_sanitize(
__(
'Please create web server writable folder [em]config[/em] in '
. 'phpMyAdmin top level directory as described in '
. '[doc@setup_script]documentation[/doc]. Otherwise you will be '
. 'only able to download or display it.'
)
)
);
break;
default:
break;
}

0 comments on commit 331c560

Please sign in to comment.
You can’t perform that action at this time.