Bug 43561: Redirect to local use sysprefs instead of 'not found'

If a user search for a local use syspref, the name will appear in the
autocomplete but when choosen "not found" will be return.  This patch
suggests to redirect to the "local use" syspref view if we found a local
use syspref that match the search term.

Test plan:
- in admin, type "OPACdid" into the system preference search
- see "OPACdidyoumean" is offered as a search term
- click OPACdidyoumean
=> Without this patch you get an error that no such syspref exists
=> With this patch you are redirected to the local use syspref view

Signed-off-by: Laura_Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: John Vinke <jvinke@austinseminary.edu>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-09-18 09:20:16 +02:00 committed by Pedro Amorim
parent f8601c1b0f
commit 2db06f9510
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 7 additions and 0 deletions

View File

@ -29,6 +29,7 @@ use C4::Output qw( output_html_with_http_headers output_and_exit_if_error )
use C4::Templates; use C4::Templates;
use Koha::Acquisition::Currencies; use Koha::Acquisition::Currencies;
use Koha::AuthorisedValues; use Koha::AuthorisedValues;
use Koha::Config::SysPrefs;
use Koha::Database::Columns; use Koha::Database::Columns;
use Koha::ILL::Request::Config; use Koha::ILL::Request::Config;
use IO::File; use IO::File;
@ -467,6 +468,12 @@ if ( $op eq 'search' ) {
$tab = ''; # No need to load a particular tab, as we found results $tab = ''; # No need to load a particular tab, as we found results
$template->param( search_jumped => 1 ) if ( $TABS[0]->{'search_jumped'} ); $template->param( search_jumped => 1 ) if ( $TABS[0]->{'search_jumped'} );
} else { } else {
my $local_use = Koha::Config::SysPrefs->search( { variable => { like => "%$searchfield%" } } )->count;
if ($local_use) {
print $input->redirect("/cgi-bin/koha/admin/systempreferences.pl");
exit;
}
$template->param( $template->param(
search_not_found => 1, search_not_found => 1,
); );