1
0
Fork 0

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:
fabrixxm 2019-04-10 08:40:50 +02:00
parent 72bee45079
commit 47aa9daf5a

View file

@ -1154,12 +1154,12 @@ function admin_page_site_post(App $a)
* @var $storagebackend \Friendica\Model\Storage\IStorage
*/
$storagebackend = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', '')));
if (!StorageManager::setBackend($storagebackend)) {
info(L10n::t('Invalid storage backend setting value.'));
}
// save storage backend form
if (!is_null($storagebackend) && $storagebackend != "") {
if (!StorageManager::setBackend($storagebackend)) {
info(L10n::t('Invalid storage backend setting value.'));
} else {
$storage_opts = $storagebackend::getOptions();
$storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storagebackend);
$storage_opts_data = [];
@ -1186,6 +1186,7 @@ function admin_page_site_post(App $a)
$a->internalRedirect('admin/site' . $active_panel);
}
}
}
@ -1499,9 +1500,14 @@ function admin_page_site(App $a)
*/
$storage_current_backend = StorageManager::getBackend();
$storage_backends_choices = [
'' => L10n::t('Database (legacy)')
];
$storage_backends_choices = [];
// 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) {
$storage_backends_choices[$class] = $name;
}