[Rt-commit] rt branch, 4.0/perl-5.18-compat, updated. rt-4.0.12-34-g8447e8b
? sunnavy
sunnavy at bestpractical.com
Tue Jun 18 12:20:04 EDT 2013
The branch, 4.0/perl-5.18-compat has been updated
via 8447e8b59192ceedf65d401a394d5d9bfe4d3039 (commit)
via 37f0d7e42a413359b5c78057ddc09775694f6fca (commit)
from 1c288588e668fc3c21fd41b7eed8568fdb9c61c4 (commit)
Summary of changes:
lib/RT/Config.pm | 1 +
share/html/REST/1.0/Forms/group/default | 7 +++++--
share/html/REST/1.0/Forms/queue/default | 7 +++++--
share/html/REST/1.0/Forms/ticket/default | 6 +++++-
share/html/REST/1.0/Forms/user/default | 7 +++++--
5 files changed, 21 insertions(+), 7 deletions(-)
- Log -----------------------------------------------------------------
commit 37f0d7e42a413359b5c78057ddc09775694f6fca
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu May 30 23:32:10 2013 +0800
REST fix: show updated message as long as the object is updated.
previously, we only check if the last update succeeded or not, which is not
that right.
without this, t/web/command_line.t will fail on perl 5.18.0 because of the new
*random* results of hash's keys().
diff --git a/share/html/REST/1.0/Forms/group/default b/share/html/REST/1.0/Forms/group/default
index 8867bf9..8a7a524 100644
--- a/share/html/REST/1.0/Forms/group/default
+++ b/share/html/REST/1.0/Forms/group/default
@@ -156,7 +156,7 @@ if (%data == 0) {
}
else {
my ($get, $set, $key, $val, $n, $s);
-
+ my $updated;
foreach $key (keys %data) {
$val = $data{$key};
$key = lc $key;
@@ -192,9 +192,12 @@ else {
$k = $changes;
}
}
+ else {
+ $updated ||= 1;
+ }
}
- push(@comments, "# Group $id updated.") unless $n == 0;
+ push(@comments, "# Group $id updated.") if $updated;
}
DONE:
diff --git a/share/html/REST/1.0/Forms/queue/default b/share/html/REST/1.0/Forms/queue/default
index 58bb899..9aa42f8 100644
--- a/share/html/REST/1.0/Forms/queue/default
+++ b/share/html/REST/1.0/Forms/queue/default
@@ -146,7 +146,7 @@ if ( keys %data == 0) {
}
else {
my ($get, $set, $key, $val, $n, $s);
-
+ my $updated;
foreach $key (keys %data) {
$val = $data{$key};
$key = lc $key;
@@ -175,9 +175,12 @@ else {
$k = $changes;
}
}
+ else {
+ $updated ||= 1;
+ }
}
- push(@comments, "# Queue $id updated.") unless $n == 0;
+ push(@comments, "# Queue $id updated.") if $updated;
}
DONE:
diff --git a/share/html/REST/1.0/Forms/ticket/default b/share/html/REST/1.0/Forms/ticket/default
index 046cc25..5279292 100644
--- a/share/html/REST/1.0/Forms/ticket/default
+++ b/share/html/REST/1.0/Forms/ticket/default
@@ -279,6 +279,7 @@ if (!keys(%data)) {
}
else {
my ($get, $set, $key, $val, $n, $s);
+ my $updated;
foreach $key (keys %data) {
$val = $data{$key};
@@ -469,8 +470,11 @@ else {
$k = $changes;
}
}
+ else {
+ $updated ||= 1;
+ }
}
- push(@comments, "# Ticket ".$ticket->id." updated.") unless $n == 0;
+ push(@comments, "# Ticket ".$ticket->id." updated.") if $updated;
}
DONE:
diff --git a/share/html/REST/1.0/Forms/user/default b/share/html/REST/1.0/Forms/user/default
index c112636..f12dd0c 100644
--- a/share/html/REST/1.0/Forms/user/default
+++ b/share/html/REST/1.0/Forms/user/default
@@ -136,7 +136,7 @@ if (keys %data == 0) {
}
else {
my ($get, $set, $key, $val, $n, $s);
-
+ my $updated;
foreach $key (keys %data) {
$val = $data{$key};
$key = lc $key;
@@ -177,9 +177,12 @@ else {
$k = $changes;
}
}
+ else {
+ $updated ||= 1;
+ }
}
- push(@comments, "# User $id updated.") unless $n == 0;
+ push(@comments, "# User $id updated.") if $updated;
}
DONE:
commit 8447e8b59192ceedf65d401a394d5d9bfe4d3039
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jun 18 23:23:09 2013 +0800
compare ref type first to make sure $entry_ref is not weirdly overloaded
one snippet:
use Math::BigInt;
no strict 'refs';
# $round_mode = bless( do{\(my $o = 'even')}, 'Math::BigInt' );
my $round_mode = *{'Math::BigInt::round_mode'}{SCALAR};
print 'ok' if $round_mode;
because Math::BigInt overloads "bool" operation, the "if $round_mode" dies
with message "Not a HASH reference".
we do similar GLOB thing in RT::Config::__GetNameByRef, but before perl 5.18,
we can always find the right Name before checking "Math::Big::Int::round_mode"
thanks to the consistent hash's keys() behavior.
hash's keys() behavior has been changed since perl 5.18:
Hash randomization
The seed used by Perl's hash function is now random. This means that the
order which keys/values will be returned from functions like "keys()",
"values()", and "each()" will differ from run to run.
i.e. we might reach "Math::Big::Int::round_mode" in RT::Config::__GetNameByRef
since perl 5.18, so we need to make sure it won't die, that's the reason we do
the extra check before the "bool" operation("next unless $entry_ref;")
Math::BigInt is require by GnuPG::Interface.
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index e06945a..b1319c0 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1220,6 +1220,7 @@ sub SetFromConfig {
$ref_type = 'SCALAR' if $ref_type eq 'REF';
my $entry_ref = *{$entry}{ $ref_type };
+ next if ref $entry_ref && ref $entry_ref ne ref $ref;
next unless $entry_ref;
# if references are equal then we've found
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list