diff --git a/phpdotnet/phd/Index.php b/phpdotnet/phd/Index.php index e0d119d3..24be8ab6 100644 --- a/phpdotnet/phd/Index.php +++ b/phpdotnet/phd/Index.php @@ -89,7 +89,7 @@ class Index extends Format private $currentid; private $chunks = array(); private $isChunk = array(); - private $nfo = array(); + protected $nfo = array(); private $isSectionChunk = array(); private $log = ''; private $previousId = ""; @@ -383,6 +383,9 @@ public function format_chunk($open, $name, $attrs, $props) { $this->chunks[] = $id; $this->currentchunk = $id; $this->storeInfo($name, $id, $id); + } else { + $this->storeInfo($name, $id, $this->currentchunk, false); + $this->appendID(); } return false; } diff --git a/phpdotnet/phd/TestIndex.php b/phpdotnet/phd/TestIndex.php new file mode 100644 index 00000000..d5586d19 --- /dev/null +++ b/phpdotnet/phd/TestIndex.php @@ -0,0 +1,8 @@ +nfo; + } +} diff --git a/tests/index/bug_GH-98.phpt b/tests/index/bug_GH-98.phpt new file mode 100644 index 00000000..dcc9e434 --- /dev/null +++ b/tests/index/bug_GH-98.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug GH-98 - Non-chunked section is not linked +--FILE-- + true, + "xml_file" => $xml_file, +]); + +$index = new TestIndex; +$render = new TestRender(new Reader, new Config, null, $index); + +$render->run(); + +$indexes = array_keys($index->getNfo()); + +echo "Indexes stored:\n"; + +var_dump(in_array("non-chunked.element.id", $indexes)); +var_dump(in_array("another.non-chunked.element.id", $indexes)); +var_dump(in_array("chunked.element.id", $indexes)); +var_dump(in_array("another.chunked.element.id", $indexes)); +var_dump(in_array("bug-GH-98", $indexes)); +?> +--EXPECT-- +Indexes stored: +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/tests/index/data/bug_GH-98.xml b/tests/index/data/bug_GH-98.xml new file mode 100644 index 00000000..dd1dba21 --- /dev/null +++ b/tests/index/data/bug_GH-98.xml @@ -0,0 +1,28 @@ + + + + + + Content to ensure this elements is indexed + + + +
+ + Content to ensure this elements is indexed too + +
+ + + + Content to ensure this elements is indexed as well + + + +
+ + Content to ensure this elements is also indexed + +
+ +