diff --git a/classes/ClassRepository.php b/classes/ClassRepository.php index 21ecf76..228d515 100644 --- a/classes/ClassRepository.php +++ b/classes/ClassRepository.php @@ -75,8 +75,8 @@ class ClassRepository { public function getCustomFilesCachePath(Node $object) { $path = $this->options['cache_dir'].DIRECTORY_SEPARATOR .strtoupper(md5($object->getId())).DIRECTORY_SEPARATOR - .($object->getProperty(ObjectRetriever::REVISION_PROPERTY) - ? $object->getProperty(ObjectRetriever::REVISION_PROPERTY)->getValue() + .($object->getProperty(Constants::PROPERTY_REVISION) + ? $object->getProperty(Constants::PROPERTY_REVISION)->getValue() : 'LocalConfig'); if (!is_dir($path)) mkdir($path, 0777, true); return $path; @@ -87,8 +87,8 @@ class ClassRepository { $vars = $this->getURIVars($uri); // Fetch class description - $revision = $object->getProperty(ObjectRetriever::REVISION_PROPERTY) - ? $object->getProperty(ObjectRetriever::REVISION_PROPERTY)->getValue() + $revision = $object->getProperty(Constants::PROPERTY_REVISION) + ? $object->getProperty(Constants::PROPERTY_REVISION)->getValue() : 'LocalConfig'; // Clear cache if cached version exists @@ -243,8 +243,8 @@ class ClassRepository { $objectRetriever = $this->container->get(ObjectRetriever::class); // Get revision - $revision = $object->getProperty(ObjectRetriever::REVISION_PROPERTY) - ? $object->getProperty(ObjectRetriever::REVISION_PROPERTY)->getValue() + $revision = $object->getProperty(Constants::PROPERTY_REVISION) + ? $object->getProperty(Constants::PROPERTY_REVISION)->getValue() : 'LocalConfig'; // Build filename where cached version should exist diff --git a/classes/ErrorHandler.php b/classes/ErrorHandler.php index 1659a1f..ba7b0c6 100644 --- a/classes/ErrorHandler.php +++ b/classes/ErrorHandler.php @@ -9,7 +9,7 @@ namespace CloudObjects\PhpMAE; use Slim\Psr7\Response; use Slim\ResponseEmitter; use ML\JsonLD\Node; -use CloudObjects\SDK\ObjectRetriever; +use CloudObjects\SDK\ObjectRetriever, CloudObjects\SDK\Constants; class ErrorHandler { @@ -22,7 +22,7 @@ class ErrorHandler { $message = substr($error['message'], 0, strpos($error['message'], ' in /')); $response = (new Response(500))->withHeader('Content-Type', 'text/plain'); $response->getBody()->write("Error in implementation of <".$object->getId()."> at revision " - . $object->getProperty(ObjectRetriever::REVISION_PROPERTY)->getValue() + . $object->getProperty(Constants::PROPERTY_REVISION)->getValue() . ":\n".$message); return $response; }); diff --git a/classes/Sandbox/CustomizedValidatorVisitor.php b/classes/Sandbox/CustomizedValidatorVisitor.php index 78bf9e1..33c61c9 100644 --- a/classes/Sandbox/CustomizedValidatorVisitor.php +++ b/classes/Sandbox/CustomizedValidatorVisitor.php @@ -49,7 +49,7 @@ class CustomizedValidatorVisitor extends NodeVisitorAbstract { */ public function leaveNode(Node $node){ if($node instanceof Node\Arg && $this->sandbox->sandbox_strings){ - return new Node\Expr\FuncCall(new Node\Name\FullyQualified(($node->value instanceof Node\Expr\Variable) ? 'PHPSandbox\\wrapByRef' : 'PHPSandbox\\wrap'), [$node, new Node\Expr\StaticCall(new Node\Name\FullyQualified("PHPSandbox\\PHPSandbox"), 'getSandbox', [new Node\Arg(new Node\Scalar\String_($this->sandbox->name))])], $node->getAttributes()); + return new Node\Expr\FuncCall(new Node\Name\FullyQualified(($node->value instanceof Node\Expr\Variable) ? 'PHPSandbox\\wrapByRef' : 'PHPSandbox\\wrap'), [$node, new Node\Expr\StaticCall(new Node\Name\FullyQualified("CloudObjects\\PhpMAE\\Sandbox\\CustomizedSandbox"), 'getGlobalSandbox')], $node->getAttributes()); } else if($node instanceof Node\Stmt\InlineHTML){ if(!$this->sandbox->allow_escaping){ $this->sandbox->validationError("Sandboxed code attempted to escape to HTML!", Error::ESCAPE_ERROR, $node);