diff --git a/phpdotnet/phd/Index.php b/phpdotnet/phd/Index.php index 0deefdf2..3a82ea9b 100644 --- a/phpdotnet/phd/Index.php +++ b/phpdotnet/phd/Index.php @@ -63,9 +63,9 @@ class Index extends Format 'titleabbrev' => 'format_short_desc', 'example' => 'format_example', 'refsect1' => 'format_refsect1', - 'tbody' => array( + 'row' => array( /* DEFAULT */ null, - 'row' => 'format_row', + 'tbody' => 'format_row', ), 'entry' => array( /* DEFAULT */ null, @@ -98,7 +98,7 @@ class Index extends Format private $inChangelog = false; private $currentChangelog = array(); private string $currentChangeLogString = ""; - private $changelog = array(); + protected $changelog = array(); private $currentMembership = null; private $commit = array(); private $POST_REPLACEMENT_INDEXES = array(); @@ -419,17 +419,19 @@ public function format_entry($open, $name, $attrs, $props) { $this->currentChangelog[] = htmlentities(trim($this->currentChangeLogString), ENT_COMPAT, "UTF-8"); } } + public function format_row($open, $name, $attrs, $props) { - if ($open) { - if ($this->inChangelog) { - end($this->ids); prev($this->ids); - $this->currentChangelog = array($this->currentMembership, current($this->ids)); - } - return; - } if ($this->inChangelog) { - $this->changelog[$this->currentid][] = $this->currentChangelog; + if ($open) { + $parent_id = $this->ids[count($this->ids) - 2]; + $this->currentChangelog = array($this->currentMembership, $parent_id); + } else { + $this->changelog[$this->currentid][] = $this->currentChangelog; + } } + + /* Fall back to regular handling so contents get processed */ + return $this->UNDEF($open, $name, $attrs, $props); } public function processFilename() { diff --git a/phpdotnet/phd/IndexRepository.php b/phpdotnet/phd/IndexRepository.php index b0729f6b..cd947699 100644 --- a/phpdotnet/phd/IndexRepository.php +++ b/phpdotnet/phd/IndexRepository.php @@ -103,14 +103,16 @@ private function saveChangelogs(array $changelog): void { $log = ""; foreach($changelog as $id => $arr) { foreach($arr as $entry) { - $log .= sprintf( - "INSERT INTO changelogs (membership, docbook_id, parent_id, version, description) VALUES('%s', '%s', '%s', '%s', '%s');\n", - $this->db->escapeString($entry[0] ?? ''), - $this->db->escapeString($id), - $this->db->escapeString($entry[1]), - $this->db->escapeString($entry[2]), - $this->db->escapeString($entry[3]) - ); + foreach(preg_split('/,\s+/', $entry[2]) as $version) { + $log .= sprintf( + "INSERT INTO changelogs (membership, docbook_id, parent_id, version, description) VALUES('%s', '%s', '%s', '%s', '%s');\n", + $this->db->escapeString($entry[0] ?? ''), + $this->db->escapeString($id), + $this->db->escapeString($entry[1]), + $this->db->escapeString($version), + $this->db->escapeString($entry[3]) + ); + } } } $this->db->exec('BEGIN TRANSACTION; ' . $log. ' COMMIT'); diff --git a/phpdotnet/phd/PI/PHPDOCHandler.php b/phpdotnet/phd/PI/PHPDOCHandler.php index b7d06312..99191520 100644 --- a/phpdotnet/phd/PI/PHPDOCHandler.php +++ b/phpdotnet/phd/PI/PHPDOCHandler.php @@ -118,7 +118,7 @@ public function parse($target, $data) { // usort() callback function used in generate-changelog-for, higest (newest) version first // 1.2.11 comes before 1.2.2, then function name (actually its id.. but close enough :)) protected static function _sortByVersion($a, $b) { - $retval = -1 * strnatcasecmp($a["version"], $b["version"]); + $retval = -1 * version_compare($a["version"], $b["version"]); if ($retval === 0) { return strnatcasecmp($a["docbook_id"], $b["docbook_id"]); @@ -138,7 +138,7 @@ protected function generateChangelogMarkup($changelogs) { $version = ""; foreach($changelogs as $entry) { - if (!$this->_changelogSince || strnatcasecmp($entry["version"], $this->_changelogSince) >= 0) { + if (!$this->_changelogSince || version_compare($entry["version"], $this->_changelogSince) >= 0) { $link = $this->format->createLink($entry["docbook_id"], $desc); if ($version == $entry["version"]) { $v = " "; diff --git a/phpdotnet/phd/TestIndex.php b/phpdotnet/phd/TestIndex.php index d5586d19..076ddbaa 100644 --- a/phpdotnet/phd/TestIndex.php +++ b/phpdotnet/phd/TestIndex.php @@ -5,4 +5,8 @@ class TestIndex extends Index { public function getNfo(): array { return $this->nfo; } + + public function getChangelog(): array { + return $this->changelog; + } } diff --git a/tests/bug_GH-87.phpt b/tests/bug_GH-87.phpt new file mode 100644 index 00000000..b5f6e1eb --- /dev/null +++ b/tests/bug_GH-87.phpt @@ -0,0 +1,65 @@ +--TEST-- +GH-87 Broken links for constants in table rows +--FILE-- +setForce_index(true); +$config->setXml_file($xml_file); + +$indexRepository = new IndexRepository(new \SQLite3(":memory:")); +$indexRepository->init(); +$config->set_indexcache($indexRepository); + +$index = new TestIndex($indexRepository, $config); + +$render = new TestRender(new Reader, $config, null, $index); + +$render->run(); + +$render = new TestRender(new Reader, $config); + +$format = new TestGenericChunkedXHTML($config); + +$render->attach($format); + +$render->run(); + +?> +--EXPECT-- +Filename: constants.html +Content: +
Constant within a table (GH-87)
++
Header | +
---|
CONSTANT_IS_DEFINED |
+