Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin 1 post 72 karma points
    Sep 04, 2018 @ 13:27
    Martin
    1

    Not working on 7.5.2

    Hi, I try to delete old versions for only one node type, but not working. In the unversion.config file I have this:

    <add docTypeAlias="post" rootXpath="//node[@nodeTypeAlias='post']" maxDays="100" maxCount="1" />
    

    I tried change this configuration by this line:

      <add maxDays="2" maxCount="1" />
    

    but still not working at all. I understand, with this configuration I have 2 days past versions and only one version per day, correct?

    Another question, when the plugin code executes? I think executes when I publish a version but I am not sure.

    Can you help me please?

    Regards!

  • Jeroen Vantroyen 54 posts 394 karma points c-trib
    Nov 07, 2018 @ 14:42
    Jeroen Vantroyen
    0

    I've been playing with this today.

    The code executes when you publish an item (not just save).

     <add maxDays="10" maxCount="5" />
    

    will retain no more than 5 versions, IF they are no more than 10 days old. MaxCount does not mean 5 version per day, but total.

    e.g. if you have 5 versions of this file, but only 2 are less than 10 days old, only those 2 will be retained.

    Your sample will only retain 1 version. If that is your desire, you can omit the maxDays property.

    The code that determines of a version is to be retained :

    var daysDiff = (DateTime.Now - versionDate).Days;
    if (published || newest || (daysDiff < configEntry.MaxDays && readerIndex <= configEntry.MaxCount))
        versionsToKeep.Add("'" + versionId.ToString("D") + "'");
    

    You say it is not working. Can you elaborate? Do you experience a bug or are you still seeing old versions in the database?

    The easiest way to verify how many versions you have left, is go to the Info tab, select Actions > Rollback and count the items in the dropdown. (see also my earlier post)

  • Heather Floyd 610 posts 1032 karma points MVP 6x c-trib
    May 31, 2019 @ 20:12
    Heather Floyd
    0

    We have this set up on an Umbraco version 7.8.1 site, and what I noticed was this...

    If my config includes:

    <add docTypeAlias="PressRelease"  maxCount="5" />
    

    then I Publish a PressRelease content node which has more than 5 versions (according to the Rollback list), now there are zero versions (according to the Rollback list)...

    This is using UnVersion 2.1, which I assumed was using the MaxInt value for the maxDays param, so wouldn't that mean that irrespective of the age of the versions, 5 should be saved?

  • Heather Floyd 610 posts 1032 karma points MVP 6x c-trib
    May 31, 2019 @ 21:07
    Heather Floyd
    0

    So, I changed the config to:

    <add docTypeAlias="PressRelease" maxDays="10000" maxCount="5" />
    

    and I downloaded/recompiled the sourcecode (so I could step-through-debug it), and my issue is now gone.

    I'm not sure if the config change fixed it, or if the sourcecode had some improvement since the 2.1 package...

    FYI for troubleshooting, you can add this to the bottom of your log4net.config file:

    <logger name="Our.Umbraco.UnVersion">
        <level value="DEBUG" />
      </logger>
    

    And you will see the actual SQL statements in your Umbraco log file.

Please Sign in or register to post replies

Write your reply to:

Draft