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

Alex Vandiver alexmv at bestpractical.com
Thu Feb 7 21:26:02 EST 2013


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

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

    Ensure that ->_Accessible 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