Bugzilla – Attachment 103495 Details for
Bug 25222
Add ability to let plugins live in individual subdirectories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25222: (QA follow-up) Make Koha create the subdirectory
Bug-25222-QA-follow-up-Make-Koha-create-the-subdir.patch (text/plain), 3.07 KB, created by
Kyle M Hall (khall)
on 2020-04-22 16:47:28 UTC
(
hide
)
Description:
Bug 25222: (QA follow-up) Make Koha create the subdirectory
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-04-22 16:47:28 UTC
Size:
3.07 KB
patch
obsolete
>From 98407ad652421ab4c8f736851eb774196d420d95 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 22 Apr 2020 11:39:19 -0400 >Subject: [PATCH] Bug 25222: (QA follow-up) Make Koha create the subdirectory > >--- > plugins/plugins-upload.pl | 31 +++++++++++++++++++++++++------ > 1 file changed, 25 insertions(+), 6 deletions(-) > >diff --git a/plugins/plugins-upload.pl b/plugins/plugins-upload.pl >index c4e8a204d0..895615b4df 100755 >--- a/plugins/plugins-upload.pl >+++ b/plugins/plugins-upload.pl >@@ -20,9 +20,10 @@ use Modern::Perl; > > use Archive::Extract; > use CGI qw ( -utf8 ); >-use Mojo::UserAgent; > use File::Copy; >+use File::Find::Rule; > use File::Temp; >+use Mojo::UserAgent; > > use C4::Context; > use C4::Auth; >@@ -59,8 +60,8 @@ if ($plugins_enabled) { > my $plugins_dir = C4::Context->config("pluginsdir"); > $plugins_dir = ref($plugins_dir) eq 'ARRAY' ? $plugins_dir->[0] : $plugins_dir; > >- my $dirname = File::Temp::tempdir( CLEANUP => 1 ); >- $debug and warn "dirname = $dirname"; >+ my $temp_dir = File::Temp::tempdir( CLEANUP => 1 ); >+ $debug and warn "temp_dir = $temp_dir"; > > my $filesuffix; > $filesuffix = $1 if $uploadfilename =~ m/(\..+)$/i; >@@ -69,7 +70,7 @@ if ($plugins_enabled) { > $debug and warn "tempfile = $tempfile"; > > $errors{'NOTKPZ'} = 1 if ( $uploadfilename !~ /\.kpz$/i ); >- $errors{'NOWRITETEMP'} = 1 unless ( -w $dirname ); >+ $errors{'NOWRITETEMP'} = 1 unless ( -w $temp_dir ); > $errors{'NOWRITEPLUGINS'} = 1 unless ( -w $plugins_dir ); > > if ( $uploadlocation ) { >@@ -91,9 +92,27 @@ if ($plugins_enabled) { > } > > my $ae = Archive::Extract->new( archive => $tempfile, type => 'zip' ); >- unless ( $ae->extract( to => $plugins_dir ) ) { >- warn "ERROR: " . $ae->error; >+ if ( $ae->extract( to => $temp_dir ) ) { >+ my ( $module ) = sort File::Find::Rule->file()->name( '*.pm' )->in( $temp_dir ); >+ $module =~ s|^$temp_dir||; # Strip out the temp dir from the start of the path >+ $module =~ s|^/||; # Remove the leading slash >+ $module =~ s|/|-|g; # Convert the path slashes to dashes >+ $module =~ s|\.pm$||; # Remove the file suffix >+ $module = lc( $module ); # Convert to all lower case >+ $module =~ s|^koha-plugin-||; # Remove the leading 'koha-plugin-', we already know this is a koha plugin ;) >+ >+ my $module_dir = "$plugins_dir/$module"; >+ mkdir( $module_dir ); >+ >+ unless ( $ae->extract( to => $module_dir ) ) { >+ $errors{'UZIPFAIL'} = $uploadfilename; >+ } >+ } >+ else { > $errors{'UZIPFAIL'} = $uploadfilename; >+ } >+ >+ if ( keys %errors ) { > $template->param( ERRORS => [ \%errors ] ); > output_html_with_http_headers $input, $cookie, $template->output; > exit; >-- >2.24.2 (Apple Git-127)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25222
:
103311
|
103317
|
103389
| 103495 |
103496