You're right, it should only list 5 items. I'll have to try and do some testing as I haven't really done any tests on 4.7 yet, so it might just be a compatability issue.
unVersion should limit the number of versions a node will save. It does this on a node by node basis (ie, when you save a node, it'll trim it's version history). If you want to do a batch job to clear out a lot of history, you might want to try the house keeping package by the farm
I've tried it this morning, and it is working fine for me. I'm wondering if it's not liking the amount of versions it's being told to delete. Have you had a look in your log table for anything that might be related?
Sorry i am really an umbraco Newbie but i just installed your package and for new sites it only stores 5 versions (like i have configured it in the config) but all old sites still have about 200 hunder entries in the dropdown list.
It looks like it has not done the changes for all old sites
I'm not sure what else I can suggest. I've just created 200 versions of a node on my local install, setup unversion the same as yourself, recycled my app pool, and republished the node and it has successfully removed the old revisions. The fact that it's also working on new installs to me suggests it's something else causing a conflict.
Maybe try using the farm houskeeping package I mentioned earlier to clear out the old revisions, then see if setting up unversion once you have cleared out the backlog makes it work.
I just made a slight change to the web.config and resaved it, but recycling it via IIS should do the same task.
Have you tried republishing a node that has less than 200 revisions but within the same install to see if it's a site wide issue, or just for nodes with lots of revisions?
There really shouldn't be any difference between new and old nodes as far as UnVersion is concerned.
Can you have a look in the umbracoLog table in your database to see if there is anything in there that sounds like it might be related. That table is where any log messages are written to.
As I can't replicate here myself, my best suggestion would be to download the source for the plugin and debug into it to see what's going on. You can get the source from codeplex at http://unversion.codeplex.com/. It's not a very complex plugin, so you shouldn't have too much dificuilty debugging. Everything pretty much happens in the AppBase class.
Perhaps you can tell me the select statement where you select all of the old items. THan i can try to select this direct in the database and look if he will find any old items.
I think it is this one or?
SELECT cv.VersionId, cv.VersionDate, d.published, d.newest FROM cmsContentVersion cv LEFT OUTER JOIN cmsDocument d ON d.versionId = cv.VersionId WHERE cv.ContentId = {0} ORDER BY cv.VersionDate DESC
I tried this statement with an id of my document and it shows exactly the 19 lines. So i think something is wrong with the delete statement or the system is never running the deletion script?
That SQL query will list ALL revisions for a node. Unversion then loops through them all and determins whether it should be kept or deleted, then deletes all those flagged for deletion.
As I say, your best bet will be to download and debug through the source. This should tell you if there are any exceptions while it tries to delete the revisions.
If you just compile it in debug mode, then drop the .dll and .pdb file into your websites bin folder, you should then be able to attach Visual Studio to your websites w3wp.exe worker process (Ctrl + Alt + P, you might have to set it to display processes from all users and all processes in all session) which should allow you to set breakpoints in the AppBase class and see what is going on.
Just update the references to point to the umbraco dlls in your websites bin folder, that should be enough to get it to compile, then the debug process is just that which I outlined in my previous comment.
Just ensure "Debug" is selected in the build configuration dropdown, and then just build the project (Ctrl + Shift + B). Then you should find the dll / pdb file in the projects bin folder. Just copy those over to your websites bin folder.
You should be able to set a breakpoint at the place where it is doing the SQL query you posted earlier. You should then be able to step through the rest of the code to see what is going on.
Once you are connected to your website's w3wp process, you should then be able to just publish a node and watch the UnVersion plugin event handler trigger stopping at your breakpoint.
Ok, then when you are debugging, take a look at the value of configEntry.MaxCount and check this is set to 5. Also check the rest of the arguments in this statement:
As this is what determins which items should get deleted, so it sounds like something is getting through that shouldn't be. Which to me, would suggest the config wasn't loaded correctly, or it is badly formatted.
Then the only way they can become part of the versionsToKeepString is if they are the current published version, or the newest draft entry. Can you check whether either of these is always coming through as true (you should only every have 1 published and 1 newest revision for any given node).
If one of these is reposting a constant true state, then it sounds like it's down to some corrupt data, as there should only ever be one of each for any given node.
as it is the ONLY location that dictates what is kept. If something is in the list to be kept, it is because this if statement allowed it, and if the if statement allowed, one of the following must be true:
published = true newest = true readerIndex <= MaxCount version date < MaxDays
published and newest should only be true for one revision for any given node, where readerIndex and version dates should be dependant on the config (which from what you have said, it is coming through correctly).
You need to figure out which one of those checks is failing, then you can figure out why it is failing, and whether it is an issue with your content, or an issue with UnVersion.
Ok, in that case, you might want to check what (versionDate -DateTime.Now).Days is. If it is old data, it should have dates set in the past, and so should be a negative value. The only way I can think that would happen is if all the datas versionDates are set to some time in the future, which shouldn't really happen.
I don't suppose the data you are working with was created on a server with it's timezone set differently to your machine? It could be that the dates were stored in one format, and your local machine is parsing them wrongly, making it think the dates are in the future?
You need to check what the version date is being parsed as in the code rather than what is in the actual database, as it's the code that is making the decisions so it's whatever it perceives the dates to be that matters.
because versionDate will always be smaller than DateTime.Now - so in my case i am always getting a negative number and the condition is true and the items are added to the versionToKeep Array
Old items still exists
Hello,
I installed the tool and changed unVersion.config to
i changed the content of a page and clicked "publish" but in the "rollback" window i still see about 300 lines
I am using umbraco version 4.7.0
Hi Dominik,
Have you tried restarting your app pool?
Many thanks
Matt
Hi Matt,
I just restarted but again all old items still exists in the rollback dropdown
Hi Dominik,
And you republished the page after you restarted the app pool?
Matt
yes i republished the content site but still there are all old items inside the rollback dropdown.
But i think it should only show the last 5 items or?
Hi Dominik,
You're right, it should only list 5 items. I'll have to try and do some testing as I haven't really done any tests on 4.7 yet, so it might just be a compatability issue.
Matt
ok this would be great because our database is getting bigger and bigger.
Will your package delete the old files from database or have i to run any manually script?
Thanks for all your help
unVersion should limit the number of versions a node will save. It does this on a node by node basis (ie, when you save a node, it'll trim it's version history). If you want to do a batch job to clear out a lot of history, you might want to try the house keeping package by the farm
http://our.umbraco.org/projects/backoffice-extensions/falm-housekeeping
Matt
So if i set in the config maxCount="5" it shows only the latest 5 items but in the database the old items still exists?
Or will it only store the latest 5 versions in the databas. This is what we want to do so the database is not getting bigger and bigger
It will only store the latest 5 versions in the database.
Matt
THis is great. So we have to look why it is not working with umbraco version 4.7.0
Perhaps you can check it on your site and tell me what i have to change.
Thanks a lot
I will give it a try this evening and get back to you.
Many thanks
Matt
Hi Matt,
I just tested it with a new created content site - and here it seems to work.
But an old created item still shows all of the old versions and not only the latest 5 (also after republishing)
Perhaps this information helps?
Hi Dominik,
I've tried it this morning, and it is working fine for me. I'm wondering if it's not liking the amount of versions it's being told to delete. Have you had a look in your log table for anything that might be related?
Many thanks
Matt
Hi Matt,
Sorry i am really an umbraco Newbie but i just installed your package and for new sites it only stores 5 versions (like i have configured it in the config) but all old sites still have about 200 hunder entries in the dropdown list.
It looks like it has not done the changes for all old sites
Regards
Hi Dominik,
I'm not sure what else I can suggest. I've just created 200 versions of a node on my local install, setup unversion the same as yourself, recycled my app pool, and republished the node and it has successfully removed the old revisions. The fact that it's also working on new installs to me suggests it's something else causing a conflict.
Maybe try using the farm houskeeping package I mentioned earlier to clear out the old revisions, then see if setting up unversion once you have cleared out the backlog makes it work.
Many thanks
Matt
Can you please tell me how you have exactly recycled your app pool. I have just restartet the app pool for this site and republished the item
But still there are 200 versions in the dropdown.
Hi Dominik,
I just made a slight change to the web.config and resaved it, but recycling it via IIS should do the same task.
Have you tried republishing a node that has less than 200 revisions but within the same install to see if it's a site wide issue, or just for nodes with lots of revisions?
Matt
HI Matt,
I just tried it with an old site that has about 15 dropdown lines.
After republishing it shows again 15 items and not only 5.
I think it is a problem with old items. New items are working great.
Hi Dominik,
There really shouldn't be any difference between new and old nodes as far as UnVersion is concerned.
Can you have a look in the umbracoLog table in your database to see if there is anything in there that sounds like it might be related. That table is where any log messages are written to.
Cheers
Matt
I just published it again and looks into the logfile.
But only 2 inserts have been done one is "Publish" and one is "Debug" with info "Xml savend in ....:"
I can not see any problem :-(
Hi Dominik,
As I can't replicate here myself, my best suggestion would be to download the source for the plugin and debug into it to see what's going on. You can get the source from codeplex at http://unversion.codeplex.com/. It's not a very complex plugin, so you shouldn't have too much dificuilty debugging. Everything pretty much happens in the AppBase class.
Best of luck.
Matt
Hi Matt,
Perhaps you can tell me the select statement where you select all of the old items. THan i can try to select this direct in the database and look if he will find any old items.
I think it is this one or?
SELECT cv.VersionId, cv.VersionDate, d.published, d.newest FROM cmsContentVersion cv LEFT OUTER JOIN cmsDocument d ON d.versionId = cv.VersionId WHERE cv.ContentId = {0} ORDER BY cv.VersionDate DESC
Hi Matt,
I tried this statement with an id of my document and it shows exactly the 19 lines. So i think something is wrong with the delete statement or the system is never running the deletion script?
HI Dominik,
That SQL query will list ALL revisions for a node. Unversion then loops through them all and determins whether it should be kept or deleted, then deletes all those flagged for deletion.
As I say, your best bet will be to download and debug through the source. This should tell you if there are any exceptions while it tries to delete the revisions.
Many thanks
Matt
Hi Matt, Sorry i do not now how i can debug it.
I can download the project and open it with VS 2010 but I think it will not find any database connection or?
Hi Dominik,
If you just compile it in debug mode, then drop the .dll and .pdb file into your websites bin folder, you should then be able to attach Visual Studio to your websites w3wp.exe worker process (Ctrl + Alt + P, you might have to set it to display processes from all users and all processes in all session) which should allow you to set breakpoints in the AppBase class and see what is going on.
Hope that helps
Cheers
Matt
Hi Matt,
If i opening your project he is not getting the links to the umbraco dlls so I think i can not just open the project in VS2010.
Is there any tutorial which describes how i can debug a third party project with umbraco?
My umbraco is running on local IIS server.
Thanks
Hi Dominik,
Just update the references to point to the umbraco dlls in your websites bin folder, that should be enough to get it to compile, then the debug process is just that which I outlined in my previous comment.
Many thanks
Matt
Hi Matt,
Ok I edited the references but can you please tell me how i can compile it in debug mode? If i click debug it is trying to open the project
Hi Dominik,
Just ensure "Debug" is selected in the build configuration dropdown, and then just build the project (Ctrl + Shift + B). Then you should find the dll / pdb file in the projects bin folder. Just copy those over to your websites bin folder.
Cheers
Matt
ok this works - but if i try to add breakpoints in the ApplicationBase.cs it always says that i am not allowed to set breakpoints there.
shall i now try to publish an old site againg.
Where i have to look after this so i can see where the problem appears?
Hi Matt,
Ok now i was able to debug.
Some things i have seen
- It will go into the if (versionNo >= 45000) statment
- The versionsToKeepString includes not only 5 items - it include all 19 items - i think here is the problem or?
I think versionsToKeepString should only include 5 items not all 19
Hi Dominik,
You should be able to set a breakpoint at the place where it is doing the SQL query you posted earlier. You should then be able to step through the rest of the code to see what is going on.
Once you are connected to your website's w3wp process, you should then be able to just publish a node and watch the UnVersion plugin event handler trigger stopping at your breakpoint.
Many thanks
Matt
HI Matt,
Yes it is working - but versionsToKeepString includes all 19 items not only 5 items
I think this is the problem or?
Ok, then when you are debugging, take a look at the value of configEntry.MaxCount and check this is set to 5. Also check the rest of the arguments in this statement:
if(published || newest || readerIndex <= configEntry.MaxCount || (versionDate - DateTime.Now).Days < configEntry.MaxDays)
As this is what determins which items should get deleted, so it sounds like something is getting through that shouldn't be. Which to me, would suggest the config wasn't loaded correctly, or it is badly formatted.
Cheers
Matt
Hi Matt
MaxCount is 5
MaxDays is 0
I think config is read correct because for new items all is working - only old items are not deleted
Then the only way they can become part of the versionsToKeepString is if they are the current published version, or the newest draft entry. Can you check whether either of these is always coming through as true (you should only every have 1 published and 1 newest revision for any given node).
If one of these is reposting a constant true state, then it sounds like it's down to some corrupt data, as there should only ever be one of each for any given node.
Cheers
Matt
RootXPath is null
Perhaps this is an problem?
I looked in the database with the select - one item is published and one other item is newest
RootXPath is optional, so shouldn't be a problem that it is null.
I tried another old site and the database shows 64 rows in cmsContentVersion for this item
If i debug it the readerIndex is 100 - perhaps this helps
I think you need to check everything that is being checked for in this if statement,
as it is the ONLY location that dictates what is kept. If something is in the list to be kept, it is because this if statement allowed it, and if the if statement allowed, one of the following must be true:
published = true
newest = true
readerIndex <= MaxCount
version date < MaxDays
published and newest should only be true for one revision for any given node, where readerIndex and version dates should be dependant on the config (which from what you have said, it is coming through correctly).
You need to figure out which one of those checks is failing, then you can figure out why it is failing, and whether it is an issue with your content, or an issue with UnVersion.
Cheers
Matt
Hi Matt i found the issue
If i remove last statement
||(versionDate -DateTime.Now).Days< configEntry.MaxDay
it is working!
Ok, in that case, you might want to check what (versionDate -DateTime.Now).Days is. If it is old data, it should have dates set in the past, and so should be a negative value. The only way I can think that would happen is if all the datas versionDates are set to some time in the future, which shouldn't really happen.
Cheers
Matt
In the database all versionDates are in the past
2011-11-18 12:07:44.623 as an example
Perhaps it is an issue if i have not set any MayDay?
regards
I don't suppose the data you are working with was created on a server with it's timezone set differently to your machine? It could be that the dates were stored in one format, and your local machine is parsing them wrongly, making it think the dates are in the future?
Cheers
Matt
You need to check what the version date is being parsed as in the code rather than what is in the actual database, as it's the code that is making the decisions so it's whatever it perceives the dates to be that matters.
Matt
Hi Matt
VersionDate: Date = {21/11/2011 00:00:00}
DateTime.Now : Now = {22/11/2011 12:58:12}
Of course it is a negative number because versiondate is always smaller than DateTime Now
So it will always be smaller than 0
I think it must be
||(DateTime.Now - versionDate).Days< configEntry.MaxDay
or?
because versionDate will always be smaller than DateTime.Now - so in my case i am always getting a negative number and the condition is true and the items are added to the versionToKeep Array
Hi Domink,
I think you might be right. Strange how it's never come up before now though, oh well, I'll do some more tests to make sure and issue an update.
You should be able to just use your custom built DLL for the time being.
Glad you were able to get it to work.
Many thanks
Matt
yes but can you please provide me wiht a complete zip package which will solve this issue?
I am wondering why this has worked for all others?
Really strange :-)
But i am happy to solved it
So once there is a new package can you please send me a note?
No problem, I'll post a reply on here to let you know.
Many thanks
Matt
Ok, v1.4 should be available to download now.
Cheers
Matt
I think its working now - thanks a lot Matt
Hi Dominik, would you be so kind as to mark this topic with a solution?
Many thanks, Lee.
is working on a reply...