瀏覽代碼

Throw RuntimeException on invalid content dirs

Daniel Rudolf 9 年之前
父節點
當前提交
d252df4b98
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 1 0
      CHANGELOG.md
  2. 7 1
      lib/Pico.php

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@ Released: -
         want to parse the contents of a page, use the `content` filter instead
 * [Changed] Improve documentation
 * [Changed] Improve table styling in default theme
+* [Changed] Throw a RuntimeException when the `content` dir isn't accessible
 * [Changed] Reuse `ParsedownExtra` object; new `onParsedownRegistration` event
 * [Fixed] `PicoDeprecated`: Sanitize `content_dir` and `base_url` options when
           reading `config.php` in Picos root dir

+ 7 - 1
lib/Pico.php

@@ -266,7 +266,8 @@ class Pico
      * meta headers, processes Markdown, does Twig processing and returns
      * the rendered contents.
      *
-     * @return string rendered Pico contents
+     * @return string           rendered Pico contents
+     * @throws RuntimeException thrown when a not recoverable error occurs
      */
     public function run()
     {
@@ -281,6 +282,11 @@ class Pico
         $this->loadConfig();
         $this->triggerEvent('onConfigLoaded', array(&$this->config));
 
+        // check content dir
+        if (!is_dir($this->getConfig('content_dir'))) {
+            throw new RuntimeException('Invalid content directory "' . $this->getConfig('content_dir') . '"');
+        }
+
         // evaluate request url
         $this->evaluateRequestUrl();
         $this->triggerEvent('onRequestUrl', array(&$this->requestUrl));