[Rt-commit] rt branch, 4.2/accessible-class-method, created. rt-4.1.6-206-gb4a47ec

Alex Vandiver alexmv at bestpractical.com
Thu Feb 7 20:18:14 EST 2013


The branch, 4.2/accessible-class-method has been created
        at  b4a47ec0c6b129de0b11988c2dec063bf237b65c (commit)

- Log -----------------------------------------------------------------
commit b4a47ec0c6b129de0b11988c2dec063bf237b65c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Feb 7 18:32:45 2013 -0500

    Ensure that ->_Attributes builds attributes 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 invariant
    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