Bug 15005: Replace $ENV{SCRIPT_NAME} with the hardcoded script paths
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 16 Oct 2015 08:05:46 +0000 (08:05 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 19 Oct 2015 12:36:43 +0000 (09:36 -0300)
Since I don't manage to make SCRIPT_NAME works directly with RequestHeader and/or
ReverseProxyPath, the easier way it to fix all the different occurrences.

Test plan:
On the import patrons page, confirm that the "Import" button does not redirect to a 'Not found' page.
You should stay on the import patrons page.

Note that if this change works, all others should work too.
Have a look at the diff of this patch and confirm there is no typo.

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Tested in patron import and item batch modification

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

offline_circ/process_koc.pl
tools/batchMod.pl
tools/batch_record_modification.pl
tools/import_borrowers.pl
tools/manage-marc-import.pl
tools/showdiffmarc.pl
tools/stage-marc-import.pl

index 21462ef..8381b1b 100755 (executable)
@@ -78,7 +78,7 @@ if ($completedJobID) {
 
     if ($runinbackground) {
         my $job_size = scalar(@input_lines);
-        $job = C4::BackgroundJob->new($sessionID, $filename, $ENV{'SCRIPT_NAME'}, $job_size);
+        $job = C4::BackgroundJob->new($sessionID, $filename, '/cgi-bin/koha/offline_circ/process_koc.pl', $job_size);
         my $jobID = $job->id();
 
         # fork off
@@ -104,7 +104,7 @@ if ($completedJobID) {
         } else {
             # fork failed, so exit immediately
             # fork failed, so exit immediately
-            warn "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
+            warn "fork failed while attempting to run offline_circ/process_koc.pl as a background job";
             exit 0;
         }
 
index af2ae4b..055e407 100755 (executable)
@@ -671,7 +671,7 @@ sub add_saved_job_results_to_template {
 sub put_in_background {
     my $job_size = shift;
 
-    my $job = C4::BackgroundJob->new($sessionID, "test", $ENV{'SCRIPT_NAME'}, $job_size);
+    my $job = C4::BackgroundJob->new($sessionID, "test", '/cgi-bin/koha/tools/batchMod.pl', $job_size);
     my $jobID = $job->id();
 
     # fork off
@@ -696,7 +696,7 @@ sub put_in_background {
         close STDERR;
     } else {
         # fork failed, so exit immediately
-        warn "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
+        warn "fork failed while attempting to run tools/batchMod.pl as a background job";
         exit 0;
     }
     return $job;
index f275088..60775a9 100755 (executable)
@@ -156,7 +156,7 @@ if ( $op eq 'form' ) {
     my ( $job );
     if ( $runinbackground ) {
         my $job_size = scalar( @record_ids );
-        $job = C4::BackgroundJob->new( $sessionID, "FIXME", $ENV{SCRIPT_NAME}, $job_size );
+        $job = C4::BackgroundJob->new( $sessionID, "FIXME", '/cgi-bin/koha/tools/batch_record_modification.pl', $job_size );
         my $job_id = $job->id;
         if (my $pid = fork) {
             $dbh->{InactiveDestroy}  = 1;
@@ -169,7 +169,7 @@ if ( $op eq 'form' ) {
             close STDOUT;
             close STDERR;
         } else {
-            warn "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
+            warn "fork failed while attempting to run tools/batch_record_modification.pl as a background job";
             exit 0;
         }
     }
index 15053cc..6d2f0c2 100755 (executable)
@@ -106,7 +106,7 @@ if ($matchpoint) {
 }
 my $overwrite_cardnumber = $input->param('overwrite_cardnumber');
 
-$template->param( SCRIPT_NAME => $ENV{'SCRIPT_NAME'} );
+$template->param( SCRIPT_NAME => '/cgi-bin/koha/tools/import_borrowers.pl' );
 
 if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
     push @feedback, {feedback=>1, name=>'filename', value=>$uploadborrowers, filename=>$uploadborrowers};
index 47803c3..b0d4f88 100755 (executable)
@@ -293,7 +293,7 @@ sub put_in_background {
     my $import_batch_id = shift;
 
     my $batch = GetImportBatch($import_batch_id);
-    my $job = C4::BackgroundJob->new($sessionID, $batch->{'file_name'}, $ENV{'SCRIPT_NAME'}, $batch->{'num_records'});
+    my $job = C4::BackgroundJob->new($sessionID, $batch->{'file_name'}, '/cgi-bin/koha/tools/manage-marc-import.pl', $batch->{'num_records'});
     my $jobID = $job->id();
 
     # fork off
@@ -318,7 +318,7 @@ sub put_in_background {
         close STDERR;
     } else {
         # fork failed, so exit immediately
-        warn "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job";
+        warn "fork failed while attempting to run tools/manage-marc-import.pl as a background job";
         exit 0;
     }
     return $job;
index 488f39e..20abada 100755 (executable)
@@ -85,7 +85,7 @@ if( $importid ) {
 
 
 $template->param(
-    SCRIPT_NAME      => $ENV{'SCRIPT_NAME'},
+    SCRIPT_NAME      => '/cgi-bin/koha/tools/showdiffmarc.pl',
     BIBLIONUMBER     => $biblionumber,
     IMPORTID         => $importid,
     BIBLIOTITLE      => $biblioTitle,
index 1a7b587..8d94cdd 100755 (executable)
@@ -72,7 +72,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 );
 
 $template->param(
-    SCRIPT_NAME => $ENV{'SCRIPT_NAME'},
+    SCRIPT_NAME => '/cgi-bin/koha/tools/stage-marc-import.pl',
     uploadmarc  => $fileID,
     record_type => $record_type,
 );
@@ -102,7 +102,7 @@ if ($completedJobID) {
         my $job_size = () = $marcrecord =~ /\035/g;
         # if we're matching, job size is doubled
         $job_size *= 2 if ($matcher_id ne "");
-        $job = C4::BackgroundJob->new($sessionID, $filename, $ENV{'SCRIPT_NAME'}, $job_size);
+        $job = C4::BackgroundJob->new($sessionID, $filename, '/cgi-bin/koha/tools/stage-marc-import.pl', $job_size);
         my $jobID = $job->id();
 
         # fork off
@@ -121,7 +121,7 @@ if ($completedJobID) {
             # close STDERR; # there is no good reason to close STDERR
         } else {
             # fork failed, so exit immediately
-            warn "fork failed while attempting to run $ENV{'SCRIPT_NAME'} as a background job: $!";
+            warn "fork failed while attempting to run tools/stage-marc-import.pl as a background job: $!";
             exit 0;
         }