[Rt-commit] rt branch, 4.2/remove-deprecations, updated. rt-4.0.6-459-g529fa7a
Thomas Sibley
trs at bestpractical.com
Thu Aug 16 19:45:53 EDT 2012
The branch, 4.2/remove-deprecations has been updated
via 529fa7a722867474d31745710fb6935b8abee54e (commit)
from fcab7d5f79f09bfaca34c3c5ad787e132053dbfb (commit)
Summary of changes:
docs/UPGRADING-4.2 | 4 ++++
etc/RT_Config.pm.in | 17 -----------------
lib/RT/Ticket.pm | 2 --
t/ticket/linking.t | 35 +++++++++++++++--------------------
4 files changed, 19 insertions(+), 39 deletions(-)
- Log -----------------------------------------------------------------
commit 529fa7a722867474d31745710fb6935b8abee54e
Author: Thomas Sibley <trs at bestpractical.com>
Date: Thu Aug 16 16:21:58 2012 -0700
Remove support for $LinkTransactionsRun1Scrip
The option was initially added to provide backwards compatible behaviour
for 3.4. We've been recording two link transactions since 3.4.5 and
running scrips on both by default since 3.8.0. Anyone relying on this
option can adjust their scrips to ignore one of the transactions.
The test file required more adjusting than I would have preferred since
it was written around the assumption of toggling this option. In the
process of making it pass, I removed the confusing cumulative behaviour
of link_count() by having it reset whenever called. I also fixed a
minor test bug which called AddLink when it meant to call DeleteLink
(line 170 in the new file).
diff --git a/docs/UPGRADING-4.2 b/docs/UPGRADING-4.2
index 66af083..322c483 100644
--- a/docs/UPGRADING-4.2
+++ b/docs/UPGRADING-4.2
@@ -4,3 +4,7 @@ UPGRADING FROM RT 4.0.0 and greater
describes what the log level controls. Setting $LogToScreen will still work,
but an informational notice will be issued on server start telling you about
the rename. To avoid this you should set $LogToSTDERR instead.
+
+* $LinkTransactionsRun1Scrip is removed. If you were relying on this behaviour
+ (by setting it to 1), you should adjust your scrips to ignore one of the link
+ transactions.
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index be968a2..abd7606 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -2678,21 +2678,4 @@ Set($StatementLog, undef);
=back
-
-
-
-=head1 Deprecated options
-
-=over 4
-
-=item C<$LinkTransactionsRun1Scrip>
-
-RT-3.4 backward compatibility setting. Add/Delete Link used to record
-one transaction and run one scrip. Set this value to 1 if you want
-only one of the link transactions to have scrips run.
-
-=cut
-
-Set($LinkTransactionsRun1Scrip, 0);
-
1;
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 4735248..69c1242 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -2314,7 +2314,6 @@ sub DeleteLink {
Field => $direction eq 'Target' ? $LINKDIRMAP{$args{'Type'}}->{Base}
: $LINKDIRMAP{$args{'Type'}}->{Target},
OldValue => $self->URI,
- ActivateScrips => !RT->Config->Get('LinkTransactionsRun1Scrip'),
TimeTaken => 0,
);
$RT::Logger->error("Couldn't create transaction: $Msg") unless $val;
@@ -2446,7 +2445,6 @@ sub _AddLink {
Field => $direction eq 'Target' ? $LINKDIRMAP{$args{'Type'}}->{Base}
: $LINKDIRMAP{$args{'Type'}}->{Target},
NewValue => $self->URI,
- ActivateScrips => !RT->Config->Get('LinkTransactionsRun1Scrip'),
TimeTaken => 0,
);
$RT::Logger->error("Couldn't create transaction: $msg") unless $val;
diff --git a/t/ticket/linking.t b/t/ticket/linking.t
index 1bd83d6..20f63f5 100644
--- a/t/ticket/linking.t
+++ b/t/ticket/linking.t
@@ -17,9 +17,6 @@ my $filename = File::Spec->catfile( RT::Test->temp_directory, 'link_count' );
open my $fh, '>', $filename or die $!;
close $fh;
-my $link_scrips_orig = RT->Config->Get( 'LinkTransactionsRun1Scrip' );
-RT->Config->Set( 'LinkTransactionsRun1Scrip', 1 );
-
my $link_acl_checks_orig = RT->Config->Get( 'StrictLinkACL' );
RT->Config->Set( 'StrictLinkACL', 1);
@@ -125,8 +122,8 @@ diag('Create tickets with rights checks on one end of a link');
$child->CurrentUser( RT->SystemUser );
is($child->_Links('Base')->Count, 1, 'link was created');
is($child->_Links('Target')->Count, 0, 'link was created only one');
- # no scrip run on second ticket accroding to config option
- is(link_count($filename), undef, "scrips ok");
+ # only one scrip run (on second ticket) since this is on a ticket Create txn
+ is(link_count($filename), 1, "scrips ok");
RT->Config->Set( StrictLinkACL => 1 );
}
@@ -144,7 +141,7 @@ diag('try to add link without rights');
ok($id,$msg);
($id, $msg) = $child->AddLink(Type => 'MemberOf', Target => $parent->id);
ok(!$id, $msg);
- is(link_count($filename), undef, "scrips ok");
+ is(link_count($filename), 0, "scrips ok");
$child->CurrentUser( RT->SystemUser );
is($child->_Links('Base')->Count, 0, 'link was not created, no permissions');
is($child->_Links('Target')->Count, 0, 'link was not create, no permissions');
@@ -162,7 +159,7 @@ diag('add link with rights only on base');
ok($id,$msg);
($id, $msg) = $child->AddLink(Type => 'MemberOf', Target => $parent->id);
ok($id, $msg);
- is(link_count($filename), 1, "scrips ok");
+ is(link_count($filename), 2, "scrips ok");
$child->CurrentUser( RT->SystemUser );
is($child->_Links('Base')->Count, 1, 'link was created');
is($child->_Links('Target')->Count, 0, 'link was created only one');
@@ -170,9 +167,9 @@ diag('add link with rights only on base');
# turn off feature and try to delete link, we should fail
RT->Config->Set( StrictLinkACL => 1 );
- ($id, $msg) = $child->AddLink(Type => 'MemberOf', Target => $parent->id);
+ ($id, $msg) = $child->DeleteLink(Type => 'MemberOf', Target => $parent->id);
ok(!$id, $msg);
- is(link_count($filename), 1, "scrips ok");
+ is(link_count($filename), 0, "scrips ok");
$child->CurrentUser( RT->SystemUser );
$child->_Links('Base')->_DoCount;
is($child->_Links('Base')->Count, 1, 'link was not deleted');
@@ -182,7 +179,7 @@ diag('add link with rights only on base');
RT->Config->Set( StrictLinkACL => 0 );
($id, $msg) = $child->DeleteLink(Type => 'MemberOf', Target => $parent->id);
ok($id, $msg);
- is(link_count($filename), 0, "scrips ok");
+ is(link_count($filename), -2, "scrips ok");
$child->CurrentUser( RT->SystemUser );
$child->_Links('Base')->_DoCount;
is($child->_Links('Base')->Count, 0, 'link was deleted');
@@ -217,7 +214,7 @@ ok ($id,$msg);
ok ($id,$msg);
($id,$msg) = $ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id);
ok($id,$msg);
-is(link_count($filename), 1, "scrips ok");
+is(link_count($filename), 2, "scrips ok");
warnings_like {
($id,$msg) = $ticket->AddLink(Type => 'RefersTo', Target => -1);
@@ -228,7 +225,7 @@ warnings_like {
($id,$msg) = $ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id);
ok($id,$msg);
-is(link_count($filename), 1, "scrips ok");
+is(link_count($filename), 0, "scrips ok"); # already added
my $transactions = $ticket2->Transactions;
$transactions->Limit( FIELD => 'Type', VALUE => 'AddLink' );
@@ -238,21 +235,19 @@ is( $transactions->First->NewValue , $ticket->URI );
($id,$msg) = $ticket->DeleteLink(Type => 'RefersTo', Target => $ticket2->id);
ok($id,$msg);
-is(link_count($filename), 0, "scrips ok");
+is(link_count($filename), -2, "scrips ok");
$transactions = $ticket2->Transactions;
$transactions->Limit( FIELD => 'Type', VALUE => 'DeleteLink' );
is( $transactions->Count, 1, "Transaction found in other ticket" );
is( $transactions->First->Field , 'ReferredToBy');
is( $transactions->First->OldValue , $ticket->URI );
-RT->Config->Set( LinkTransactionsRun1Scrip => 0 );
-
($id,$msg) =$ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id);
ok($id,$msg);
is(link_count($filename), 2, "scrips ok");
($id,$msg) =$ticket->DeleteLink(Type => 'RefersTo', Target => $ticket2->id);
ok($id,$msg);
-is(link_count($filename), 0, "scrips ok");
+is(link_count($filename), -2, "scrips ok");
# tests for silent behaviour
($id,$msg) = $ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id, Silent => 1);
@@ -287,7 +282,7 @@ is(link_count($filename), 1, "scrips ok");
}
($id,$msg) =$ticket->DeleteLink(Type => 'RefersTo', Target => $ticket2->id, SilentBase => 1);
ok($id,$msg);
-is(link_count($filename), 0, "scrips ok");
+is(link_count($filename), -1, "scrips ok");
($id,$msg) = $ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id, SilentTarget => 1);
ok($id,$msg);
@@ -303,11 +298,10 @@ is(link_count($filename), 1, "scrips ok");
}
($id,$msg) =$ticket->DeleteLink(Type => 'RefersTo', Target => $ticket2->id, SilentTarget => 1);
ok($id,$msg);
-is(link_count($filename), 0, "scrips ok");
+is(link_count($filename), -1, "scrips ok");
# restore
-RT->Config->Set( LinkTransactionsRun1Scrip => $link_scrips_orig );
RT->Config->Set( StrictLinkACL => $link_acl_checks_orig );
{
@@ -388,8 +382,9 @@ sub link_count {
open( my $fh, '<', $file ) or die "couldn't open $file";
my $data = <$fh>;
close $fh;
+ truncate($file, 0);
- return undef unless $data;
+ return 0 unless defined $data;
chomp $data;
return $data + 0;
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list