Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FallbackDisabler is disabled after a call to GlassController.GetRenderingParameters<T>() #18

Closed
seankearney opened this issue Jul 17, 2015 · 2 comments

Comments

@seankearney
Copy link
Member

We are seeing that fallback isn't working after a call to GlassController.GetRenderingParameters()

Glass code goes and creates an in-memory Sitecore item via this and this

Basically – Glass goes and creates a fake, in memory, Sitecore item. This triggers events to be fired in Sitecore. Specifically it triggers the AddingVersion and SavingItem events. It should also trigger the AddedVersion and SavedItem events; it does not fire the last two.

The field fallback module responds to the Adding/Saving events and disables FieldFallback. When it sees Added/Saved it is re-enabled. Being we aren’t seeing the closing events Field Fallback stays disabled!

I’ve registered a bug with Sitecore #442839. Here is a simple script to duplicate Sitecore bug

cc: @mikeedwards83

@seankearney
Copy link
Member Author

Sitecore's response thus far is:

The AddedVersion and SavedItem events are database specific. Because of the creating the item in memory without parent item, it does not appears in the database. That’s why you cannot see these events. If you want to see them, you have to create item with the parent

@seankearney
Copy link
Member Author

A potential workaround for this issue could be to override the GlassController's GetRenderingParameters method.

public class CustomController : GlassController
{
    protected override T GetRenderingParameters<T>()
    {
        // Sitecore bug 442839... we need to manually raise two events until the bug is fixed
        // Field fallback bug - https://github.com/HedgehogDevelopment/sitecore-field-fallback/issues/18
        // https://github.com/mikeedwards83/Glass.Mapper/issues/158

        using (new Sitecore.Data.Events.EventDisabler())
        {
            return base.GetRenderingParameters<T>();
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant