U4-7038 - Create IPublishedContentWithKey and include the GUID (Key) in the umbraco.config file

Created by Shannon Deminick 28 Aug 2015, 10:31:44 Updated by Shannon Deminick 08 Sep 2015, 16:33:59

Relates to: U4-5271

Relates to: U4-6674

(as discussed on slack)

We want to include the GUID of a document in the cache file so that we can have it in IPublishedContentWithKey (which is an implementation of IPublishedContent). We'll create an extension method GetKey on IPublishedContent, to check if the current implementation is IPublishedContentWithKey and can retrieve the key.

We should also consider having this for media too which means ensuring that the GUID is indexed.

Then need to consider how long this will take and if this affects upgrades and backwards compat.


Stephan 01 Sep 2015, 13:03:28

Have pushed 7848ea5ec0e7b80ce748791bf54fcc3953564d1e (for content) and dfbdf99bbc066bbd39f69762b9137d3e09454ff2 (for media) that provide IPublishedContentWithKey. Will document how it's done below.

NOTE for the time being, there is no migration and the key is ''not'' added to the Xml index nor the Examine media index during the upgrade. One has to manually rebuild them to get the key in there. In the meantime, content.GetKey() should return Guid.Empty. Whether we need a (potentially heavy) migration is up for discussion.

Now running tests to ensure nothing is broken.

Stephan 01 Sep 2015, 13:15:28

How it's done:

*new interface IPublishedContentWithKey implements existing interface IPublishedContent. *new class PublishedContentWithKeyBase inherits existing class PublishedContentBase and implements IPublishedContentWithKey *our internal XmlPublishedContent, PublishedMediaCache.DictionaryPublishedContent and MemberPublishedContent now inherit from PublishedContentWithKeyBase (was PublishedContentBase) *plumbing is in place so the "key" attribute is added to Xml and Examine, then back into our content and media *if "key" is missing, then we use Guid.Empty - there is no migration to rebuild indexes

Also: *new class PublishedContentWithKeyWrapped inherits PublishedContentWrapped and implements IPublishedContentWithKey *new class PublishedContentWithKeyExtended inherits PublishedContentExtended and implements IPublishedContentWithKey *new class PublishedContentWithKeyModel inherits PublishedContentModel and implements IPublishedContentWithKey

That way, backward compatibility is preserved: whenever we had a PublishedContentExtended (which inherits from PublishedContentWrapped) we now have a PublishedContentWithKeyExtended, which still inherits from PublishedContentExtended and PublishedContentWrapped. Same for models. Casts that worked still work.

When extending a content via PublishedContentExtended.Extend, we figure out whether we're extending something implementing IPublishedContentWithKey, and then extend using PublishedContentWithKeyExtended.

(of course, see U4-6674, we plan to simplify wrapped/extended/models in v8)

Shannon Deminick 08 Sep 2015, 16:33:54

Great! Just tested transferring content with courier after saving and the xml file is updated correctly in both environments :) I also verified it gets put into the index.

Priority: Normal

Type: Task

State: Fixed

Assignee: Stephan

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.3.0


Story Points: