Skip to content

Commit

Permalink
[#314] Went through MT::CMS::Entry to have it use new MT::Asset->asso…
Browse files Browse the repository at this point in the history
…ciation methods.
  • Loading branch information
byrnereese committed Mar 5, 2010
1 parent e41d9cc commit ee1a051
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions lib/MT/CMS/Entry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1434,21 +1434,16 @@ $ao
}
my $seen = ();
foreach my $asset_id (@asset_ids) {
my $obj_asset = MT::ObjectAsset->load({ asset_id => $asset_id, object_ds => 'entry', object_id => $obj->id });
unless ($obj_asset) {
my $obj_asset = new MT::ObjectAsset;
$obj_asset->blog_id($blog_id);
$obj_asset->asset_id($asset_id);
$obj_asset->object_ds('entry');
$obj_asset->object_id($obj->id);
$obj_asset->save;
my $asset = MT->model('asset')->load( $asset_id );
unless ($asset->is_associated( $obj )) {
$asset->associate( $obj, 0 );
}
$seen->{$asset_id} = 1;
}
foreach my $asset_id (keys %{$obj_assets}) {
my $asset = MT->model('asset')->load( $asset_id );
unless ($seen->{$asset_id}) {
my $obj_asset = MT::ObjectAsset->load({ asset_id => $asset_id, object_ds => 'entry', object_id => $obj->id });
$obj_asset->remove;
$asset->unassociate( $obj );
}
}

Expand Down

9 comments on commit ee1a051

@Hiranyaloka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit breaks asset association with pages.

@byrnereese
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on a fix.

@byrnereese
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just pushed to byrnereese/melody/lh-1005-broken-asset-assoc a possible fix for this. I first need someone to test to make sure that associations are properly found for entries and pages. Once this is confirmed, then I will write an upgrade routine that will modify the ObjectAsset table to properly reflect the right object type for each referenced entry/page. Right now they are all hardcoded to "page".

@Hiranyaloka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error on opening page edit form

Internal callback died with: Can't use string ("MT::Asset") as a HASH ref while "strict refs" in use at melody/extlib/Data/ObjectDriver/BaseObject.pm line 404.

@byrnereese
Copy link
Member Author

@byrnereese byrnereese commented on ee1a051 Sep 7, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hiranyaloka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am seeing the association in the Assets widget of the editPage form, and in the "Appears in" widget of the EditAsset form. Same for pages and entries. However, the mt:EntryAssets (or mt:pageAssets) tags are not publishing the assets. The identical code works in an Entry archive but not in a page archive.

Here's the template code I'm using to test the publishing. https://gist.github.com/1199942

@Hiranyaloka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should also note that I am now able to delete the association from the Page Assets widget as well. And I am seeing no errors in Melody or Apache logs during saving and publishing of pages and entries.

@byrnereese
Copy link
Member Author

@byrnereese byrnereese commented on ee1a051 Sep 7, 2011 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hiranyaloka
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated MT/Template/ContextHandlers. Entry associated assets publish. Page-associated assets are not publishing.

Please sign in to comment.