[Rt-commit] rt branch 5.0/current-user-circular-refs created. rt-5.0.4-7-gb7b820d316
BPS Git Server
git at git.bestpractical.com
Thu May 18 14:03:43 UTC 2023
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/current-user-circular-refs has been created
at b7b820d3165ca2e4b4325e79b5c3a589d2197556 (commit)
- Log -----------------------------------------------------------------
commit b7b820d3165ca2e4b4325e79b5c3a589d2197556
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu May 18 21:32:51 2023 +0800
Create a new object to avoid circular references that happen on RT::CurrentUser
RT::CurrentUser inherits from RT::User, so it caches stuff just like
RT::User and other RT objects, including PrincipalObj, Attributes,
CreatorObj, LastUpdatedByObj, etc. All these cached objects are
created with current user's CurrentUser method.
Previously this caused circular references, e.g. $u is an
RT::CurrentUser object, then:
$u -> $u->{_principal_obj} -> $u->{_principal_obj}{user} -> $u
This commit tweaks CurrentUser's CurrentUser method to generate a new
object instead of using itself to get around this issue.
diff --git a/lib/RT/CurrentUser.pm b/lib/RT/CurrentUser.pm
index 02b3c7ee49..9482c2272a 100644
--- a/lib/RT/CurrentUser.pm
+++ b/lib/RT/CurrentUser.pm
@@ -270,7 +270,12 @@ Return the current currentuser object
=cut
sub CurrentUser {
- return shift;
+ my $self = shift;
+ if ( !$self->{user} ) {
+ $self->{user} = RT::CurrentUser->new();
+ $self->{user}->Load($self->Id);
+ }
+ return $self->{user};
}
sub CustomFieldLookupType {
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list