summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2013-08-17 21:33:32 +0200
committerMichael Hamann <michael@content-space.de>2013-08-17 21:44:25 +0200
commit66d935e75f9ebbb37332c14e0a9425170c7c9330 (patch)
treed3216a06bc70f8ab0cf25cb2b3997a83fb638d97
parent9148a9640449434d985796b2a456153b72d090f4 (diff)
downloadrpg-66d935e75f9ebbb37332c14e0a9425170c7c9330.tar.gz
rpg-66d935e75f9ebbb37332c14e0a9425170c7c9330.tar.bz2
Fix backlinks for internal links with parameters
This adds the parameter extraction code from the xhtml renderer to the metadata renderer in order to not to include the parameters in the id that is recorded as link target. A test case checks that the link is actually returned as backlink (fails without the fix).
-rw-r--r--_test/tests/inc/fulltext_backlinks.test.php10
-rw-r--r--inc/parser/metadata.php6
2 files changed, 15 insertions, 1 deletions
diff --git a/_test/tests/inc/fulltext_backlinks.test.php b/_test/tests/inc/fulltext_backlinks.test.php
index 058e13498..b20a16ee1 100644
--- a/_test/tests/inc/fulltext_backlinks.test.php
+++ b/_test/tests/inc/fulltext_backlinks.test.php
@@ -8,7 +8,7 @@ if (!defined('DOKU_INC')) die();
*
* @author Michael Hamann <michael@content-space.de>
*/
-class fultext_backlinks_test extends DokuWikiTest {
+class fulltext_backlinks_test extends DokuWikiTest {
public function test_internallink() {
saveWikiText('test:internallinks', '[[internälLink]] [[..:internal link]]', 'Test initialization');
@@ -74,4 +74,12 @@ class fultext_backlinks_test extends DokuWikiTest {
$this->assertEquals(array(), ft_backlinks('test:internallink'));
$this->assertEquals(array(), ft_backlinks('internal_link'));
}
+
+ function test_parameters() {
+ saveWikiText('test:links', '[[wiki:syntax?do=export_raw]] [[:web:scripts:add_vhost.sh?do=export_raw]]', 'Init tests');
+ idx_addPage('test:links');
+
+ $this->assertEquals(array('test:links'), ft_backlinks('wiki:syntax'));
+ $this->assertEquals(array('test:links'), ft_backlinks('web:scripts:add_vhost.sh'));
+ }
}
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index d64fe4d77..7d186e069 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -287,6 +287,12 @@ class Doku_Renderer_metadata extends Doku_Renderer {
if ($name['type'] == 'internalmedia') $this->_recordMediaUsage($name['src']);
}
+ $parts = explode('?', $id, 2);
+ if (count($parts) === 2) {
+ $id = $parts[0];
+ }
+
+
$default = $this->_simpleTitle($id);
// first resolve and clean up the $id