Merge pull request #1531 from owncloud/cron_no_routes

Fix router warnings when running as CLI
This commit is contained in:
blizzz 2013-02-07 11:22:58 -08:00
commit 07f504812c
2 changed files with 15 additions and 9 deletions

View File

@ -554,14 +554,16 @@ class OC {
self::checkUpgrade();
}
try {
OC::getRouter()->match(OC_Request::getPathInfo());
return;
} catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
//header('HTTP/1.0 404 Not Found');
} catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) {
OC_Response::setStatus(405);
return;
if (!self::$CLI) {
try {
OC::getRouter()->match(OC_Request::getPathInfo());
return;
} catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
//header('HTTP/1.0 404 Not Found');
} catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) {
OC_Response::setStatus(405);
return;
}
}
$app = OC::$REQUESTEDAPP;

View File

@ -23,7 +23,11 @@ class OC_Router {
public function __construct() {
$baseUrl = OC_Helper::linkTo('', 'index.php');
$method = $_SERVER['REQUEST_METHOD'];
if ( !OC::$CLI) {
$method = $_SERVER['REQUEST_METHOD'];
}else{
$method = 'GET';
}
$host = OC_Request::serverHost();
$schema = OC_Request::serverProtocol();
$this->context = new RequestContext($baseUrl, $method, $host, $schema);