fix deletion for configIDs < s10
Also move ensureConfigIDExists checks into try, it might throw DB related exceptions Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
9ca4065ef5
commit
91ed70f094
|
@ -145,12 +145,6 @@ class ConfigAPIController extends OCSController {
|
||||||
* @throws OCSException
|
* @throws OCSException
|
||||||
*/
|
*/
|
||||||
public function delete($configID) {
|
public function delete($configID) {
|
||||||
$initial = substr($configID, 0, 1);
|
|
||||||
$number = substr($configID, 1);
|
|
||||||
if($initial !== 's' || $number !== strval(intval($number))) {
|
|
||||||
throw new OCSBadRequestException('Not a valid config ID');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->ensureConfigIDExists($configID);
|
$this->ensureConfigIDExists($configID);
|
||||||
if(!$this->ldapHelper->deleteServerConfiguration($configID)) {
|
if(!$this->ldapHelper->deleteServerConfiguration($configID)) {
|
||||||
|
@ -190,13 +184,13 @@ class ConfigAPIController extends OCSController {
|
||||||
* @throws OCSException
|
* @throws OCSException
|
||||||
*/
|
*/
|
||||||
public function modify($configID, $configData) {
|
public function modify($configID, $configData) {
|
||||||
$this->ensureConfigIDExists($configID);
|
|
||||||
|
|
||||||
if(!is_array($configData)) {
|
|
||||||
throw new OCSBadRequestException('configData is not properly set');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$this->ensureConfigIDExists($configID);
|
||||||
|
|
||||||
|
if(!is_array($configData)) {
|
||||||
|
throw new OCSBadRequestException('configData is not properly set');
|
||||||
|
}
|
||||||
|
|
||||||
$configuration = new Configuration($configID);
|
$configuration = new Configuration($configID);
|
||||||
$configKeys = $configuration->getConfigTranslationArray();
|
$configKeys = $configuration->getConfigTranslationArray();
|
||||||
|
|
||||||
|
@ -207,6 +201,8 @@ class ConfigAPIController extends OCSController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$configuration->saveConfiguration();
|
$configuration->saveConfiguration();
|
||||||
|
} catch(OCSException $e) {
|
||||||
|
throw $e;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
throw new OCSException('An issue occurred when modifying the config.');
|
throw new OCSException('An issue occurred when modifying the config.');
|
||||||
|
@ -287,9 +283,9 @@ class ConfigAPIController extends OCSController {
|
||||||
* @throws OCSException
|
* @throws OCSException
|
||||||
*/
|
*/
|
||||||
public function show($configID, $showPassword = false) {
|
public function show($configID, $showPassword = false) {
|
||||||
$this->ensureConfigIDExists($configID);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$this->ensureConfigIDExists($configID);
|
||||||
|
|
||||||
$config = new Configuration($configID);
|
$config = new Configuration($configID);
|
||||||
$data = $config->getConfiguration();
|
$data = $config->getConfiguration();
|
||||||
if(!boolval(intval($showPassword))) {
|
if(!boolval(intval($showPassword))) {
|
||||||
|
@ -301,6 +297,8 @@ class ConfigAPIController extends OCSController {
|
||||||
$data[$key] = $value;
|
$data[$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(OCSException $e) {
|
||||||
|
throw $e;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
throw new OCSException('An issue occurred when modifying the config.');
|
throw new OCSException('An issue occurred when modifying the config.');
|
||||||
|
@ -317,7 +315,7 @@ class ConfigAPIController extends OCSController {
|
||||||
*/
|
*/
|
||||||
private function ensureConfigIDExists($configID) {
|
private function ensureConfigIDExists($configID) {
|
||||||
$prefixes = $this->ldapHelper->getServerConfigurationPrefixes();
|
$prefixes = $this->ldapHelper->getServerConfigurationPrefixes();
|
||||||
if(!in_array($configID, $prefixes)) {
|
if(!in_array($configID, $prefixes, true)) {
|
||||||
throw new OCSNotFoundException('Config ID not found');
|
throw new OCSNotFoundException('Config ID not found');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue