• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5805: trunk doesn't work with ShorterUrlCookbook

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine TSA Urgent Closed   major  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


When I merged the fix of Item5382 to trunk, I attempted to test it, then I realized that TWiki:TWiki/ShorterUrlCookbook doesn't work with trunk. Wen used, it leads to a "Not Found" error (message generated from TWiki::UI::handleRequest: it searches for an entry within $TWiki::cfg{SwitchBoard} and if none is find, error!).

I didn't test yet, but I suspect that it happens cause $req->action() is empty (or with the web's name).

-- TWiki:Main/GilmarSantosJr - 22 Jul 2008

I changed overall path handling a little, so I could achieve more flexiblity:

  • It's possible to keep using regular bin scripts (view, edit, save, etc), so legacy/alien apache auth works as always wordek
  • CLI interface is more stable
  • It's possible to eliminate all regular bin scripts and use only twiki_cgi.pl (legacy/alien apache auth could work by using Location directives instead of Files)
  • It's possible to replace regular bin scripts by twiki_cgi.pl and keep those needed to legacy/alien apache auth
  • All items above works in the traditional way and with TWiki:TWiki.ShorterUrlCookbook

I have some assumptions:

  • twiki_cgi.pl is always used in one of the following ways:
    • ScriptAlias /twiki/bin /path/to/twiki/bin/twiki_cgi.pl (map bin to twiki_cgi.pl, so the action is the first component of path_info)
    • Alias /twiki /path/to/twiki/bin/twiki_cgi.pl (ShorterUrl. First component of path_info is not an action. Same constraints of ShorterUrl applies)
  • ShorterUrl should work with both twiki_cgi.pl and view (so, who already uses view doesn't need to change config)
  • Regular script are always used with ScriptAlias /twiki/bin /path/to/twiki/bin (the traditional way: many entry points)

So, changes were:

  • regular bin scripts define TWIKI_ACTION environment variable with its name
  • twiki_cgi.pl ensure there's no TWIKI_ACTION environment variable
  • CGI engine tests if TWIKI_ACTION is defined:
    • If it is, then set $req->action (a regular script was used. With SorterUrl or not)
    • If not, then check if the first component of PATH_INFO corresponds to an action, I mean, check if exists $TWiki::cfg{SwitchBoard}{comp} (twiki_cgi.pl was called. With ShorterUrl or not)
      • If it exists, then set action to it and remove it from PATH_INFO (no ShorterUrl)
      • If not, assume that action is view (ShorterUrl)

Corner cases:

  • If PATH_INFO is not defined or empty
    • And TWIKI_ACTION is defined, then default web and topic is used (Main.WebHome in most cases)
    • And TWIKI_ACTION not defined, then assume that action is view

The reason to keep regular bin scripts is the use of legacy/alien apache auth and CLI interface. I think this solution is flexible enough. Unit tests can keep using path_info as it was always used.

Please, verify this and give feedback.

-- TWiki:Main.GilmarSantosJr - 10 Aug 2008

Yes, that makes sense. It has the added unwritten benefit that by adding TWIKI_ACTION to $TWiki::cfg{SafeEnv}, then view will provide the action name.

-- TWiki:Main.CrawfordCurrie - 11 Aug 2008

I sent this to twiki-dev mailing list, but it's cool to also document here:

I didn't understand this unwritten benefit. Action name is available to TWiki from $twiki->{request}->action() and to plugins from TWiki::Func::getCgiQuery()->action(). The environment variable is used only by regular scripts (not twiki_cgi.pl) and CGI/CLI engines. The portable way is to check action() from TWiki::Request.

-- TWiki:Main.GilmarSantosJr - 11 Aug 2008

Crawford gave an excellent reason to add TWIKI_ACTION to $TWiki::cfg{AccessibleENV}:

> The portable way is to check action() from TWiki::Request.

From code, yes. But now template and topic authors can write:




to include OtherTopicviewVersion, OtherTopicpreviewVersion etc etc.

(if TWIKI_ACTION is added to $TWiki::cfg{AccessibleENV}, that is)

I made TWiki::Request::action() set $ENV{TWIKI_ACTION}, so it's available to TWiki core and plugins no matter what engine is in use.

-- TWiki:Main.GilmarSantosJr - 16 Aug 2008

Changing this from "waiting for release" to "closed" since this is a trunk only bug, e.g. should not be listed in TWiki-5.0.0 release notes.

-- TWiki:Main.PeterThoeny - 29 May 2010

Summary trunk doesn't work with ShorterUrlCookbook
ReportedBy TWiki:Main.GilmarSantosJr
Codebase ~twiki4
SVN Range TWiki-5.0.0, Tue, 22 Jul 2008, build 17106
AppliesTo Engine
Component TSA
Priority Urgent
CurrentState Closed

Checkins TWikirev:17401 TWikirev:17424
TargetRelease major

Edit | Attach | Watch | Print version | History: r9 < r8 < r7 < r6 < r5 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r9 - 2010-05-29 - PeterThoeny
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback