We have moved to GitHub Issues
Created by Tom Dudfield 01 Feb 2013, 16:04:03 Updated by Tom Dudfield 08 Feb 2013, 10:57:14
Relates to: U4-1648
When creating new content, if I call contentService.Save(content) the ID of the content is set after the save. However if I call contentService.SaveAndPublish(content) the ID of the content isn't set. This behaviour doesn't seem correct, I would expect the ID to be set in both scenarios.
Would it be possible for you to post a bit of your code? Think I'm missing the context because it seems unlikely that the behavior of Save would be different (in Save vs. SaveAndPublish) as the two methods are using the same internal repository for persisting the content object to the db.
After some more thought I think I know what is causing this. But just to confirm the content you are trying to SaveAndPublish does that have any ancestors that are not published or a mandatory property that is blank or null?
I can confirm that the property isn't mandatory.
Please refer to line 98, it was SaveAndPublish https://github.com/TomDudfield/Umbraco.Auto.Documents/blob/feature/v6/AutoDocuments/AutoDocuments.cs
So currently you do Save and then Publish - did you verify that this approach does in fact publish the content passed in? Does the Publish method return true or false?
Good point the publish returns false, however I'm not sure why as there are no mandatory fields and the parent item is already published.
The conditions for Publish is that all ancestors are published (except for the system root with id -1 of course), that content is valid (meaning no blank/null mandatory fields) and that the status of the content is not Expired, AwaitingRelease or Trashed. All of these checks are logged upon published, so you should be able to find some info in the UmbracoTraceLogs.txt file in /App_Data/Logs/
Looking at the log I see the following error, I've checked and it happens for every doc type not just the one I was trying earlier so it seems I have more of a fundamental issue
2013-02-04 14:56:59,496  INFO Umbraco.Core.Services.ContentService - [Thread 5] Content 'Blog' with Id '1107' could not be published because of invalid properties.
If you have it in a sql ce database I'd be happy to take a look and see if I can spot the issue - Or run the code from your github repo if that is what produces the result..?
The database is on azure, so you can connect directly to that using SSMS. Is there a way I can send you the credentials?
Tom, I think this issue might be related to U4-1648 which I'm gonna look into today.
Thanks, after more investigation that sounds very similar to my issue, my documents were setup in a similar way.
Hi Tom, the issue has been fixed for version 6.0.1 which is due out March 1st, but I have pushed a build of the recent changes so you can use the following nightly build to correct this issue: http://nightly.umbraco.org/umbraco%206.0.1/UmbracoCms.6.0.1-build.7.zip
Just overwrite the asssemblies with the ones from the bin folder in the above zip, and you should be good to go.
I can confirm, that using the updated dlls my issue is now resolved. Thanks
Assignee: Morten Christensen
Backwards Compatible: True
Affected versions: 6.0.0
Due in version: 6.0.1