From afa1a6d2b3cc1b07c7e99b370ad88f9473c50add Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 Feb 2013 17:53:38 +0100 Subject: [PATCH 1/3] Don't try to use routes when called from cli --- lib/base.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/base.php b/lib/base.php index b432f282aaf..5bfdb0b7c0a 100644 --- a/lib/base.php +++ b/lib/base.php @@ -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; From f3f55654ce0202bcb00e692ea318b2f165354746 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 Feb 2013 18:28:56 +0100 Subject: [PATCH 2/3] Use dummy request method in CLI --- lib/router.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/router.php b/lib/router.php index 746b68c2c0c..fbf56a1bb42 100644 --- a/lib/router.php +++ b/lib/router.php @@ -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); From 73ed62976de60ed1ab6728944d638e5b9b4b4e10 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 7 Feb 2013 18:30:01 +0100 Subject: [PATCH 3/3] Fix previous commit --- lib/router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/router.php b/lib/router.php index fbf56a1bb42..dbaca9e0d5d 100644 --- a/lib/router.php +++ b/lib/router.php @@ -23,7 +23,7 @@ class OC_Router { public function __construct() { $baseUrl = OC_Helper::linkTo('', 'index.php'); - if (OC::$CLI) { + if ( !OC::$CLI) { $method = $_SERVER['REQUEST_METHOD']; }else{ $method = 'GET';