Bug 20351

Summary: Implement blocking errors for serials scripts
Product: Koha Reporter: Maria <mbugz2>
Component: SerialsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: trivial    
Priority: P5 - low CC: colin.campbell, fridolin.somers, jonathan.druart, martin.renvoize, nick, sandboxes
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20661
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20927
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21232
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 20661, 20730    
Bug Blocks:    
Attachments: Bug 20351: Shortcut serials scripts if a blocking error appeared
Bug 20351: Shortcut serials scripts if a blocking error appeared
Bug 20351: Shortcut serials scripts if a blocking error appeared
Bug 20351: Shortcut serials scripts if a blocking error appeared
Bug 20351: Shortcut serials scripts if a blocking error appeared
Bug 20351: Shortcut serials scripts if a blocking error appeared

Description Maria 2018-03-07 16:13:49 UTC
When you go to subscription details, like

cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=108

and use a subscriptionid which is not in the subscriptions table

you get an empty subscription item, but

should get a page telling you the subscription doesn't exist.
Comment 1 Jonathan Druart 2018-05-08 17:41:03 UTC
Created attachment 75178 [details] [review]
Bug 20351: Shortcut serials scripts if a blocking error appeared

The idea of output_and_exit_if_error (added by bug 18403) is to make sure
parameters are valid before executing the script.
If not (old or broken URLs), we shortcut everything coming next to display a
generic error ("object does not exist", "you do not have permission to do that", etc.)

This bug report fixes the scripts under serials/*.

Test plan:
Hit the script under the serials directory with an invalid subscriptionid parameter
and confirm you get an error instead of the normal view with empty values.

The goal is not to be exhaustive during the first iteration, but at least to fix
the most common views.

For instance:
/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=XXX
/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=XXX
/cgi-bin/koha/serials/routing.pl?subscriptionid=XXX&op=new
/cgi-bin/koha/serials/subscription-add.pl?op=modify&subscriptionid=XXx
/cgi-bin/koha/serials/subscription-add.pl?op=dup&subscriptionid=XXX
Comment 2 Jonathan Druart 2018-05-08 18:55:04 UTC
Created attachment 75185 [details] [review]
Bug 20351: Shortcut serials scripts if a blocking error appeared

The idea of output_and_exit_if_error (added by bug 18403) is to make sure
parameters are valid before executing the script.
If not (old or broken URLs), we shortcut everything coming next to display a
generic error ("object does not exist", "you do not have permission to do that", etc.)

This bug report fixes the scripts under serials/*.

Test plan:
Hit the script under the serials directory with an invalid subscriptionid parameter
and confirm you get an error instead of the normal view with empty values.

The goal is not to be exhaustive during the first iteration, but at least to fix
the most common views.

For instance:
/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=XXX
/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=XXX
/cgi-bin/koha/serials/routing.pl?subscriptionid=XXX&op=new
/cgi-bin/koha/serials/subscription-add.pl?op=modify&subscriptionid=XXx
/cgi-bin/koha/serials/subscription-add.pl?op=dup&subscriptionid=XXX
Comment 3 Maria 2018-05-11 15:02:10 UTC
I did an attempt to set up a sandbox and sign it off, but got this result.

The sandbox you've requested is not ready.
Some problems occurred applying patches from bug 20351:
<h1>Something went wrong !</h1>Applying: Bug 20351: Shortcut serials scripts if a blocking error appeared
.git/rebase-apply/patch:61: trailing whitespace.
   
.git/rebase-apply/patch:107: trailing whitespace.
   
.git/rebase-apply/patch:120: trailing whitespace.
  
fatal: sha1 information is lacking or useless (koha-tmpl/intranet-tmpl/prog/en/includes/blocking_errors.inc).
error: could not build fake ancestor
Patch failed at 0001 Bug 20351: Shortcut serials scripts if a blocking error appeared
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem run git bz apply --continue.
If you would prefer to skip this patch, instead run git bz apply --skip.
To restore the original branch and stop patching run git bz apply --abort.
Bug 20351 - Implement blocking errors for serials scripts

75185 - Bug 20351: Shortcut serials scripts if a blocking error appeared

Apply? [(y)es, (n)o, (i)nteractive] Patch left in /tmp/Bug-20351-Shortcut-serials-scripts-if-a-blocking-e-EBl7TX.patch .
Comment 4 Jonathan Druart 2018-05-11 17:16:01 UTC
Created attachment 75274 [details] [review]
Bug 20351: Shortcut serials scripts if a blocking error appeared

The idea of output_and_exit_if_error (added by bug 18403) is to make sure
parameters are valid before executing the script.
If not (old or broken URLs), we shortcut everything coming next to display a
generic error ("object does not exist", "you do not have permission to do that", etc.)

This bug report fixes the scripts under serials/*.

Test plan:
Hit the script under the serials directory with an invalid subscriptionid parameter
and confirm you get an error instead of the normal view with empty values.

The goal is not to be exhaustive during the first iteration, but at least to fix
the most common views.

For instance:
/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=XXX
/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=XXX
/cgi-bin/koha/serials/routing.pl?subscriptionid=XXX&op=new
/cgi-bin/koha/serials/subscription-add.pl?op=modify&subscriptionid=XXx
/cgi-bin/koha/serials/subscription-add.pl?op=dup&subscriptionid=XXX
Comment 5 Jonathan Druart 2018-05-11 17:16:39 UTC
(In reply to Maria from comment #3)
> I did an attempt to set up a sandbox and sign it off, but got this result.
> 

You need to apply patches from bug 20661 and bug 20730 first.
Comment 6 Katrin Fischer 2018-08-30 06:08:27 UTC
Patch doesn't apply, can you please fix?
Comment 7 Jonathan Druart 2018-08-31 18:00:08 UTC
Created attachment 78344 [details] [review]
Bug 20351: Shortcut serials scripts if a blocking error appeared

The idea of output_and_exit_if_error (added by bug 18403) is to make sure
parameters are valid before executing the script.
If not (old or broken URLs), we shortcut everything coming next to display a
generic error ("object does not exist", "you do not have permission to do that", etc.)

This bug report fixes the scripts under serials/*.

Test plan:
Hit the script under the serials directory with an invalid subscriptionid parameter
and confirm you get an error instead of the normal view with empty values.

The goal is not to be exhaustive during the first iteration, but at least to fix
the most common views.

For instance:
/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=XXX
/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=XXX
/cgi-bin/koha/serials/routing.pl?subscriptionid=XXX&op=new
/cgi-bin/koha/serials/subscription-add.pl?op=modify&subscriptionid=XXx
/cgi-bin/koha/serials/subscription-add.pl?op=dup&subscriptionid=XXX
Comment 8 Biblibre Sandboxes 2018-09-15 20:28:13 UTC
Patch tested with a sandbox, by Séverine QUEUNE <severine.queune@bulac.fr>
Comment 9 Biblibre Sandboxes 2018-09-15 20:28:38 UTC
Created attachment 78887 [details] [review]
Bug 20351: Shortcut serials scripts if a blocking error appeared

The idea of output_and_exit_if_error (added by bug 18403) is to make sure
parameters are valid before executing the script.
If not (old or broken URLs), we shortcut everything coming next to display a
generic error ("object does not exist", "you do not have permission to do that", etc.)

This bug report fixes the scripts under serials/*.

Test plan:
Hit the script under the serials directory with an invalid subscriptionid parameter
and confirm you get an error instead of the normal view with empty values.

The goal is not to be exhaustive during the first iteration, but at least to fix
the most common views.

For instance:
/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=XXX
/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=XXX
/cgi-bin/koha/serials/routing.pl?subscriptionid=XXX&op=new
/cgi-bin/koha/serials/subscription-add.pl?op=modify&subscriptionid=XXx
/cgi-bin/koha/serials/subscription-add.pl?op=dup&subscriptionid=XXX

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 10 Katrin Fischer 2018-10-10 21:33:11 UTC
Created attachment 80371 [details] [review]
Bug 20351: Shortcut serials scripts if a blocking error appeared

The idea of output_and_exit_if_error (added by bug 18403) is to make sure
parameters are valid before executing the script.
If not (old or broken URLs), we shortcut everything coming next to display a
generic error ("object does not exist", "you do not have permission to do that", etc.)

This bug report fixes the scripts under serials/*.

Test plan:
Hit the script under the serials directory with an invalid subscriptionid parameter
and confirm you get an error instead of the normal view with empty values.

The goal is not to be exhaustive during the first iteration, but at least to fix
the most common views.

For instance:
/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=XXX
/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=XXX
/cgi-bin/koha/serials/routing.pl?subscriptionid=XXX&op=new
/cgi-bin/koha/serials/subscription-add.pl?op=modify&subscriptionid=XXx
/cgi-bin/koha/serials/subscription-add.pl?op=dup&subscriptionid=XXX

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Nick Clemens (kidclamp) 2018-10-17 19:21:48 UTC
Awesome work all!

Pushed to master for 18.11
Comment 12 Martin Renvoize (ashimema) 2018-10-26 13:15:54 UTC
Pushed to 18.05.x for 18.05.06
Comment 13 Fridolin Somers 2018-11-09 15:14:33 UTC
Depends on Bug 20661 not in 17.11.x