The good old
ScriptUrlPath config variable, like all config variables ending with "Path", needs to be fed with a relative URL. Cool.
The new
ScriptUrlPaths thingie is great, but... the documentation (
TWiki:TWiki/ShorterURLCookbook) gives an example where it is fed with an absolute URL. Weird.
Not so weird, or more weird actually, since it does not work as expected if it is fed with a relative URL ; my test setup for shorter-urls reveals a bug ; my config is :
$cfg{ScriptUrlPath} = '/twiki';
$TWiki::cfg{ScriptUrlPaths}{view} = '/twiki';
The initial bug that told me something was wrong is : the logout button in the
WebLeftBar is broken, and links to
http://my.test.host/twiki/edit/TWiki/TwikiMainBenVouilogout1?topicparent=Main.BenVoui, when I'm on
http://my.test.host/twiki/Main/BenVoui page. However, it shoud link to
http://cage.krups.taz/twiki/Main/BenVoui?logout=1 instead.
Why ? I tracked down the problem : the
_LOGOUTURL
function (in
lib/TWiki/Client.pm
) uses
getScriptUrl
to build the logout URL. I then had a look to the new
getScriptUrl
function, that now supports
{ScriptUrlPaths}
in addition to
{ScriptUrlPath}
. And... here is the weirdest : in order to build an absolute URL,
getScriptUrl
only prepends
$this->{urlHost}
when no
{ScriptUrlPaths}
value exist for the given script, i.e. in the classic case. In the not-so-classic and not-so-much-tested-case where a
relative path exists, in
{ScriptUrlPaths}
, for the given script, no
$this->{urlHost}
is prepended, which makes the
_LOGOUT
function to break.
I tried the following to achieve the behaviour that seemed more logical to me (not only it would seem more logical to me like this, but I particularly need relative URLs for wikis available via http
and https, see Bugs.Item1099) :
- in the config, feed
{ScriptUrlPaths}
with relative URLs, like we already do for the good old {ScriptUrlPath}
- modify
getScriptUrl
to prepend $this->{urlHost}
in both case ; the following patch is against SVN r7706 :
--- TWiki.pm.orig 2005-12-02 07:00:15.000000000 +0100
+++ TWiki.pm 2005-12-02 07:00:32.000000000 +0100
@@ -873,7 +873,7 @@
# $this->{urlHost} is needed, see Codev.PageRedirectionNotWorking
my $url;
if( defined $TWiki::cfg{ScriptUrlPaths} ) {
- $url = $TWiki::cfg{ScriptUrlPaths}{$script};
+ $url = $this->{urlHost}.$TWiki::cfg{ScriptUrlPaths}{$script};
}
unless( $url ) {
$url = $this->{urlHost}.$TWiki::cfg{ScriptUrlPath}.'/'.
This fixes the "logout button" bug, and after 5 minutes of random testing, does not break anything ; except that... the "Log In" button is broken, it links to :
http://my.test.host/Main/BenVoui?origurl=http%3a//my.test.host/twiki/Main/BenVoui ; investigating.
Update: I just realize that, the way
getScriptUrl
is written, either
all or
no scripts' path have to be defined in
{ScriptUrlPaths}
. Intuitively, I had considered this variable as a way to define
exceptions. What should it really do ? Anyway, with my above patch applied, and
{ScriptUrlPaths}{login}
set to
'/twiki/login'
, the "Log In" button also works. And since this
{ScriptUrlPaths}
definition problem does not fit this bug's topic, I create another bug : Bugs.Item1102.
-- BenVoui
duplicate of 1099; and the suggested patch is wrong.
Discarded.
CC