After changes made to addbiblio with the bug 31791, when trying to open the editor with biblionumber=<invalid_number> (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 >>
Created attachment 166190 [details] [review] Bug 36786: (Bug 31791 follow-up) Koha explodes when trying to edit a biblio with invalid biblionumber After changes made to addbiblio with the bug 31791, when trying to open the editor with biblionumber=<invalid_number> (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 >> Test plan: ========== 1. Try to edit a biblio giving as a biblionumber (in URL) a non-existing biblionumber, e.g. in ktd, with standard ktd test data: http://your_ktd:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=1234567 Koha should explode with the message: Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 2. Apply the patch; restart_all. 3. Repeat p.1. You should get the 403 error page. Sponsored-by: Ignatianum University in Cracow
Created attachment 166233 [details] [review] Bug 36786: (Bug 31791 follow-up) Koha explodes when trying to edit a biblio with invalid biblionumber After changes made to addbiblio with the bug 31791, when trying to open the editor with biblionumber=<invalid_number> (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 >> Test plan: ========== 1. Try to edit a biblio giving as a biblionumber (in URL) a non-existing biblionumber, e.g. in ktd, with standard ktd test data: http://your_ktd:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=1234567 Koha should explode with the message: Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 2. Apply the patch; restart_all. 3. Repeat p.1. You should get the 403 error page. Sponsored-by: Ignatianum University in Cracow Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Hi, I felt tempted to rewrite all those conditionals on adding this feature. I didn't do it because I didn't intend to change other behaviors. One of those is the fact this page has some custom handling of the record not found use case. I don't think it is THAT important, but with your patch, that part of the template becomes unreachable, and thus requires a cleanup. That said, I'd suggest you make the condition be checked as an else of the previous one: ```perl if ($biblio) { if ( !$biblio->can_be_edited($logged_in_patron) ) { print $input->redirect("/cgi-bin/koha/errors/403.pl"); # escape early exit; } else { $biblionumber = undef; $template->param( bib_doesnt_exist => 1 ); } ``` Otherwise you will be returning 403 when the record doesn't exist, which should be a 404 and has specific code for handling it.
(In reply to Tomás Cohen Arazi from comment #3) > That said, I'd suggest you make the condition be checked as an else of the > previous one: > Thank you, Tomás, you are right--that would be much better! A new version follows.
Created attachment 166260 [details] [review] Bug 36786: (Bug 31791 follow-up) Koha explodes when trying to edit a biblio with invalid biblionumber After changes made to addbiblio with the bug 31791, when trying to open the editor with biblionumber=<invalid_number> (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 >> Test plan: ========== 1. Try to edit a biblio giving as a biblionumber (in URL) a non-existing biblionumber, e.g. in ktd, with standard ktd test data: http://your_ktd:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=1234567 Koha should explode with the message: Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 2. Apply the patch; restart_all. 3. Repeat p.1. You should get the 403 error page. Sponsored-by: Ignatianum University in Cracow
Created attachment 166262 [details] [review] Bug 36786: (Bug 31791 follow-up) Koha explodes when trying to edit a biblio with invalid biblionumber After changes made to addbiblio with the bug 31791, when trying to open the editor with biblionumber=<invalid_number> (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 >> Test plan: ========== 1. Try to edit a biblio giving as a biblionumber (in URL) a non-existing biblionumber, e.g. in ktd, with standard ktd test data: http://your_ktd:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=1234567 Koha should explode with the message: Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 2. Apply the patch; restart_all. 3. Repeat p.1. You should get a page with the info: "The record you are trying to edit doesn't exist...". Sponsored-by: Ignatianum University in Cracow
Created attachment 166285 [details] [review] Bug 36786: (Bug 31791 follow-up) Koha explodes when trying to edit a biblio with invalid biblionumber After changes made to addbiblio with the bug 31791, when trying to open the editor with biblionumber=<invalid_number> (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 >> Test plan: ========== 1. Try to edit a biblio giving as a biblionumber (in URL) a non-existing biblionumber, e.g. in ktd, with standard ktd test data: http://your_ktd:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=1234567 Koha should explode with the message: Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 2. Apply the patch; restart_all. 3. Repeat p.1. You should get a page with the info: "The record you are trying to edit doesn't exist...". Sponsored-by: Ignatianum University in Cracow Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Created attachment 166328 [details] [review] Bug 36786: (Bug 31791 follow-up) Koha explodes when trying to edit a biblio with invalid biblionumber After changes made to addbiblio with the bug 31791, when trying to open the editor with biblionumber=<invalid_number> (e.g. a deleted biblionumber) Koha explodes with a message << Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 >> Test plan: ========== 1. Try to edit a biblio giving as a biblionumber (in URL) a non-existing biblionumber, e.g. in ktd, with standard ktd test data: http://your_ktd:8081/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=1234567 Koha should explode with the message: Can't call method "can_be_edited" on an undefined value at /kohadevbox/koha/cataloguing/addbiblio.pl line 555 2. Apply the patch; restart_all. 3. Repeat p.1. You should get a page with the info: "The record you are trying to edit doesn't exist...". Sponsored-by: Ignatianum University in Cracow Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Pushed for 24.05! Well done everyone, thank you!
Depends on Bug 31791 not in 23.11.x
No changes required to the manual.