# HG changeset patch # User Vincent Tondellier # Date 1415738124 -3600 # Node ID 2218a127abd92222b5ef998402c48007f5ae56c4 # Parent 5d34ac405901de62ca535d467711aa276a19ae4b Fix deprecated warnings for Mojo::JSON OO syntax with Mojolicious >= 5.54 diff -r 5d34ac405901 -r 2218a127abd9 lib/CrashTest/Decode/Queue/Gearman.pm --- a/lib/CrashTest/Decode/Queue/Gearman.pm Sun Sep 21 17:30:24 2014 +0200 +++ b/lib/CrashTest/Decode/Queue/Gearman.pm Tue Nov 11 21:35:24 2014 +0100 @@ -13,6 +13,7 @@ package CrashTest::Decode::Queue::Gearman; use Mojo::Base -base; +use Mojo::JSON qw/j/; use Gearman::Client; has [ qw/config gearman/ ]; @@ -30,14 +31,11 @@ sub decode { my ($self, $file, $paramshash, $uuidstr, $cb) = @_; - my $json = Mojo::JSON->new; - my $args = $json->encode( - { - file => $file->slurp, - params => $paramshash, - uuid => $uuidstr - } - ); + my $args = j { + file => $file->slurp, + params => $paramshash, + uuid => $uuidstr + }; $self->gearman->dispatch_background('dump_decode', $args); diff -r 5d34ac405901 -r 2218a127abd9 lib/CrashTest/Decode/Queue/NoQueue.pm --- a/lib/CrashTest/Decode/Queue/NoQueue.pm Sun Sep 21 17:30:24 2014 +0200 +++ b/lib/CrashTest/Decode/Queue/NoQueue.pm Tue Nov 11 21:35:24 2014 +0100 @@ -13,6 +13,7 @@ package CrashTest::Decode::Queue::NoQueue; use Mojo::Base -base; +use Mojo::JSON qw/decode_json/; use File::Temp; has [ qw/config dumper_config storage/ ]; @@ -33,11 +34,9 @@ my $cmd = $self->dumper_config->{JSONStackwalker} . " $dmp_file " . $self->dumper_config->{SymbolsPath}; my $out = qx($cmd 2>/dev/null) or die $!; - my $json = Mojo::JSON->new; - my $pjson = $json->decode($out); + my $pjson = decode_json($out); # Create json for the params - # TODO check for authorised values ... $pjson->{client_info} = $paramshash; $self->storage->store_dump($uuidstr, $file->slurp); diff -r 5d34ac405901 -r 2218a127abd9 lib/CrashTest/Storage/FileSystem.pm --- a/lib/CrashTest/Storage/FileSystem.pm Sun Sep 21 17:30:24 2014 +0200 +++ b/lib/CrashTest/Storage/FileSystem.pm Tue Nov 11 21:35:24 2014 +0100 @@ -14,6 +14,7 @@ package CrashTest::Storage::FileSystem; use Mojo::Base -base; use Mojo::Util qw/slurp spurt/; +use Mojo::JSON qw/j decode_json/; use DateTime; use Data::Page; @@ -86,8 +87,7 @@ my $jsonfilename = File::Spec->catfile($self->data_path, "$uuid.json"); my $json_content = slurp($jsonfilename) or die $!; - my $json = Mojo::JSON->new; - my $processed_data = $json->decode($json_content); + my $processed_data = decode_json($json_content); return $processed_data; } @@ -98,8 +98,7 @@ my $jsonfilename = File::Spec->catfile($self->data_path, "$uuid.json"); my $dmpfilename = File::Spec->catfile($self->data_path, "$uuid.dmp"); - my $json = Mojo::JSON->new; - spurt($json->encode($pjson), $jsonfilename) or die $!; + spurt(j($pjson), $jsonfilename) or die $!; # Set time of the .dmp to the CrashTime my $crashtime = $pjson->{client_info}->{CrashTime}; diff -r 5d34ac405901 -r 2218a127abd9 lib/CrashTest/Storage/Sql.pm --- a/lib/CrashTest/Storage/Sql.pm Sun Sep 21 17:30:24 2014 +0200 +++ b/lib/CrashTest/Storage/Sql.pm Tue Nov 11 21:35:24 2014 +0100 @@ -13,6 +13,7 @@ package CrashTest::Storage::Sql; use Mojo::Base "CrashTest::Storage::FileSystem"; +use Mojo::JSON qw/j/; use DateTime; use CrashTest::Storage::Sql::Schema; @@ -59,7 +60,6 @@ sub _db_insert_processed_data { my ($self, $uuid, $pjson) = @_; - my $json = Mojo::JSON->new; $self->{schema}->txn_do(sub { my $crash = $self->{schema}->resultset('CrashReport')->new({ uuid => $uuid }); @@ -96,7 +96,7 @@ $user->{cpu_arch} = $pjson->{system_info}->{cpu_arch}; $user->{cpu_count} = $pjson->{system_info}->{cpu_count}; $user->{os} = $pjson->{system_info}->{os}; - $user->{extra_info} = $json->encode($pjson->{client_info}); + $user->{extra_info} = j($pjson->{client_info}); $crash->crash_user($self->{schema}->resultset('CrashUser')->new($user)); }