Bug: $TranslationToken passed into subroutines
I ran into a problem with a plugin leveraging
TWiki::Plugins::renderWikiWordHandler in that on certain occasions the routine is passed text which is still surrounded by
$TranslationToken and thus fails. Per
Peter's explanation in
WhatPurposeDoesTranslationTokenServe,
$TranslationToken should not be passed into subroutines.
What I observe is the following:
-
getRenderedVersion when faced with the pattern Web.TopicName wraps $TranslationToken around TopicName and passes it as $theLinkText to internalCrosswebLink
- if this is an internal link,
internalCrosswebLink calls internalLink and passes the text on
- in
internalLink the test for TWiki::isWikiName fails, as the text still is surrounded by $TranslationToken
This is also true for patterns
Web.TopicName#anchor, and
TopicName#anchor.
Test case
Install
SpacedWikiWorkPlugin. Then try
%TOPICLIST{" * $web.$name"}%
You will see that none of the
WikiWords in the list are expanded.
Environment
--
ThomasWeigert - 10 Feb 2005
Impact and Available Solutions
Follow up
I have attached a patch which in an awkward way may solve the problem described above. Rather than inserting
$TranslationToken immediately, I pass a flag into the subroutine to insert
$TranslationToken around the text to be linked before it is actually used. In this case, the text is clean for most part of the subroutine but
$TranslationToken is inserted and after the subroutine exists the string has been altered as in the original version.
While this patch solved my problem, it has an unpleasant appearance in that now the insertion of the
$TranslationToken and its removal are separated through subroutine calls and it is less visible weather or not the
$TranslationToken is inserted only temporarily.
By the way, I think a comment should be made in the code where
$TranslationToken is defined explaining what it does and that it
- should be used only temporarily
- should not be passed into subroutines
--
ThomasWeigert - 11 Feb 2005
Doesn't seem to be a problem on DEVELOP - see
http://develop.twiki.org/~develop/cgi-bin/view/Sandbox/TestTopic2
There is also an explanatory comment in the code already.
--
CrawfordCurrie - 11 Feb 2005
Crawford, did you look at what value
$theLinkText has when
internalLink is entered during the generation of the list? Looking at the final page tells you nothing.
--
ThomasWeigert - 11 Feb 2005
OK, so the test case is not a test case. Can you give me a testcase to illustrate where this is a problem? Is it in the call to renderWikiWordHandler?
I see the handling of
TranslationToken, which has been carried over to DEVELOP. In a spirit of adventure I applied the principles of
DFP and removed the
TranslationToken handling to see if I could work out why it is there by it's absence. I couldn't; everything seems to work just fine without it, so I propose to leave it out in DEVELOP.
--
CrawfordCurrie - 12 Feb 2005
I am sorry, I thought it was clear from the description that the problem has to do with how the links are temporarily treated and only affects you if there is something you want to do with the link names within
internalLink. For example, the handler = TWiki::Plugins::renderWikiWordHandler= is not invoked in many occasions where it should due to this problem. I have updated the test case, but it requires you to install another plugin.
Peter added an explanation on
WhatPurposeDoesTranslationTokenServe what the
TranslationToken does. I don't quite understand the situations where there would be a problem, but according to him one cannot take these out.
--
ThomasWeigert - 12 Feb 2005
Fix record
Discussion