From 25acf80f34c6796e58c29ff57ccc923c812f6dfe Mon Sep 17 00:00:00 2001 From: Martijn van Nieuwenhoven Date: Sun, 17 Apr 2016 01:36:54 +0200 Subject: [PATCH] Check for Controller::curr(); It is nog a fact that there is always a Controller on the command line --- code/Extensions/Annotatable.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/code/Extensions/Annotatable.php b/code/Extensions/Annotatable.php index 06e9303..4d52d0c 100644 --- a/code/Extensions/Annotatable.php +++ b/code/Extensions/Annotatable.php @@ -52,9 +52,13 @@ public function requireDefaultRecords() // Setup the protected values. $this->setUp(); - /** @var SS_HTTPRequest|NullHTTPRequest $request */ - $request = Controller::curr()->getRequest(); - $skipAnnotation = $request->getVar('skipannotation'); + $skipAnnotation = null; + + // This is not the case on the command line + if(Controller::has_curr()) { + $skipAnnotation = Controller::curr()->getRequest()->getVar('skipannotation'); + } + if ($skipAnnotation !== null || !$this->permissionChecker->environmentIsAllowed()) { return false; }