You are here: Foswiki>Tasks Web>Item958 (11 Feb 2009, MichaelDaum)Edit Attach

Item958: natsearch returns a 404 instead of results.

pencil
Priority: Urgent
Current State: No Action Required
Released In:
Target Release: n/a
Applies To: Extension
Component: NatSkinPlugin
Branches:
Reported By: AaronFuleki
Waiting For:
Last Change By: MichaelDaum
Multiple users have noted that natsearch doesn't work on FW1.0.0 with NatSkin v3.0-pre37/ NatSkinPlugin v3.0-pre36. It just returns a 404. See the irc logs for discussion, particularly from 2009-02-02 and 2009-02-01. - AaronFuleki

This item is related to Item765 -- PascalSchuppli - 11 Feb 2009

Clarification: The irc log which is linked above gives the impression that it is apache which produces the 404 because it can't find the natsearch script. As the summary of this task implies, this is not the case; natsearch is found by apache, executed by perl and produces the 404 as its output. You can test this by executing natsearch on the command line; you get the same 404 error output on stdout.

I think I know why the 404 is shown, although I don't know the Foswiki components well enough to suggest a fix. Here's my analysis of the code path that leads to the 404 error:

  1. When natsearch starts, it calls TWiki::UI::run with an argument that's most likely the function which should be called to handle the search.
  2. This in turn is a simple wrapper for Foswiki::UI:run. Foswiki::UI:run just throws away the vital information about what function to call provided by natsearch. I'd call this a bug but it seems it's actually a feature (see below)
  3. Foswiki::UI:run calls the run-method of the engine. There seem to be two possibilities for an engine, CLI and CGI. I assume we are dealing with the CGI engine.
  4. Engine::CGI::run prepares a request object and calls Foswiki::UI::handleRequest with it. The request object contains something called an "action" which seems to be of vital importance later on in determining which function to call to handle the request. Probably this action simply gets set to the script name, "natsearch", because natsearch provides none of the viable alternatives as check for in Engine::CGI::preparePath.
  5. handleRequest tries to find the requested action in the SwitchBoard configuration (whatever that is) to determine a dispatcher. The entries for the switchboard hash are defined at the top of Foswiki::UI and are definitely not incorporating anything to do with natsearch.
  6. So obviously handleRequest can't find a dispatcher for the request and outputs the 404 Error.

Reading Engine::CGI, especially preparePath, it seems natsearch might be able to define a FOSWIKI_ACTION env var to an action which exists in the switchboard, maybe search, but as I said, I don't see how all the components fit together yet, so I won't touch the code. Too bad Foswiki::UI::run throws away the function that would probably be needed in the switchboard! (wouldn't it be better to add it to the switchboard?)

Here's what the inline documentation says about throwing away the vital parameter:
Supported for bin scripts that were written for Foswiki < 2.0. The
parameter is a function reference to the UI method to call, and is ignored
in Foswiki >= 2.0, where it should be replaced by a Config.spec entry such as:

# **PERL H**
# Bin script registration - do not modify
$Foswiki::cfg{SwitchBoard}{publish} = [ "Foswiki::Contrib::Publish", "publish", { publishing => 1 } ];

So.... is this something Michael Daum should add to the natskin plugin distribution? Michael, can you provide feedback?

-- PascalSchuppli - 10 Feb 2009

Hi Pascal,

Thanks for this great analysis!

You can "solve" this issue by adding:
$Foswiki::cfg{SwitchBoard}{natsearch} = [ 'TWiki::Plugins::NatSkinPlugin::Search', 'searchCgi', {natsearch => 1}];

to your lib/LocalSite.cfg. This problem is related to the (solved) task Item714 and Development.FoswikiStandAlone#Note_to_Extension_Developers.

-- GilmarSantosJr - 11 Feb 2009

Yep, that did it. Thanks. I'm leaving the state on "Waiting For Feedback" to get Michael's attention to it so he fixes the plugin :-), but as for me, the matter is sufficiently solved with the entry to LocalSite.cfg.

-- PascalSchuppli - 11 Feb 2009

I did a full svn checkout over the weekend (trunk rev 2419), and natseach works fine there, but I haven't looked at the commit log to see if either of the two things GilmarSantosJr mentioned made their way in.

-- AaronFuleki - 11 Feb 2009

Natsearch works fine calling it as a regular cgi script now. If you are using fastcgi contrib, you will have to add the switchboard entry as noted above. I will add this to the installation/documentation of the plugin. See also the discussion at Item765. Basically, this bug item here is reporting the same issue. Closing this one and continuing at the other one.

-- MichaelDaum - 11 Feb 2009

ItemTemplate edit

Summary natsearch returns a 404 instead of results.
ReportedBy AaronFuleki
Codebase 1.0.0
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component NatSkinPlugin
Priority Urgent
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn
Topic revision: r7 - 11 Feb 2009, MichaelDaum
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