To recreate: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined`
Created attachment 179173 [details] [review] Bug 39307: Check to make sure there is a document.referrer To test: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. APPLY PATCH 4. JS error should be gone
Created attachment 179298 [details] [review] Bug 39307: Check to make sure there is a document.referrer To test: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. APPLY PATCH 4. JS error should be gone Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>
Created attachment 179638 [details] [review] Bug 39307: Check to make sure there is a document.referrer To test: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. APPLY PATCH 4. JS error should be gone Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Oops, sorry for the messy changes. Thanks for the fast QA, Brendan!
Makes sense to check if there is a referrer before running that code block. Passing QA. Thanks!
Unfortunately this fails when 1) there is a referrer and 2) it is not additem.pl. While document.referrer is defined `document.referrer.split(window.location.origin + '/cgi-bin/koha/cataloguing/additem.pl?')[1]` is not be so you'll see an "undefined does not have method match" error. QA plan should be: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. Go to circ home circ/circulation-home.pl and search for a patron 4. See the console error when you select a patron or are taken directly to them 5. APPLY PATCH 6. JS error should be gone in both instances
This code works since it checks the split array index first before using match: if (document.referrer.length) { const referrerSplit = document.referrer.split(window.location.origin + '/cgi-bin/koha/cataloguing/additem.pl?') if(referrerSplit[1] && referrerSplit[1].match(/frameworkcode=FA&circborrowernumber=/) ) { let urlParams = new URLSearchParams(window.location.search); let barcode = urlParams.get('barcode'); $('#barcode').val(barcode); $('#mainform').submit(); } } Happy to make a patch and apologies if it's uncouth to set back to failed QA without consulting anyone. I just noticed this console error on our instance and saw that it wasn't due to referrer being undefined but due to the problem I stated above.
Hi Eric, thanks for catching this and changing to Failed QA. I apologize for not testing thoroughly enough. Your explanation, test plan and code makes sense. If you submit a patch I can test and sign off.
Created attachment 179701 [details] [review] Bug 39307: Check to make sure there is a document.referrer To test: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. Go to circ home circ/circulation-home.pl and search for a patron 4. See the console error when you select a patron or are taken directly to them 5. APPLY PATCH 5. JS error should be gone in both instances
Created attachment 179702 [details] [review] Bug 39307: Check to make sure there is a document.referrer To test: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. Go to circ home circ/circulation-home.pl and search for a patron 4. See the console error when you select a patron or are taken directly to them 5. APPLY PATCH 5. JS error should be gone in both instances squash Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Created attachment 179707 [details] [review] Bug 39307: Check to make sure there is a document.referrer To test: 1. Navigate to circ/circulation.pl?borrowernumber=X 2. See the console error `document.referrer.split(...)[1] is undefined` 3. Go to circ home circ/circulation-home.pl and search for a patron 4. See the console error when you select a patron or are taken directly to them 5. APPLY PATCH 5. JS error should be gone in both instances squash Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Pushed for 25.05! Well done everyone, thank you!