Item5805: Trunk doesn't work with ShorterUrlCookbook

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.0
Target Release: patch
Applies To: Engine
Component: TSA
Branches:
Reported By: TWiki:Main.GilmarSantosJr
Waiting For:
Last Change By: KennethLavrsen
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 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:

%ENV{TWIKI_ACTION}%

e.g.

%INCLUDE{"OtherTopicVersion"}%

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

ItemTemplate edit

Summary Trunk doesn't work with ShorterUrlCookbook
ReportedBy TWiki:Main.GilmarSantosJr
Codebase trunk
SVN Range TWiki-5.0.0, Tue, 22 Jul 2008, build 17106
AppliesTo Engine
Component TSA
Priority Urgent
CurrentState Closed
WaitingFor
Checkins TWikirev:17401 TWikirev:17424
TargetRelease patch
ReleasedIn 1.0.0
Topic revision: r9 - 26 Dec 2008, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy