Add blackmagic due to cyclic dependency 🙈

This commit is contained in:
Lukas Reschke 2015-02-16 16:26:02 +01:00
parent 9f91d64918
commit 992164446c
2 changed files with 11 additions and 4 deletions

View File

@ -104,7 +104,14 @@ class OC {
* FIXME: The following line is required because of a cyclic dependency * FIXME: The following line is required because of a cyclic dependency
* on IRequest. * on IRequest.
*/ */
$scriptName = $_SERVER['SCRIPT_NAME']; $params = [
'server' => [
'SCRIPT_NAME' => $_SERVER['SCRIPT_NAME'],
'SCRIPT_FILENAME' => $_SERVER['SCRIPT_FILENAME'],
],
];
$fakeRequest = new \OC\AppFramework\Http\Request($params, null, new \OC\AllConfig(new \OC\SystemConfig()));
$scriptName = $fakeRequest->getScriptName();
if (substr($scriptName, -1) == '/') { if (substr($scriptName, -1) == '/') {
$scriptName .= 'index.php'; $scriptName .= 'index.php';
//make sure suburi follows the same rules as scriptName //make sure suburi follows the same rules as scriptName

View File

@ -80,7 +80,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @see http://www.php.net/manual/en/reserved.variables.php * @see http://www.php.net/manual/en/reserved.variables.php
*/ */
public function __construct(array $vars=array(), public function __construct(array $vars=array(),
ISecureRandom $secureRandom, ISecureRandom $secureRandom = null,
IConfig $config, IConfig $config,
$stream='php://input') { $stream='php://input') {
$this->inputStream = $stream; $this->inputStream = $stream;
@ -596,8 +596,8 @@ class Request implements \ArrayAccess, \Countable, IRequest {
$name = $this->server['SCRIPT_NAME']; $name = $this->server['SCRIPT_NAME'];
$overwriteWebRoot = $this->config->getSystemValue('overwritewebroot'); $overwriteWebRoot = $this->config->getSystemValue('overwritewebroot');
if ($overwriteWebRoot !== '' && $this->isOverwriteCondition()) { if ($overwriteWebRoot !== '' && $this->isOverwriteCondition()) {
// FIXME: This code is untestable due to ___DIR__ // FIXME: This code is untestable due to __DIR__, also that hardcoded path is really dangerous
$serverRoot = str_replace('\\', '/', substr(__DIR__, 0, -strlen('lib/private/'))); $serverRoot = str_replace('\\', '/', substr(__DIR__, 0, -strlen('lib/private/appframework/http/')));
$suburi = str_replace('\\', '/', substr(realpath($this->server['SCRIPT_FILENAME']), strlen($serverRoot))); $suburi = str_replace('\\', '/', substr(realpath($this->server['SCRIPT_FILENAME']), strlen($serverRoot)));
$name = '/' . ltrim($overwriteWebRoot . $suburi, '/'); $name = '/' . ltrim($overwriteWebRoot . $suburi, '/');
} }