Tweak storage selection in admin page
Don't call `StorageManager::setBackend()` on save when legacy is selected, dont't show legacy option in selectbox after backend is changed from legacy
This commit is contained in:
parent
72bee45079
commit
47aa9daf5a
|
@ -1154,40 +1154,41 @@ function admin_page_site_post(App $a)
|
||||||
* @var $storagebackend \Friendica\Model\Storage\IStorage
|
* @var $storagebackend \Friendica\Model\Storage\IStorage
|
||||||
*/
|
*/
|
||||||
$storagebackend = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', '')));
|
$storagebackend = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', '')));
|
||||||
if (!StorageManager::setBackend($storagebackend)) {
|
|
||||||
info(L10n::t('Invalid storage backend setting value.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// save storage backend form
|
// save storage backend form
|
||||||
if (!is_null($storagebackend) && $storagebackend != "") {
|
if (!is_null($storagebackend) && $storagebackend != "") {
|
||||||
$storage_opts = $storagebackend::getOptions();
|
if (!StorageManager::setBackend($storagebackend)) {
|
||||||
$storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storagebackend);
|
info(L10n::t('Invalid storage backend setting value.'));
|
||||||
$storage_opts_data = [];
|
} else {
|
||||||
foreach($storage_opts as $name => $info) {
|
$storage_opts = $storagebackend::getOptions();
|
||||||
$fieldname = $storage_form_prefix . '_' . $name;
|
$storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storagebackend);
|
||||||
switch ($info[0]) { // type
|
$storage_opts_data = [];
|
||||||
|
foreach($storage_opts as $name => $info) {
|
||||||
|
$fieldname = $storage_form_prefix . '_' . $name;
|
||||||
|
switch ($info[0]) { // type
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
case 'yesno':
|
case 'yesno':
|
||||||
$value = !empty($_POST[$fieldname]);
|
$value = !empty($_POST[$fieldname]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$value = defaults($_POST, $fieldname, '');
|
$value = defaults($_POST, $fieldname, '');
|
||||||
|
}
|
||||||
|
$storage_opts_data[$name] = $value;
|
||||||
}
|
}
|
||||||
$storage_opts_data[$name] = $value;
|
unset($name);
|
||||||
}
|
unset($info);
|
||||||
unset($name);
|
|
||||||
unset($info);
|
$storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
|
||||||
|
if (count($storage_form_errors)) {
|
||||||
$storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
|
foreach($storage_form_errors as $name => $err) {
|
||||||
if (count($storage_form_errors)) {
|
notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
|
||||||
foreach($storage_form_errors as $name => $err) {
|
}
|
||||||
notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
|
$a->internalRedirect('admin/site' . $active_panel);
|
||||||
}
|
}
|
||||||
$a->internalRedirect('admin/site' . $active_panel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Has the directory url changed? If yes, then resubmit the existing profiles there
|
// Has the directory url changed? If yes, then resubmit the existing profiles there
|
||||||
if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
|
if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
|
||||||
|
@ -1499,9 +1500,14 @@ function admin_page_site(App $a)
|
||||||
*/
|
*/
|
||||||
$storage_current_backend = StorageManager::getBackend();
|
$storage_current_backend = StorageManager::getBackend();
|
||||||
|
|
||||||
$storage_backends_choices = [
|
$storage_backends_choices = [];
|
||||||
'' => L10n::t('Database (legacy)')
|
|
||||||
];
|
// show legacy option only if it is the current backend:
|
||||||
|
// once changed can't be selected anymore
|
||||||
|
if ($storage_current_backend == '') {
|
||||||
|
$storage_backends_choices[''] = L10n::t('Database (legacy)');
|
||||||
|
};
|
||||||
|
|
||||||
foreach($storage_backends as $name=>$class) {
|
foreach($storage_backends as $name=>$class) {
|
||||||
$storage_backends_choices[$class] = $name;
|
$storage_backends_choices[$class] = $name;
|
||||||
}
|
}
|
||||||
|
@ -1509,7 +1515,7 @@ function admin_page_site(App $a)
|
||||||
|
|
||||||
// build storage config form,
|
// build storage config form,
|
||||||
$storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storage_current_backend);
|
$storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storage_current_backend);
|
||||||
|
|
||||||
$storage_form = [];
|
$storage_form = [];
|
||||||
if (!is_null($storage_current_backend) && $storage_current_backend != "") {
|
if (!is_null($storage_current_backend) && $storage_current_backend != "") {
|
||||||
foreach ($storage_current_backend::getOptions() as $name => $info) {
|
foreach ($storage_current_backend::getOptions() as $name => $info) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user