]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
no bug - Remove File::Slurp and File::Slurper
authorDylan William Hardison <dylan@hardison.net>
Tue, 6 Nov 2018 20:12:09 +0000 (15:12 -0500)
committerGitHub <noreply@github.com>
Tue, 6 Nov 2018 20:12:09 +0000 (15:12 -0500)
Bugzilla/Bloomfilter.pm
Bugzilla/Install/Filesystem.pm
Bugzilla/Quantum/CGI.pm
Bugzilla/Template.pm
Makefile.PL
extensions/BMO/Extension.pm
extensions/RequestNagger/bin/send-request-nags.pl
scripts/update_localconfig.pl
t/css.t

index ba1d6d6c35e270ef62c9db8d15045dfc6085865b..10ac39b71c90ea52311d590922d797492a7b5f0a 100644 (file)
@@ -13,7 +13,7 @@ use warnings;
 
 use Bugzilla::Constants;
 use Algorithm::BloomFilter;
-use File::Slurper qw(write_binary read_binary read_lines);
+use Mojo::File qw(path);
 use File::Spec::Functions qw(catfile);
 
 sub _new_bloom_filter {
@@ -24,33 +24,33 @@ sub _new_bloom_filter {
     return Algorithm::BloomFilter->new($m, $k);
 }
 
-sub _filename {
+sub _file {
     my ($name, $type) = @_;
 
     my $datadir = bz_locations->{datadir};
 
-    return catfile($datadir, "$name.$type");
+    return path(catfile($datadir, "$name.$type"));
 }
 
 sub populate {
     my ($class, $name) = @_;
     my $memcached = Bugzilla->memcached;
-    my @items     = read_lines(_filename($name, 'list'));
+    my @items     = split(/\n/, _file($name, 'list')->slurp);
     my $filter    = _new_bloom_filter(@items + 0);
 
     $filter->add($_) foreach @items;
-    write_binary(_filename($name, 'bloom'), $filter->serialize);
+    _file($name, 'bloom')->spurt( $filter->serialize );
     $memcached->clear_bloomfilter({name => $name});
 }
 
 sub lookup {
     my ($class, $name) = @_;
     my $memcached   = Bugzilla->memcached;
-    my $filename    = _filename($name, 'bloom');
+    my $file        = _file($name, 'bloom');
     my $filter_data = $memcached->get_bloomfilter( { name => $name } );
 
-    if (!$filter_data && -f $filename) {
-        $filter_data = read_binary($filename);
+    if (!$filter_data && -f $file) {
+        $filter_data = $file->slurp;
         $memcached->set_bloomfilter({ name => $name, filter => $filter_data });
     }
 
index 317152962cb0541b6df6b7de9e277d0e2cf83617..faf031d5b75cc4675714b9227fbdd53fe1aa0e6b 100644 (file)
@@ -32,8 +32,8 @@ use File::Path;
 use File::Basename;
 use File::Copy qw(move);
 use File::Spec;
+use Mojo::File qw(path);
 use Cwd ();
-use File::Slurp;
 use IO::File;
 use POSIX ();
 use English qw(-no_match_vars $OSNAME);
@@ -327,30 +327,30 @@ sub FILESYSTEM {
     my $yui_all_css = sub {
         return join("\n",
             map {
-                my $css = read_file($_);
+                my $css = path($_)->slurp;
                 _css_url_fix($css, $_, "skins/yui.css.list")
-            } read_file("skins/yui.css.list", { chomp => 1 })
+            } split(/\n/, path("skins/yui.css.list")->slurp)
         );
     };
 
     my $yui_all_js = sub {
         return join("\n",
-            map { scalar read_file($_) } read_file("js/yui.js.list", { chomp => 1 })
+            map { path($_)->slurp } split(/\n/, path("js/yui.js.list")->slurp)
         );
     };
 
     my $yui3_all_css = sub {
         return join("\n",
             map {
-                my $css = read_file($_);
+                my $css = path($_)->slurp;
                 _css_url_fix($css, $_, "skins/yui3.css.list")
-            } read_file("skins/yui3.css.list", { chomp => 1 })
+            } split(/\n/, path("skins/yui3.css.list")->slurp)
         );
     };
 
     my $yui3_all_js = sub {
         return join("\n",
-            map { scalar read_file($_) } read_file("js/yui3.js.list", { chomp => 1 })
+            map { path($_)->slurp } split(/\n/, path('js/yui3.js.list')->slurp)
         );
     };
 
index 6a9492d06def30975492098014c157e692d87540..41d6af16b02a1e984411eb3a6f317e2d58908cac 100644 (file)
@@ -15,8 +15,7 @@ use Sys::Hostname;
 use Sub::Quote 2.005000;
 use Sub::Name;
 use Socket qw(AF_INET inet_aton);
-use File::Spec::Functions qw(catfile);
-use File::Slurper qw(read_text);
+use Mojo::File qw(path);
 use English qw(-no_match_vars);
 use Bugzilla::Quantum::Stdout;
 use Bugzilla::Constants qw(bz_locations USAGE_MODE_BROWSER);
@@ -37,7 +36,7 @@ sub load_all {
 sub load_one {
   my ($class, $name, $file) = @_;
   my $package = __PACKAGE__ . "::$name", my $inner_name = "_$name";
-  my $content = read_text(catfile(bz_locations->{cgi_path}, $file));
+  my $content = path(bz_locations->{cgi_path}, $file)->slurp;
   $content = "package $package; $content";
   untaint($content);
   my %options = (package => $package, file => $file, line => 1, no_defer => 1,);
index 93101330b34c7a3f1df9ff9930f98670cbf21750..a72a440f93ad1bd97aded5769735527e00ef7acb 100644 (file)
@@ -35,7 +35,6 @@ use Digest::MD5 qw(md5_hex);
 use File::Basename qw(basename dirname);
 use File::Find;
 use File::Path qw(rmtree mkpath);
-use File::Slurp;
 use File::Spec;
 use IO::Dir;
 use List::MoreUtils qw(firstidx);
index 156ef83d3a84c2df04ec170121efb57305249a34..50f3121e82aa5f0387d647d53634fc2907053767 100755 (executable)
@@ -57,8 +57,6 @@ my %requires = (
   'Email::MIME'                         => '1.904',
   'Email::Send'                         => '1.911',
   'FFI::Platypus'                       => 0,
-  'File::Slurp'                         => '9999.13',
-  'File::Slurper'                       => '0.012',
   'Future'                              => '0.34',
   'HTML::Escape'                        => '1.10',
   'IPC::System::Simple'                 => 0,
index 6d654d68a4f611f55f985ac71e037a37b77ee405..1c9922f6ed6680ddbfb4c40ca15a12a84b92d30f 100644 (file)
@@ -57,8 +57,8 @@ use List::Util qw(first);
 use Scalar::Util qw(blessed);
 use Sys::Syslog qw(:DEFAULT);
 use Text::Balanced qw( extract_bracketed extract_multiple );
-use File::Slurp qw(read_file);
-use JSON::XS;
+use JSON::MaybeXS;
+use Mojo::File qw(path);
 
 use Bugzilla::Extension::BMO::Constants;
 use Bugzilla::Extension::BMO::FakeBug;
@@ -2594,9 +2594,9 @@ sub install_filesystem {
     # version.json needs to have a source attribute pointing to
     # our repository. We already have this information in the (static)
     # contribute.json file, so parse that in
-    my $json = JSON::XS->new->pretty->utf8->canonical();
+    my $json = JSON::MaybeXS->new->pretty->utf8->canonical();
     my $contribute = eval {
-        $json->decode(scalar read_file(bz_locations()->{cgi_path} . "/contribute.json"));
+        $json->decode(path(bz_locations()->{cgi_path}, "/contribute.json")->slurp);
     };
 
     if (!$contribute) {
index f823fc197dadaf4a8ea66d8a5c405bb5d5d22a58..824c0dc516b9a012022f05720375cdadabb2ee74 100755 (executable)
@@ -28,9 +28,9 @@ use Bugzilla::Mailer;
 use Bugzilla::User;
 use Bugzilla::Util qw(format_time datetime_from);
 use Email::MIME;
-use File::Slurp qw(read_file);
+use Mojo::File qw(path);
 use File::Temp qw(tempfile);
-use JSON qw(encode_json decode_json);
+use Mojo::JSON qw(encode_json decode_json);
 use Sys::Hostname qw(hostname);
 
 Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
@@ -39,7 +39,7 @@ my $DO_NOT_NAG = grep { $_ eq '-d' } @ARGV;
 @ARGV = grep { !/^-/ } @ARGV;
 
 if (my $filename = shift @ARGV) {
-    _send_email(decode_json(scalar read_file($filename)));
+    _send_email(decode_json(path($filename)->slurp));
     exit;
 }
 
index ca3329022773da6cc1db97559f06af18f65e395d..9a72f01231db3108ef07064fcdc35644d9fc46f9 100755 (executable)
@@ -17,7 +17,7 @@ use Bugzilla::Config qw( :admin );
 use Bugzilla::Constants;
 use Bugzilla::Install::Localconfig;
 
-use File::Slurp;
+use Mojo::File qw(path);
 
 Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
 
@@ -28,7 +28,7 @@ die "Syntax: $0 param_name param_value\n" unless defined($param_value);
 die "Invalid param name: $param_name\n" unless exists $localconfig->{$param_name};
 
 if ($localconfig->{$param_name} ne $param_value) {
-    my @file = read_file('localconfig');
+    my @file = split(/\n/, path('localconfig')->slurp);
     my $updated = 0;
     foreach my $line (@file) {
         next unless $line =~ /^\s*\$([\w_]+)\s*=\s*'([^']*)'/;
@@ -39,7 +39,7 @@ if ($localconfig->{$param_name} ne $param_value) {
             $updated = 1;
         }
     }
-    write_file('localconfig', @file) if $updated;
+    path('localconfig')->spurt(join("\n", @file)) if $updated;
 } else {
     print "'$param_name' is already '$param_value'\n";
 }
diff --git a/t/css.t b/t/css.t
index a64cadea6f3f329eb8b755881350d2b17051cf1f..1d08ce154422bde4a144a41f8d2a0883ca02bb93 100644 (file)
--- a/t/css.t
+++ b/t/css.t
@@ -9,7 +9,7 @@ use warnings;
 use 5.10.1;
 use lib qw( . lib local/lib/perl5 );
 use File::Spec;
-use File::Slurp qw(read_file);
+use Mojo::File qw(path);
 use File::Find qw(find);
 use Cwd qw(realpath cwd);
 use Test::More;
@@ -21,7 +21,7 @@ find(
         wanted => sub {
             if (/\.css$/) {
                 my $css_file = $File::Find::name;
-                my $content = read_file($_);
+                my $content = path($_)->slurp;
                 while ($content =~ m{url\(["']?([^\?\)"']+)(?:\?.+)?['"]?\)}g) {
                     my $file = $1;
                     my $file_rel_root = File::Spec->abs2rel(realpath(File::Spec->rel2abs($file)), $root);