Changeset 1731

Show
Ignore:
Timestamp:
04/02/08 23:27:20 (4 months ago)
Author:
bchoate
Message:

Adding embedded column to MT::ObjectAsset. BugId:71500. Thanks, Tim!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-33/build/mt-dists/default.mk

    r1722 r1731  
    22 
    33PRODUCT_VERSION = 4.15 
    4 SCHEMA_VERSION = 4.0051 
     4SCHEMA_VERSION = 4.0052 
    55API_VERSION = 4.15 
    66 
  • branches/release-33/lib/MT/Entry.pm

    r1618 r1731  
    622622        object_id => $entry->id, 
    623623        blog_id => $entry->blog_id, 
    624         object_ds => $entry->datasource 
     624        object_ds => $entry->datasource, 
     625        embedded => 1, 
    625626    }); 
    626627    my %assets = map { $_->asset_id => $_->id } @assets; 
     
    629630        my $innards = $2; 
    630631 
    631         # is asset exists? 
    632         my $asset = MT->model('asset')->load({ id => $id }) or next; 
    633  
    634632        # reference to an existing asset... 
    635633        if (exists $assets{$id}) { 
    636634            $assets{$id} = 0; 
    637635        } else { 
     636            # is asset exists? 
     637            my $asset = MT->model('asset')->load({ id => $id }) or next; 
     638 
    638639            my $map = new MT::ObjectAsset; 
    639640            $map->blog_id($entry->blog_id); 
     
    641642            $map->object_ds($entry->datasource); 
    642643            $map->object_id($entry->id); 
     644            $map->embedded(1); 
    643645            $map->save; 
    644646            $assets{$id} = 0; 
     
    646648    } 
    647649    if (my @old_maps = grep { $assets{$_->asset_id} } @assets) { 
    648         my @old_ids = map { $_->id } @old_maps; 
    649         MT::ObjectAsset->remove( { id => \@old_ids }); 
     650        my @old_ids = map { $_->id } grep { $_->embedded } @old_maps; 
     651        MT::ObjectAsset->remove( { id => \@old_ids }) 
     652            if @old_ids; 
    650653    } 
    651654    return 1; 
  • branches/release-33/lib/MT/ObjectAsset.pm

    r1523 r1731  
    1818        object_ds => 'string(50) not null', 
    1919        asset_id => 'integer not null', 
     20        embedded => 'boolean', 
    2021    }, 
    2122    indexes => { 
    22         blog_id => 1, 
    23         object_id => 1, 
     23        blog_obj => { 
     24            columns => ['blog_id', 'object_ds', 'object_id'], 
     25        }, 
    2426        asset_id => 1, 
    25         object_ds => 1, 
     27    }, 
     28    defaults => { 
     29        embedded => 0, 
    2630    }, 
    2731    child_of => 'MT::Blog', 
  • branches/release-33/lib/MT/Upgrade.pm

    r1583 r1731  
    548548            priority => 5.1, 
    549549        }, 
     550        'core_migrate_commenter_auth' => { 
     551            code => \&migrate_commenter_auth, 
     552            version_limit => 3.3101, 
     553            priority => 3.1, 
     554        }, 
    550555        'core_deprecate_bitmask_permissions' => { 
    551556            code => \&deprecate_bitmask_permissions, 
     
    557562            version_limit => 4.0002, 
    558563            priority => 3.3, 
    559         }, 
    560         'core_migrate_commenter_auth' => { 
    561             code => \&migrate_commenter_auth, 
    562             version_limit => 3.3101, 
    563             priority => 3.1, 
    564564        }, 
    565565        'core_populate_authored_on' => { 
     
    689689                type => 'author', 
    690690                label => 'Adding new feature widget to dashboard...', 
     691                condition => sub { 
     692                    my ($user) = @_; 
     693                    $user->type == MT::Author::AUTHOR(); # AUTHOR records only 
     694                }, 
    691695                code => sub { 
    692696                    my ($user) = @_; 
     
    703707                    } 
    704708                    $user->widgets($widget_store); 
    705                     $user->save; 
    706709                }, 
    707710            }, 
     
    775778                    } 
    776779                    $blog->page_layout($layout); 
    777                     $blog->save; 
    778780                }, 
    779781            }, 
     
    792794                    my $basename = MT::Util::make_unique_author_basename($author); 
    793795                    $author->basename($basename); 
    794                     $author->save; 
    795796                }, 
    796797            }, 
     
    806807            updater       => { 
    807808                type      => 'entry', 
    808                 label     => 'Assigning entry comment and trackback count...', 
     809                label     => 'Assigning entry comment and TrackBack counts...', 
    809810                condition => sub { 
    810811                    require MT::Comment; 
     
    834835                # it doesn't have the unnecessary save. 
    835836                code => sub { 1; }, 
     837            }, 
     838        }, 
     839        'core_assign_object_embedded' => { 
     840            version_limit => 4.0052, 
     841            priority => 3.2, 
     842            updater => { 
     843                type => 'objectasset', 
     844                label => 'Assigning embedded flag to asset placements...', 
     845                code => sub { 
     846                    $_[0]->embedded(1); 
     847                }, 
     848                sql => 'update mt_objectasset set objectasset_embedded=1', 
    836849            }, 
    837850        },