What steps will reproduce the problem?
$yaml = <<<YAML
people:
- colin:
age: 29
<<: *COLIN
stored:
- &COLIN
name: Colin
languages: &LANGS
- English
- Japanese
YAML;
$data = Spyc::YAMLLoadString($yaml);
What is the expected output? What do you see instead?
exptected $data to have $data['people'][0]['colin']['name'] => "Colin"
instead: get a "Undefined variable "$value" on line 728
What version of the product are you using? On what operating system?
0.5.0, php 5.3
Please provide any additional information below.
--- spyc.php
+++ Spyc.class.php
@@ -725,10 +725,11 @@
private function referenceContentsByAlias ($alias) {
do {
- if (!isset($this->SavedGroups[$alias])) { echo "Bad group name:
$alias."; break; }
+ if (!isset($this->SavedGroups[$alias])) { echo "Bad group name:
$alias."; return NULL; }
$groupPath = $this->SavedGroups[$alias];
$value = $this->result;
foreach ($groupPath as $k) {
$value = $value[$k];
}
} while (false);
Once that is taken care of (by moving the stored section to the top)
What steps will reproduce the problem?
$yaml = <<<YAML
stored:
- &COLIN
name: Colin
languages: &LANGS
- English
- Japanese
people:
- colin:
age: 29
<<: *COLIN
YAML;
$data = Spyc::YAMLLoadString($yaml);
What is the expected output? What do you see instead?
exptected $data to have $data['people'][0]['colin']['name'] => "Colin"
instead: get a "Undefined index: : PHP Notice" line 733
Please provide any additional information below.
--- spyc.php
+++ Spyc.class.php
@@ -725,10 +725,11 @@
private function referenceContentsByAlias ($alias) {
do {
if (!isset($this->SavedGroups[$alias])) { echo "Bad group name: $alias."; return NULL; }
$groupPath = $this->SavedGroups[$alias];
$value = $this->result;
foreach ($groupPath as $k) {
+ if ( $k === NULL ) break;
$value = $value[$k];
}
} while (false);
ALL TOGETHER:
--- spyc.php
+++ Spyc.class.php
@@ -725,10 +725,11 @@
private function referenceContentsByAlias ($alias) {
do {
- if (!isset($this->SavedGroups[$alias])) { echo "Bad group name:
$alias."; break; }
+ if (!isset($this->SavedGroups[$alias])) { echo "Bad group name:
$alias."; return NULL; }
$groupPath = $this->SavedGroups[$alias];
$value = $this->result;
foreach ($groupPath as $k) {
+ if ( $k === NULL ) break;
$value = $value[$k];
}
} while (false);
Original issue reported on code.google.com by coli...@gmail.com on 7 Jun 2011 at 4:33
Original issue reported on code.google.com by
coli...@gmail.com
on 7 Jun 2011 at 4:33Attachments: