Bug 17785 - oai.pl returns wrong URLs under Plack
Summary: oai.pl returns wrong URLs under Plack
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Marcel de Rooy
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-16 12:46 UTC by Marcel de Rooy
Modified: 2017-06-14 22:17 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 17785: oai.pl returns wrong URLs under Plack (9.88 KB, patch)
2016-12-20 15:23 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 17785: Fix OAI-PMH's XSLT-generated URLs under Plack (10.01 KB, patch)
2016-12-21 13:01 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 17785: Fix OAI-PMH's XSLT-generated URLs under Plack (10.08 KB, patch)
2016-12-27 15:04 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2016-12-16 12:46:31 UTC
oai.pl uses CGI's self_url
Under Plack this results in an URL like:
/opac/oai.pl?verb=ListRecords&resumptionToken=marcxml/100/1970-01-01T00:00:00Z/2016-12-16T23:59:59Z/
(This is the URL for the More button.)

Should we adjust the mounting point and ProxyPass statements?
Mount like /cgi-bin/koha/opac ?
Comment 1 Marcel de Rooy 2016-12-20 15:23:37 UTC
Created attachment 58303 [details] [review]
Bug 17785: oai.pl returns wrong URLs under Plack

Look at e.g. the URL for Show More at the end of the output of Records or
Identifiers. If you use Plack, you will see that it refers to
yourserver:/opac/oai.pl, which is not correct.

This is caused by using CGI's self_url in combination with script alias,
mounting point, etc. Note that we cannot solve this problem in the code of
Koha only. Since HTTP::OAI modules also call self_url, we still end up
with some wrong url's.

Instead of a larger architectural operation on Apache and Plack config files,
this patch adjusts the final xslt transformation on the OAI response.
It hardcodes the correct path only once, in a xslt variable. And replaces
all oai:OAI-PMH/oai:request/text() calls, containing wrong URLs, by this
variable.

Test plan:
Run oai.pl. Try the various verbs.
Verify that the URLs point to /cgi-bin/koha/oai.pl.
Comment 2 Marcel de Rooy 2016-12-20 15:25:13 UTC
Adding in cc some people involved in recent oai changes.
Comment 3 Tomás Cohen Arazi 2016-12-21 13:01:54 UTC
Created attachment 58338 [details] [review]
Bug 17785: Fix OAI-PMH's XSLT-generated URLs under Plack

Look at e.g. the URL for Show More at the end of the output of Records or
Identifiers. If you use Plack, you will see that it refers to
yourserver:/opac/oai.pl, which is not correct.

This is caused by using CGI's self_url in combination with script alias,
mounting point, etc. Note that we cannot solve this problem in the code of
Koha only. Since HTTP::OAI modules also call self_url, we still end up
with some wrong url's.

Instead of a larger architectural operation on Apache and Plack config files,
this patch adjusts the final xslt transformation on the OAI response.
It hardcodes the correct path only once, in a xslt variable. And replaces
all oai:OAI-PMH/oai:request/text() calls, containing wrong URLs, by this
variable.

Test plan:
Run oai.pl. Try the various verbs.
Verify that the URLs point to /cgi-bin/koha/oai.pl.

Edit: changed commit subject

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Works as expected. Good workaround until a definitive solution is implemented.
Comment 4 Jonathan Druart 2016-12-27 15:04:25 UTC
Created attachment 58435 [details] [review]
Bug 17785: Fix OAI-PMH's XSLT-generated URLs under Plack

Look at e.g. the URL for Show More at the end of the output of Records or
Identifiers. If you use Plack, you will see that it refers to
yourserver:/opac/oai.pl, which is not correct.

This is caused by using CGI's self_url in combination with script alias,
mounting point, etc. Note that we cannot solve this problem in the code of
Koha only. Since HTTP::OAI modules also call self_url, we still end up
with some wrong url's.

Instead of a larger architectural operation on Apache and Plack config files,
this patch adjusts the final xslt transformation on the OAI response.
It hardcodes the correct path only once, in a xslt variable. And replaces
all oai:OAI-PMH/oai:request/text() calls, containing wrong URLs, by this
variable.

Test plan:
Run oai.pl. Try the various verbs.
Verify that the URLs point to /cgi-bin/koha/oai.pl.

Edit: changed commit subject

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Works as expected. Good workaround until a definitive solution is implemented.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 5 Kyle M Hall 2016-12-28 13:36:31 UTC
Pushed to master for 17.05, thanks Marcel!
Comment 6 Katrin Fischer 2017-01-04 21:36:20 UTC
This patch has been pushed to 16.11.x and will be in 16.11.02.
Comment 7 Mason James 2017-01-27 02:41:05 UTC
Pushed to 16.05.x, for 16.05.08 release
Comment 8 Steven F. Schmieder 2017-03-11 13:01:50 UTC
I am having a similar problem that does appear to have been solved by the patch.  I running Debian Stretch RC2 with perl 5.24.1 and Koha 16.11.04.  Everythings works fine except the oai.pl script which returns an "internal server message".  As far as I can ascertain, the other scripts run fine.