Skip to main content

Architecture

Sitecore 8. Developer’s Notes – Part 1

Taking Notes@1x.jpg

[su_note note_color=”#fafafa”]Unlike my usual blog posts where I pick a subject and dig deep, this one is a broad collection of notes that I’ve recorded since I started exploring Sitecore 8 and playing with SCORE and FakeDb in it. Like many Sitecore enthusiasts I just couldn’t help it and got my hands on it the minute it was available for download.[/su_note]

In no particular order:

Pipeline-based Item Provider

Here’s a good overview of the Sitecore Data Architecture. I have built data providers before and we’ve built a fake Sitecore database on the Data Engine’s commands level (here) too so I guess I can say I know a thing or two about how it works.

In Sitecore 8:

<itemManager defaultProvider="pipelineBased">
  <providers>
    <clear/>
    <add name="pipelineBased"
         type="Sitecore.Data.Managers.PipelineBasedItemProvider, Sitecore.Kernel"
         fallbackProvider="default"/>
    <add name="default" type="Sitecore.Data.Managers.ItemProvider, Sitecore.Kernel"/>
  </providers>
</itemManager>
[...]
<group name="itemProvider" groupName="itemProvider">
  <pipelines>
    <addFromTemplate/>
    <addVersion/>
    ...
    <copyItem/>
    ...
  </pipelines>
</group>

All provider’s methods are now sent through a generic processing chain that runs the pipeline (if defined and can handle the call) and defaults to the fallback provider otherwise:

    protected virtual TResult ExecuteAndReturnResult(...)
    {
      if (CorePipelineFactory.GetPipeline(pipelineName, pipelineDomain) != null)
      {
        TArgs args = pipelineArgsCreator();
        CorePipeline.Run(pipelineName, (PipelineArgs) args, pipelineDomain);
        if (args.Handled)
        {
          return args.Result;
        }
      }

      return fallbackResult();
    }

Which means you can do a very granular customization on the Item Provider level without taking over the entire thing or having to chain into the Data Providers (which is a black art, I agree with Nick here).

[su_note note_color=”#fafafa”]I believe the technique can be retrofitted to also work in earlier versions of Sitecore but it probably can’t be just ported over. Sitecore 8 introduced a new abstraction Sitecore.Data.Managers.ItemProviderBase that did not exist before. I will mention it again later today.[/su_note]

/bin Folder Explosion

Sitecore 7.5 has a little over 12Mb of Sitecore.* assemblies in 62 files. Sitecore 8 has over 17Mb in … 130 DLLs. It’s thanks to Sitecore Social now bundled together with the core product as well many other new applications (e.g. FxM, Path Analyzer, List Manager, etc.).

Sitecore.Kernel breakup

Another trend that probably contributed to the /bin folder explosion is what seems to be the beginning of Sitecore.Kernel breakup. I noticed a few families of assemblies that are now packaged separately in Sitecore.ExperienceEditor.dll:

  • Sitecore.Shell.Applications.WebEdit.*
  • Sitecore.Shell.Applications.Preview.*
  • Sitecore.Layouts.PageExtenders.*

There’s probably more and that’s why I am seeing it as a trend. The good thing is the namespaces haven’t changed. The thorn is that you have to add new references to find them when building for Sitecore 8. But ultimately it will allow Sitecore product team to innovate on the parts of the platform independently which is a long term win no doubt.

API changes

I am sure there’s many but there’s a particular one I stumbled upon with FakeDb. We happened to have used ItemManager.Provider.CopyItem() in our implementation of the data engine’s copy command and one of my unit tests in SCORE failed with a runtime System.MissingMethodException : Method not found for Sitecore.Data.Managers.ItemManager.get_Provider(). The property is still there but its signature has changed:

In Sitecore 7:

public static ItemProvider Provider { get { ... } }

In Sitecore 8:

public static ItemProviderBase Provider { get { ... } }

A code compiled against 7 won’t run in 8. A fix in our case was very simple. We shouldn’t have used the Provider property anyway so I changed it to a higher level ItemManager.CopyItem() that in turn calls into the provider but happens to maintain its signature unchanged through versions. I guess what I am saying is – progress never comes for free. Do expect API changes.

JSON serialization in Experience Editor

I don’t know exactly what it is yet but I did see the following in the logs:

ERROR Bad JSON escape sequence: A. [...]

And the following in my Experience Editor:

error ocurred

This was reported on my attempt to save a custom field with a special raw value format from Experience Editor. I reproduced it with a Single-Line field and the value of aabb^ccdd. Manipulating the value in Content Editor works fine so I guess I am contacting support (#427759) as it looks like a defect. I will update this post once I hear back from the guys and/or dig deeper into what/why/when the JSON serialization. This use case works flawlessly in 7.5 and older.

[su_note note_color=”#fafafa”]The support team accepted this as a defect and suggested the following fix for the time being:

  1. Open the WebsitesitecoreshellclientSitecoreExperienceEditorCommandsSave.js file
  2. Replace the following line in the execute: function (context) {...} function
    fields[postElements[i].id] =
        Sitecore.ExperienceEditor.Web.encodeHtml(postElements[i].value);
    

    With this line:

    fields[postElements[i].id] =
        Sitecore.ExperienceEditor.Web.encodeHtml(postElements[i].value.replace(/\/g, '\\'));
    

[/su_note]

Update: Fixed in Sitecore 8 Update 2.

[su_divider][/su_divider]

Next time I will write about final layouts and Content Testing (aka Page Test). Stay tuned!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Brian Beckham

As a Sitecore MVP, Brian spends most of his time consulting and architecting software solutions for enterprise-level Sitecore projects.

More from this Author

Follow Us