浏览代码

merged branch makasim/yaml-throw-not-readable (PR #3105)

Commits
-------

7961014 [Yaml][Parser] changes according review
efce640 [Yaml][Parser] throw an exception if not readable

Discussion
----------

[Yaml][Parser] throw an exception if service file not readable.

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3077
Todo: -

---------------------------------------------------------------------------

by makasim at 2012-01-13T15:49:49Z

 @fabpot done
Fabien Potencier 13 年之前
父节点
当前提交
119a24f016
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/Symfony/Component/Yaml/Yaml.php

+ 5 - 1
src/Symfony/Component/Yaml/Yaml.php

@@ -47,7 +47,11 @@ class Yaml
         $file = '';
 
         // if input is a file, process it
-        if (strpos($input, "\n") === false && is_file($input) && is_readable($input)) {
+        if (strpos($input, "\n") === false && is_file($input)) {
+            if (false === is_readable($input)) {
+                throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
+            }
+
             $file = $input;
 
             ob_start();