[Rt-commit] rt branch, 4.2/accessible-class-method, created. rt-4.1.6-206-gbdd9710
Alex Vandiver
alexmv at bestpractical.com
Thu Feb 7 18:56:16 EST 2013
The branch, 4.2/accessible-class-method has been created
at bdd971057bd700aa79f106113276d3b2fb01b987 (commit)
- Log -----------------------------------------------------------------
commit bdd971057bd700aa79f106113276d3b2fb01b987
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Feb 7 18:32:45 2013 -0500
Ensure that ->_Attributes builds them when called as a class method
Prior to 5671e60, ->_Init was guaranteed to have been called prior to
->_accessible, as the former is called during ->new, and the latter
required an instance. When calling it as a class method, that invarient
does not hold, and autovivification causes an empty hash to be used.
This, in turn, causes all column fetches on records of the class to
fail with "___ unimplemented".
Fill the attributes cache using _BuildTableAttributes, if it is not
already.
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 6a44aa2..6167ee7 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -731,8 +731,12 @@ sub _Accessible {
my $self = shift;
my $column = shift;
my $attribute = lc(shift);
- return 0 unless defined ($_TABLE_ATTR->{ref($self) || $self}->{$column});
- return $_TABLE_ATTR->{ref($self) || $self}->{$column}->{$attribute} || 0;
+
+ my $class = ref($self) || $self;
+ $class->_BuildTableAttributes unless ($_TABLE_ATTR->{$class});
+
+ return 0 unless defined ($_TABLE_ATTR->{$class}->{$column});
+ return $_TABLE_ATTR->{$class}->{$column}->{$attribute} || 0;
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list