From 36c3d454262d814c2174483bec2a6a181c3fd3b0 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Tue, 15 Aug 2017 17:23:00 +0200 Subject: [PATCH] Bug 16401: System preference staffClientBaseURL hardcoded to 'http://' Test plan: 1) Insert some value to staffBaseURL preference, without starting http:// 2) Apply the patch 3) Update database 4) Go to system preferences adminsitration, find the staffBaseURL preference, the inserted value should be prepended with 'http://' and the comment should be "This should be a complete URL, starting with http:// or https://. Do not include a trailing slash in the URL. (This must be filled in correctly for CAS, svc, and load_testing to work.)" 5) prove t/db_dependent/Auth_with_cas.t 6) prove t/db_dependent/selenium/basic_workflow.t 7) prove t/db_dependent/check_sysprefs.t Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart --- installer/data/mysql/atomicupdate/bug_16401.perl | 8 ++++++++ installer/data/mysql/sysprefs.sql | 2 +- .../prog/en/modules/admin/preferences/staff_client.pref | 4 ++-- svc/import_bib | 2 +- t/db_dependent/Auth_with_cas.t | 2 +- t/db_dependent/selenium/basic_workflow.t | 6 +----- 6 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_16401.perl diff --git a/installer/data/mysql/atomicupdate/bug_16401.perl b/installer/data/mysql/atomicupdate/bug_16401.perl new file mode 100644 index 0000000000..946953c46c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_16401.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "UPDATE systempreferences SET value = CONCAT('http://', value) WHERE variable = 'staffClientBaseURL' AND value NOT LIKE 'http%'" ); + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 16401 - fix potentialy bad set staffClientBaseURL preference)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index bc08b5a5d3..fc4e560e54 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -495,7 +495,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SpineLabelAutoPrint','0','','If this setting is turned on, a print dialog will automatically pop up for the quick spine label printer.','YesNo'), ('SpineLabelFormat','','30|10','This preference defines the format for the quick spine label printer. Just list the fields you would like to see in the order you would like to see them, surrounded by <>, for example .','Textarea'), ('SpineLabelShowPrintOnBibDetails','0','','If turned on, a \"Print Label\" link will appear for each item on the bib details page in the staff interface.','YesNo'), -('staffClientBaseURL','',NULL,'Specify the base URL of the staff client','free'), +('staffClientBaseURL','',NULL,'Specify the base URL of the staff client starting with http:// or https://. Do not include a trailing slash in the URL. (This must be filled in correctly for CAS, svc, and load_testing to work.)','free'), ('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'), ('StaffLangSelectorMode','footer','top|both|footer','Select the location to display the language selector in staff client','Choice'), ('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref index 234d356fa9..9514b1f124 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref @@ -13,10 +13,10 @@ Staff Client: choices: staff-templates - theme on the staff interface. - - - "The staff client is located at http://" + - "The staff client is located at" - pref: staffClientBaseURL class: url - - . Do not include a trailing slash in the URL. + - This should be a complete URL, starting with http:// or https://. Do not include a trailing slash in the URL. (This must be filled in correctly for CAS, svc, and load_testing to work.) - - Use the CSS stylesheet - pref: intranetstylesheet diff --git a/svc/import_bib b/svc/import_bib index a23b72de65..c6112249f3 100755 --- a/svc/import_bib +++ b/svc/import_bib @@ -98,7 +98,7 @@ sub import_bib { $sth = $dbh->prepare("SELECT overlay_status FROM import_records WHERE import_record_id =?"); $sth->execute($import_record_id); my $match_status = $sth->fetchrow_arrayref->[0] || 'no_match'; - my $url = 'http://'. C4::Context->preference('staffClientBaseURL') .'/cgi-bin/koha/catalogue/detail.pl?biblionumber='. $biblionumber; + my $url = C4::Context->preference('staffClientBaseURL') .'/cgi-bin/koha/catalogue/detail.pl?biblionumber='. $biblionumber; $result->{'status'} = "ok"; $result->{'import_batch_id'} = $batch_id; diff --git a/t/db_dependent/Auth_with_cas.t b/t/db_dependent/Auth_with_cas.t index a58300ac1d..5389d2ed96 100755 --- a/t/db_dependent/Auth_with_cas.t +++ b/t/db_dependent/Auth_with_cas.t @@ -41,7 +41,7 @@ $dbh->{ RaiseError } = 1; C4::Context->disable_syspref_cache(); t::lib::Mocks::mock_preference('OPACBaseURL','http://localhost'); -t::lib::Mocks::mock_preference('staffClientBaseURL','localhost:8080'); +t::lib::Mocks::mock_preference('staffClientBaseURL','http://localhost:8080'); my $opac_base_url = C4::Context->preference('OpacBaseURL'); my $staff_base_url = C4::Context->preference('staffClientBaseURL'); diff --git a/t/db_dependent/selenium/basic_workflow.t b/t/db_dependent/selenium/basic_workflow.t index 235ebf29e1..5521c478a2 100644 --- a/t/db_dependent/selenium/basic_workflow.t +++ b/t/db_dependent/selenium/basic_workflow.t @@ -45,14 +45,10 @@ use MARC::Field; my $dbh = C4::Context->dbh; my $login = $ENV{KOHA_USER} || 'koha'; my $password = $ENV{KOHA_PASS} || 'koha'; -my $base_url - = ( $ENV{KOHA_INTRANET_URL} || 'http://' . C4::Context->preference("staffClientBaseURL") ) - . "/cgi-bin/koha/"; +my $base_url= ( $ENV{KOHA_INTRANET_URL} || C4::Context->preference("staffClientBaseURL") ) . "/cgi-bin/koha/"; my $selenium_addr = $ENV{SELENIUM_ADDR} || 'localhost'; my $selenium_port = $ENV{SELENIUM_PORT} || 4444; - - my $number_of_biblios_to_insert = 3; our $sample_data = { category => { -- 2.39.5