Changeset 2314

Show
Ignore:
Timestamp:
05/13/08 17:43:45 (6 months ago)
Author:
bchoate
Message:

Weaken category parent/children references cached in a category object. BugId:79687

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-38/lib/MT/Category.pm

    r2275 r2314  
    99use strict; 
    1010use base qw( MT::Object ); 
     11use MT::Util qw( weaken ); 
    1112 
    1213use MT::Blog; 
     
    7677    return $cat->{__path} if exists $cat->{__path}; 
    7778    my $result = $cat->basename; 
     79    my $orig = $cat; 
    7880    do { 
    79         # TODO: uh, does this not mean we cache the resulting path on the 
    80         # root category object instead? 
    8181        $cat = $cat->parent ? __PACKAGE__->load($cat->parent) : undef; 
    8282        $result = join "/", $cat->basename, $result if $cat; 
     
    8484    # caching this information may be problematic IF 
    8585    # parent category basenames are changed. 
    86     $cat->{__path} = $result; 
     86    $orig->{__path} = $result; 
    8787} 
    8888*category_path = \&publish_path; 
     
    9292    return $cat->{__label_path} if exists $cat->{__label_path}; 
    9393    my $result = $cat->label =~ m!/! ? '[' . $cat->label . ']' : $cat->label; 
     94    my $orig = $cat; 
    9495    do { 
    9596        $cat = $cat->parent ? __PACKAGE__->load($cat->parent) : undef; 
     
    99100    # caching this information may be problematic IF 
    100101    # parent category labels are changed. 
    101     $cat->{__label_path} = $result; 
     102    $orig->{__label_path} = $result; 
    102103} 
    103104 
     
    389390    unless ($cat->{__parent_category}) { 
    390391        $cat->{__parent_category} = ($cat->parent) ? $class->load($cat->parent) : undef; 
     392        weaken( $cat->{__parent_category} ); 
    391393    } 
    392394    $cat->{__parent_category}; 
     
    400402        $class->load({ blog_id => $cat->blog_id, 
    401403            parent => $cat->id }); 
     404        weaken( $_ ) foreach @{ $cat->{__children} }; 
    402405    } 
    403406    @{$cat->{__children}};