695 my ( $duplicatebiblionumber, $duplicatetitle ); 696 ( $duplicatebiblionumber, $duplicatetitle ) = FindDuplicate($record); 697 698 my $confirm_not_duplicate = $headers->header('x-confirm-not-duplicate'); 699 700 return $c->render( 701 status => 400, 702 openapi => { 703 error => "Duplicate biblio $duplicatebiblionumber", 704 } 705 ) unless !$duplicatebiblionumber || $confirm_not_duplicate; We don't need to call FindDuplicate if the header is set.
Nice finding.
Created attachment 176806 [details] [review] Bug 38927: Only call FindDuplicate if required This patch makes the code call `FindDuplicate` only if `x-confirm-not-duplicate` is not passed. This makes sense, as having it passed makes it override any duplicate found. This patch doesn't change any end user behavior, just makes the code more efficient. To test: 1. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/biblios.t => SUCCESS: Tests pass 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests pass, no behavior change 4. Sign off :-D
Created attachment 176825 [details] [review] Bug 38927: Only call FindDuplicate if required This patch makes the code call `FindDuplicate` only if `x-confirm-not-duplicate` is not passed. This makes sense, as having it passed makes it override any duplicate found. This patch doesn't change any end user behavior, just makes the code more efficient. To test: 1. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/biblios.t => SUCCESS: Tests pass 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests pass, no behavior change 4. Sign off :-D Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 176837 [details] [review] Bug 38927: Only call FindDuplicate if required This patch makes the code call `FindDuplicate` only if `x-confirm-not-duplicate` is not passed. This makes sense, as having it passed makes it override any duplicate found. This patch doesn't change any end user behavior, just makes the code more efficient. To test: 1. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/biblios.t => SUCCESS: Tests pass 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests pass, no behavior change 4. Sign off :-D Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Hm, this reads a little confusing: + if ( !$confirm_not_duplicate ) { + my ( $duplicatebiblionumber, $duplicatetitle ) = FindDuplicate($record); But after checking docs: confirm_not_duplicate doesn't mean "Koha, confirm this is not a duplicate" but "API user says this is not a duplicate". OK.
Pushed for 25.05! Well done everyone, thank you!