From 0be89228e7c6e0c21131730a12ad4ac5b45b82f6 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Fri, 22 Oct 2010 01:08:44 +0000 Subject: [PATCH] BUGFIX: catch any errors thrown by incorrect paths nicer --- code/DocumentationPage.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/code/DocumentationPage.php b/code/DocumentationPage.php index 08a3f12..cf4e705 100644 --- a/code/DocumentationPage.php +++ b/code/DocumentationPage.php @@ -58,8 +58,8 @@ class DocumentationPage extends ViewableData { * @return String */ function getPath() { - $path = realpath(rtrim($this->entity->getPath($this->version, $this->lang), '/') . '/' . $this->getRelativePath()); - + $path = realpath(rtrim($this->entity->getPath($this->version, $this->lang), '/') . '/' . trim($this->getRelativePath(), '/')); + if(!file_exists($path)) { throw new InvalidArgumentException(sprintf( 'Path could not be found. Module path: %s, file path: %s', @@ -91,7 +91,14 @@ class DocumentationPage extends ViewableData { * @return String */ function getMarkdown() { - return file_get_contents($this->getPath()); + try { + $path = $this->getPath(); + + return file_get_contents($path); + } + catch(InvalidArgumentException $e) {} + + return null; } /**