Merge pull request #294 from picocms/enhancement/YamlParseError2
Catch YAML parse errors (2)
This commit is contained in:
commit
9e4af2cba4
11
lib/Pico.php
11
lib/Pico.php
@ -753,6 +753,8 @@ class Pico
|
|||||||
* @param string $rawContent the raw file contents
|
* @param string $rawContent the raw file contents
|
||||||
* @param string[] $headers known meta headers
|
* @param string[] $headers known meta headers
|
||||||
* @return array parsed meta data
|
* @return array parsed meta data
|
||||||
|
* @throws \Symfony\Component\Yaml\Exception\ParseException thrown when the
|
||||||
|
* meta data is invalid
|
||||||
*/
|
*/
|
||||||
public function parseFileMeta($rawContent, array $headers)
|
public function parseFileMeta($rawContent, array $headers)
|
||||||
{
|
{
|
||||||
@ -949,7 +951,14 @@ class Pico
|
|||||||
$url = $this->getPageUrl($id);
|
$url = $this->getPageUrl($id);
|
||||||
if ($file != $this->requestFile) {
|
if ($file != $this->requestFile) {
|
||||||
$rawContent = file_get_contents($file);
|
$rawContent = file_get_contents($file);
|
||||||
$meta = $this->parseFileMeta($rawContent, $this->getMetaHeaders());
|
|
||||||
|
$headers = $this->getMetaHeaders();
|
||||||
|
try {
|
||||||
|
$meta = $this->parseFileMeta($rawContent, $headers);
|
||||||
|
} catch (\Symfony\Component\Yaml\Exception\ParseException $e) {
|
||||||
|
$meta = $this->parseFileMeta('', $headers);
|
||||||
|
$meta['YAML_ParseError'] = $e->getMessage();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$rawContent = &$this->rawContent;
|
$rawContent = &$this->rawContent;
|
||||||
$meta = &$this->meta;
|
$meta = &$this->meta;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user