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

unicorn ignoring config when programmatically creating items or publishing #33

Closed
tommyhawk520 opened this issue Oct 10, 2014 · 9 comments

Comments

@tommyhawk520
Copy link

I have unicorn 2.0.4 set up in sitecore 7.2, the config is standard but i have added a few extra include and exclude rules. unicorn seems to ignore the exclude rules when i publish an item or create it programmatically. if i just create an item in content editor it doesnt get created

@kamsar
Copy link
Collaborator

kamsar commented Oct 10, 2014

Can you attach your config and an example scenario where excludes aren't working?

On Oct 10, 2014, at 2:29 AM, tommyhawk520 notifications@github.com wrote:

I have unicorn 2.0.4 set up in sitecore 7.2, the config is standard but i have added a few extra include and exclude rules. unicorn seems to ignore the exclude rules when i publish an item or create it programmatically. if i just create an item in content editor it doesnt get created


Reply to this email directly or view it on GitHub.

@RaYell
Copy link

RaYell commented Oct 14, 2014

I've noticed the same behavior with the Schedule definition. I have <exclude path="/sitecore/system/Tasks/Schedules" /> in my config but whenever a schedule item is updated by Sitecore (when the LastRun field value changes) a corresponding item is created on the disk. I've also tried excluding the same item based on template id but it behaves exactly the same.

@tommyhawk520
Copy link
Author

this is my config...

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <unicorn>
            <configurations>
                <configuration name="Default Configuration">
                    <predicate type="Unicorn.Predicates.SerializationPresetPredicate, Unicorn" singleInstance="true">
            <include database="core" path="/sitecore/system/Field types"/>
            <include database="core" path="/sitecore/system/Settings" />
            <include database="core" path="/sitecore/content/Documents and settings/All users"/>
            <include database="core" path="/sitecore/content/Applications"/>
            <include database="master" path="/sitecore/templates/Personalization Tracker" />
            <include database="master" path="/sitecore/templates/Redirect Module" />
            <include database="master" path="/sitecore/templates/Web Forms for Marketers" />
            <include database="master" path="/sitecore/templates/modules" />
            <include database="master" path="/sitecore/templates/System/Modules"/>
            <include database="master" path="/sitecore/templates/Branches"/>
            <include database="master" path="/sitecore/content/audi">
              <exclude path="/sitecore/content/audi/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/bmw">
              <exclude path="/sitecore/content/bmw/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/jaguar">
              <exclude path="/sitecore/content/jaguar/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/experience explorer"/>
            <include database="master" path="/sitecore/content/test">
              <exclude path="/sitecore/content/test/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/vw">
              <exclude path="/sitecore/content/vw/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/toyota">
              <exclude path="/sitecore/content/toyota/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/mini">
              <exclude path="/sitecore/content/mini/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/mercedesbenz">
              <exclude path="/sitecore/content/mercedesbenz/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/lexus">
              <exclude path="/sitecore/content/lexus/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/content/landrover">
              <exclude path="/sitecore/content/landrover/home/vehicles" />
            </include>
            <include database="master" path="/sitecore/Media Library"/>
            <include database="master" path="/sitecore/layout"/>
            <include database="master" path="/sitecore/system">
              <exclude path="/sitecore/system/Aliases"/>
              <exclude path="/sitecore/system/Marketing Center"/>
              <exclude path="/sitecore/system/Publishing targets" />
              <exclude path="/sitecore/system/Modules/Web Forms for Marketers/Website" />
              <exclude path="/sitecore/system/Modules/Web Forms for Marketers/Local Forms" />
              <exclude path="/sitecore/system/Modules/Web Forms for Marketers/Sample forms" />
              <exclude path="/sitecore/system/Modules/Azure" />
            </include>
          </predicate>
        </configuration>
      </configurations>
            <defaults>
                <sourceDataProvider type="Unicorn.Data.SitecoreSourceDataProvider, Unicorn" singleInstance="true" />

                <evaluator type="Unicorn.Evaluators.SerializedAsMasterEvaluator, Unicorn" singleInstance="true" />
                    <evaluatorLogger type="Unicorn.Evaluators.DefaultSerializedAsMasterEvaluatorLogger, Unicorn" singleInstance="true" />

                <predicate type="null" />

                <fieldPredicate type="Unicorn.Predicates.ConfigurationFieldPredicate, Unicorn" singleInstance="true">
                </fieldPredicate>

                <loaderLogger type="Unicorn.Loader.DefaultSerializationLoaderLogger, Unicorn" singleInstance="true" />

                <loaderConsistencyChecker type="Unicorn.Loader.DuplicateIdConsistencyChecker, Unicorn" />
                    <loaderConsistencyCheckerLogger type="Unicorn.Loader.DefaultDuplicateIdConsistencyCheckerLogger, Unicorn" singleInstance="false" />

                <loaderDeserializeFailureRetryer type="Unicorn.Loader.DeserializeFailureRetryer, Unicorn" singleInstance="false" />

                <serializationProvider type="Unicorn.Serialization.Sitecore.Fiat.FiatSitecoreSerializationProvider, Unicorn" rootPath="default" singleInstance="true" />
                    <serializationProviderLogger type="Unicorn.Serialization.Sitecore.Fiat.DefaultFiatDeserializerLogger, Unicorn" singleInstance="true" />

                <dataProvider type="Unicorn.DefaultUnicornDataProviderLogger, Unicorn" singleInstance="true" />

                <logger type="Unicorn.Logging.PubSubLogger, Unicorn" singleInstance="true" />
            </defaults>

            <configurationProvider type="Unicorn.Configuration.XmlConfigurationProvider, Unicorn" />
        </unicorn>

        <processors>
            <saveUI>
                <processor patch:before="*[@type='Sitecore.Pipelines.Save.Save, Sitecore.Kernel']" mode="on" type="Unicorn.SerializationConflictProcessor, Unicorn"/>
            </saveUI>
        </processors>

        <pipelines>
            <httpRequestBegin>
                <processor patch:after="*[@type='Sitecore.Pipelines.HttpRequest.UserResolver, Sitecore.Kernel']" type="Unicorn.ControlPanel.UnicornControlPanelPipelineProcessor">
                    <param desc="activationUrl">/sync-database.aspx</param>
                </processor>
            </httpRequestBegin>
            <filterItem>
                <processor patch:before="*[@type='Sitecore.Pipelines.FilterItem.CheckIfFilteringIsActive, Sitecore.Kernel']" type="Unicorn.ControlPanel.CheckIfFilterDisablerIsActive, Unicorn" />
            </filterItem>
        </pipelines>

        <dataProviders>
            <unicorn type="Unicorn.Unicorn$(database)DataProvider, Unicorn">
                <param connectionStringName="$(1)"/>
                <Name>$(1)</Name>
            </unicorn>
        </dataProviders>
        <databases>
            <database id="master">
                <dataProviders>
                    <dataProvider>
                        <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                    </dataProvider>
                </dataProviders>
            </database>
            <database id="core">
                <dataProviders>
                    <dataProvider>
                        <patch:attribute name="ref">dataProviders/unicorn</patch:attribute>
                    </dataProvider>
                </dataProviders>
            </database>
        </databases>
    </sitecore>
</configuration>

and with this config i get items under vehicles for all sites even though they are excluded when i create the items programmatically and as part of that if i run a publish with code i get items from the web database saved to disk even though at no point is unicorn bound as a data provider for the web db

@kamsar
Copy link
Collaborator

kamsar commented Oct 16, 2014

You're getting web items serialized when you publish? (eg in serialization/web) Or are the master items being serialized as they get published to web?

I'll take a look at the exclude issue - I have test coverage on that so I thought it was working, but tests are only so much of a safety net ;)

Sorry for the delay in doing anything in depth; I'm in the middle of moving!

@tommyhawk520
Copy link
Author

if i run a publish programmatically then the items that are in master get published and as they are published they get items created for them on disk in serialization/web. the items i am publishing this way are the same items i am importing that should be excluded. when i publish the same items from within sitecore they do not get web items created

@kamsar
Copy link
Collaborator

kamsar commented Oct 17, 2014

What's the code you're using to programmatically publish?

On Thu, Oct 16, 2014 at 7:20 AM, tommyhawk520 notifications@github.com
wrote:

if i run a publish programmatically then the items that are in master get
published and as they are published they get items created for them on disk
in serialization/web. the items i am publishing this way are the same items
i am importing that should be excluded. when i publish the same items from
within sitecore they do not get web items created


Reply to this email directly or view it on GitHub
#33 (comment).

@tommyhawk520
Copy link
Author

the code i'm using is...

public static void Publish(string itemPath, bool includeSubitems)
        {
            using (new Sitecore.SecurityModel.SecurityDisabler())
            {
                var masterDb = Sitecore.Configuration.Factory.GetDatabase("master");
                var webDb = Sitecore.Configuration.Factory.GetDatabase("web");
                var language = Sitecore.Context.Language;
                var publishTime = DateTime.Now;
                var item = masterDb.Items[itemPath];
                var options = new PublishOptions(masterDb, webDb, PublishMode.Smart, language, publishTime);
                var publisher = new Publisher(options);
                publisher.Options.RootItem = item;
                publisher.Options.Deep = true;
                publisher.Publish();
            }
        }

@kamsar
Copy link
Collaborator

kamsar commented Apr 25, 2015

I've retested the exclusion part of this issue and am unable to reproduce it in several different scenario tries. It's worth noting that Sitecore 8 defaults to having schedule items in the database like @RaYell mentioned above that change their last run field. I've got those excluded in several production or in-development Sitecore 8 sites without issue.

I've also tried programmatically creating items in excluded locations:

    using (new SecurityDisabler())
    {
      var db = Factory.GetDatabase("master");

      var item = db.GetItem("/sitecore/system/publishing targets");

      item.Add("cats", new TemplateID(TemplateIDs.Alias));
    }

No items were written either time.

I'll see if I can replicate the publishing piece.

@kamsar
Copy link
Collaborator

kamsar commented Apr 25, 2015

Ok I tested using the exact publishing code from two comments ago, and I can't replicate that issue either. I tried publishing both with a root item that is excluded and one that is included, and no web database serialization occurred.

My best guess is that there's some kind of event handler, pipeline processor, etc that is doing something unexpected to the way Sitecore works. But without reproduction, I'm going to close this for now.

@kamsar kamsar closed this as completed Apr 25, 2015
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

3 participants