From 1946245a838fcf3fc24ee10ea77700a4686f3dda 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 --- 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 | 2 +- 6 files changed, 14 insertions(+), 6 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 0000000..946953c --- /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 0bd8cac..e26d23a 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -491,7 +491,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'), ('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'), ('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'), 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 e7da2e8..0ee8ffe 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 @@ -6,10 +6,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 a23b72d..c611224 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 ab21233..6754621 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 f439dac..dadf99b 100644 --- a/t/db_dependent/selenium/basic_workflow.t +++ b/t/db_dependent/selenium/basic_workflow.t @@ -45,7 +45,7 @@ use MARC::Field; my $dbh = C4::Context->dbh; my $login = 'koha'; my $password = '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 $number_of_biblios_to_insert = 3; -- 2.1.4