mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Change return false to throw new
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
62c03beb1d
commit
603a578a1c
2 changed files with 22 additions and 10 deletions
|
|
@ -43,6 +43,7 @@ namespace OC;
|
|||
|
||||
use bantu\IniGetWrapper\IniGetWrapper;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use OC\App\AppStore\Bundles\BundleFetcher;
|
||||
use OC\Authentication\Token\DefaultTokenCleanupJob;
|
||||
use OC\Authentication\Token\DefaultTokenProvider;
|
||||
|
|
@ -434,18 +435,19 @@ class Setup {
|
|||
* Find webroot from config
|
||||
*
|
||||
* @param SystemConfig $config
|
||||
* @return bool|string
|
||||
* @return string
|
||||
* @throws InvalidArgumentException when invalid value for overwrite.cli.url
|
||||
*/
|
||||
public static function findWebRoot(SystemConfig $config) {
|
||||
public static function findWebRoot(SystemConfig $config): string {
|
||||
// For CLI read the value from overwrite.cli.url
|
||||
if (\OC::$CLI) {
|
||||
$webRoot = $config->getValue('overwrite.cli.url', '');
|
||||
if ($webRoot === '') {
|
||||
return false;
|
||||
throw new InvalidArgumentException('overwrite.cli.url is empty');
|
||||
}
|
||||
$webRoot = parse_url($webRoot, PHP_URL_PATH);
|
||||
if ($webRoot === null) {
|
||||
return false;
|
||||
throw new InvalidArgumentException('invalid value for overwrite.cli.url');
|
||||
}
|
||||
$webRoot = rtrim($webRoot, '/');
|
||||
} else {
|
||||
|
|
@ -463,7 +465,12 @@ class Setup {
|
|||
*/
|
||||
public static function updateHtaccess() {
|
||||
$config = \OC::$server->getSystemConfig();
|
||||
$webRoot = self::findWebRoot($config);
|
||||
|
||||
try {
|
||||
$webRoot = self::findWebRoot($config);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$setupHelper = new \OC\Setup(
|
||||
$config,
|
||||
|
|
|
|||
|
|
@ -134,18 +134,23 @@ class SetupTest extends \Test\TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider findWebRootProvider
|
||||
* @param $url
|
||||
* @param $expected
|
||||
*/
|
||||
public function testFindWebRootCli($url, $webRoot) {
|
||||
public function testFindWebRootCli($url, $expected) {
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getValue')
|
||||
->will($this->returnValue($url));
|
||||
\OC::$CLI = true;
|
||||
|
||||
$this->assertEquals(
|
||||
$webRoot,
|
||||
$this->setupClass::findWebRoot($this->config)
|
||||
);
|
||||
try {
|
||||
$webRoot = $this->setupClass::findWebRoot($this->config);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$webRoot = false;
|
||||
}
|
||||
|
||||
$this->assertEquals($webRoot, $expected);
|
||||
}
|
||||
|
||||
public function findWebRootProvider(): array {
|
||||
|
|
|
|||
Loading…
Reference in a new issue