Skip to content

Commit

Permalink
fixed a hash reference for perl versions less than 5.14
Browse files Browse the repository at this point in the history
removed $version reference from ia7_collection_upgrader
removed a sort from json_server.pl to slightly optimize
  • Loading branch information
hplato committed Jul 24, 2016
1 parent 856b9df commit 2025097
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions code/common/ia7_collection_upgrader.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Category = IA7

#@ IA7 v1.2 : This is a helper utility that can find and update collections.json files
#@ IA7 Collection Updater v1.3 : This is a helper utility that can find and update collections.json files
#@ if any structural changes are required.
#@
#@ v1.2 - add in new login system id 700
Expand Down Expand Up @@ -35,14 +35,14 @@
}
push (@{$json_data->{500}->{children}},700) unless ($found);
$json_data->{meta}->{version} = "1.2";
print_log "[IA7_Collection_Updater] : Checking $file to version $ia7_coll_current_ver";
print_log "[IA7_Collection_Updater] : Updating $file to version 1.2";
$updated = 1;
}
if ($updated) {
my $json_newdata = to_json($json_data, {utf8 => 1, pretty => 1});
my $backup_file = $file . ".v" . $version . ".backup";
my $backup_file = $file . ".t" . int( ::get_tickcount() / 1000 ) . ".backup";
file_write($backup_file,$file_data);
print_log "[IA7_Collection_Updater] : Saved backup " . $file . ".v" . $version . ".backup";
print_log "[IA7_Collection_Updater] : Saved backup " . $file . ".t" . int( ::get_tickcount() / 1000 ) . ".backup";
file_write($file,$json_newdata);
}
}
Expand Down
12 changes: 8 additions & 4 deletions lib/json_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ =head2 METHODS
=cut

#NOTE: Removed sort from line 454 for optimization.

use strict;

use RRDTool::Rawish;
Expand Down Expand Up @@ -215,8 +217,8 @@ sub json_get {
print_log
"Json_Server.pl: Client override section for $Http{Client_address} found";
for my $key (
keys $json_data{'ia7_config'}->{clients}
->{ $Http{Client_address} } )
keys %{$json_data{'ia7_config'}->{clients}
->{ $Http{Client_address} }} )
{
print_log
"Json_Server.pl: Client key=$key, value = $json_data{'ia7_config'}->{clients}->{$Http{Client_address}}->{$key}";
Expand Down Expand Up @@ -450,7 +452,8 @@ sub json_get {
push @objects, &list_objects_by_type($object_type);
}
}
foreach my $o ( map { &get_object_by_name($_) } sort @objects ) {
# foreach my $o ( map { &get_object_by_name($_) } sort @objects ) {
foreach my $o ( map { &get_object_by_name($_) } @objects ) {
next unless $o;
my $name = $o;
$name = $o->{object_name};
Expand Down Expand Up @@ -1033,14 +1036,15 @@ sub json_page {
my ($json_raw) = @_;
my $json;

#utf8::encode( $json_raw ); #may need to wrap gzip in an eval and encode it if errors develop. It crashes if a < is in the text
## utf8::encode( $json_raw ); #may need to wrap gzip in an eval and encode it if errors develop. It crashes if a < is in the text
gzip \$json_raw => \$json;
my $output = "HTTP/1.0 200 OK\r\n";
$output .= "Server: MisterHouse\r\n";
$output .= "Content-type: application/json\r\n";
$output .= "Content-Encoding: gzip\r\n";
$output .= "\r\n";
$output .= $json;
## $output .= $json_raw;

return $output;
}
Expand Down

0 comments on commit 2025097

Please sign in to comment.