From 9f5f920c813342eb4c0a038f9c8656201b1ee841 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Mon, 28 Jan 2013 17:18:20 +0000 Subject: [PATCH 1/7] MNTP: Corrected a typo in the example XPath (additional apostrophe) --- .../MultiNodeTreePicker/MNTPResources.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.resx b/src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.resx index e3e9167bc1..0224ee5734 100644 --- a/src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.resx +++ b/src/umbraco.editorControls/MultiNodeTreePicker/MNTPResources.resx @@ -145,7 +145,7 @@ The XPath expression that is evaluated to match a start node can be evaluated at a global tree level, or matched from the current node being edited. - An xpath filter to match nodes that will be either enabled or disabled from being clicked (depending on what is selected for the XPath filter type). This XPath filter is for one node only so it should be formatted to select only one node. The XML to XPath against is the same as the Umbraco XML for one node.<br/><br/>Example: <code>/*[self::'myNodeType or self::yourNodeType]</code><br/><br/>The above would make all nodes of types: myNodeType or yourNodeType not selectable in the tree + An xpath filter to match nodes that will be either enabled or disabled from being clicked (depending on what is selected for the XPath filter type). This XPath filter is for one node only so it should be formatted to select only one node. The XML to XPath against is the same as the Umbraco XML for one node.<br/><br/>Example: <code>/*[self::myNodeType or self::yourNodeType]</code><br/><br/>The above would make all nodes of types: myNodeType or yourNodeType not selectable in the tree Should the XPath filter match nodes to enable nodes or disable nodes. If Enable is selected, this means that only nodes that match the XPath filter will be allowed to be selected in the tree picker and vise versa for Disabled From a9e1e7b63429d1a4b645f57857ec8951c9a62ece Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 29 Jan 2013 03:42:58 +0600 Subject: [PATCH 2/7] Updating: #U4-1491 - Updated HasPublishedVersion() to ensure it checks for 'newest' --- src/umbraco.cms/businesslogic/web/Document.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index d5a2f362be..2bbec1ac9c 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -1228,7 +1228,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'"); public bool HasPublishedVersion() { - return (SqlHelper.ExecuteScalar("select Count(published) as tmp from cmsDocument where published = 1 And nodeId =" + Id) > 0); + return (SqlHelper.ExecuteScalar("select Count(published) as tmp from cmsDocument where published = 1 And newest = 1 And nodeId =" + Id) > 0); } /// From 27cfa85d3a52023b8c58fc6d27bbe76175abe430 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 29 Jan 2013 04:39:44 +0600 Subject: [PATCH 3/7] Fixes: #U4-1579 - moving a node doesn't update the descendants of that node's level or path. --- src/umbraco.cms/businesslogic/CMSNode.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/umbraco.cms/businesslogic/CMSNode.cs b/src/umbraco.cms/businesslogic/CMSNode.cs index a18a4bc91b..d325720aa4 100644 --- a/src/umbraco.cms/businesslogic/CMSNode.cs +++ b/src/umbraco.cms/businesslogic/CMSNode.cs @@ -513,15 +513,17 @@ order by level,sortOrder"; SqlHelper.CreateParameter("@parentId", newParent.Id)); this.Parent = newParent; - this.sortOrder = maxSortOrder + 1; + this.sortOrder = maxSortOrder + 1; + } + + //detect if we have moved, then update the level and path + // issue: http://issues.umbraco.org/issue/U4-1579 + if (this.Path != newParent.Path + "," + this.Id.ToString()) + { this.Level = newParent.Level + 1; this.Path = newParent.Path + "," + this.Id.ToString(); } - //this.Parent = newParent; - //this.Level = newParent.Level + 1; - //this.Path = newParent.Path + "," + this.Id.ToString(); - //this code block should not be here but since the class structure is very poor and doesn't use //overrides (instead using shadows/new) for the Children property, when iterating over the children //and calling Move(), the super classes overridden OnMove or Move methods never get fired, so From a6a3ddca750acb61548137d780957f5dd6231c17 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 29 Jan 2013 05:37:14 +0600 Subject: [PATCH 4/7] Fixes: #U4-1580 - m_SQLOptimizedMany includes the 'trashed' flag which can be used by business logic. --- src/umbraco.cms/businesslogic/web/Document.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index 2bbec1ac9c..6a8303afa9 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Web; using System.Xml; using Umbraco.Core.IO; @@ -187,7 +188,7 @@ namespace umbraco.cms.businesslogic.web umbracoNode.path, umbracoNode.sortOrder, coalesce(publishCheck.published,0) as isPublished, umbracoNode.createDate, cmsDocument.text, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, cmsContentType.masterContentType, cmsContentType.nodeId as contentTypeId, - umbracoNode.nodeUser + umbracoNode.nodeUser, umbracoNode.trashed from umbracoNode left join umbracoNode children on children.parentId = umbracoNode.id inner join cmsContent on cmsContent.nodeId = umbracoNode.id @@ -202,7 +203,8 @@ namespace umbraco.cms.businesslogic.web cmsDocument.templateId, cmsDocumentType.templateNodeId, umbracoNode.path, umbracoNode.sortOrder, coalesce(publishCheck.published,0), umbracoNode.createDate, cmsDocument.text, cmsContentType.icon, cmsContentType.alias, cmsContentType.thumbnail, cmsContentType.description, - cmsContentType.masterContentType, cmsContentType.nodeId, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, umbracoNode.nodeUser + cmsContentType.masterContentType, cmsContentType.nodeId, cmsDocument.updateDate, cmsContentVersion.versionDate, cmsDocument.releaseDate, cmsDocument.expireDate, + umbracoNode.nodeUser, umbracoNode.trashed order by {1} "; @@ -449,6 +451,8 @@ namespace umbraco.cms.businesslogic.web return isDoc; } + + /// /// Used to get the firstlevel/root documents of the hierachy /// /// Root documents @@ -1001,6 +1005,11 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'"); /// /// The usercontext under which the action are performed /// True if the publishing succeed. Possible causes for not publishing is if an event aborts the publishing + /// + /// This method needs to be marked with [MethodImpl(MethodImplOptions.Synchronized)] + /// because we execute multiple queries affecting the same data, if two thread are to do this at the same time for the same node we may have problems + /// + [MethodImpl(MethodImplOptions.Synchronized)] public bool PublishWithResult(User u) { PublishEventArgs e = new PublishEventArgs(); @@ -1723,10 +1732,7 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'"); protected void PopulateDocumentFromReader(IRecordsReader dr) { - bool _hc = false; - - if (dr.GetInt("children") > 0) - _hc = true; + var hc = dr.GetInt("children") > 0; int? masterContentType = null; @@ -1738,14 +1744,14 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'"); , dr.GetInt("parentId") , dr.GetInt("nodeUser") , dr.GetInt("documentUser") - , (dr.GetInt("isPublished") == 1) + , !dr.GetBoolean("trashed") && (dr.GetInt("isPublished") == 1) //set published... double check trashed property , dr.GetString("path") , dr.GetString("text") , dr.GetDateTime("createDate") , dr.GetDateTime("updateDate") , dr.GetDateTime("versionDate") , dr.GetString("icon") - , _hc + , hc , dr.GetString("alias") , dr.GetString("thumbnail") , dr.GetString("description") From 4cf1d7d9a44ff7f46433f902c2c9296f0ec3057e Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 29 Jan 2013 05:48:18 +0600 Subject: [PATCH 5/7] Fixes: #U4-1577 - HasPublishedVersion checks for trashed --- src/umbraco.cms/businesslogic/web/Document.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/umbraco.cms/businesslogic/web/Document.cs b/src/umbraco.cms/businesslogic/web/Document.cs index 6a8303afa9..703207644e 100644 --- a/src/umbraco.cms/businesslogic/web/Document.cs +++ b/src/umbraco.cms/businesslogic/web/Document.cs @@ -1235,9 +1235,22 @@ and node.nodeObjectType='C66BA18E-EAF3-4CFF-8A22-41B16D66A972'"); } } + /// + /// Returns true if the document is published + /// + /// + /// + /// If the document is in the trash then this will return false + /// public bool HasPublishedVersion() { - return (SqlHelper.ExecuteScalar("select Count(published) as tmp from cmsDocument where published = 1 And newest = 1 And nodeId =" + Id) > 0); + var count = SqlHelper.ExecuteScalar(@" +select Count(published) as CountOfPublished +from cmsDocument +inner join umbracoNode on cmsDocument.nodeId = umbracoNode.id +where published = 1 And nodeId = @nodeId And trashed = 0", SqlHelper.CreateParameter("@nodeId", Id)); + + return count > 0; } /// From 5e9f4559b6eb4d9a090483f1c8db60c22582df3f Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 29 Jan 2013 07:49:14 +0600 Subject: [PATCH 6/7] Fixes: #U4-1536 --- src/Umbraco.Web/Mvc/RenderMvcController.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Umbraco.Web/Mvc/RenderMvcController.cs b/src/Umbraco.Web/Mvc/RenderMvcController.cs index 9a7d0a4f64..2c1993943f 100644 --- a/src/Umbraco.Web/Mvc/RenderMvcController.cs +++ b/src/Umbraco.Web/Mvc/RenderMvcController.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Web.Mvc; using Umbraco.Core.Logging; +using Umbraco.Core.Models; using Umbraco.Web.Models; using Umbraco.Web.Routing; @@ -25,6 +26,14 @@ namespace Umbraco.Web.Mvc get { return PublishedContentRequest.RoutingContext.UmbracoContext; } } + /// + /// Returns the Current published content item for rendering the content + /// + protected IPublishedContent CurrentPage + { + get { return PublishedContentRequest.PublishedContent; } + } + //TODO: make this protected once we make PublishedContentRequest not internal after we figure out what it should actually contain /// /// Returns the current PublishedContentRequest From c5d1439422992c491146ce0878b074aae7f81cd2 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Tue, 29 Jan 2013 08:35:09 +0600 Subject: [PATCH 7/7] Fixes: #U4-1458 - due to a null check on PublishedContentRequest on UmbracoContext --- src/Umbraco.Web/Templates/TemplateRenderer.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/Templates/TemplateRenderer.cs b/src/Umbraco.Web/Templates/TemplateRenderer.cs index ce2da96730..0967f0c360 100644 --- a/src/Umbraco.Web/Templates/TemplateRenderer.cs +++ b/src/Umbraco.Web/Templates/TemplateRenderer.cs @@ -1,5 +1,7 @@ using System; +using System.Globalization; using System.IO; +using System.Linq; using System.Web.Compilation; using System.Web.Mvc; using System.Web.Routing; @@ -8,6 +10,7 @@ using Umbraco.Web.Models; using Umbraco.Web.Mvc; using Umbraco.Web.Routing; using umbraco; +using umbraco.cms.businesslogic.language; namespace Umbraco.Web.Templates { @@ -61,8 +64,21 @@ namespace Umbraco.Web.Templates return; } - //set the culture to the same as is currently rendering - contentRequest.Culture = _umbracoContext.PublishedContentRequest.Culture; + //in some cases the UmbracoContext will not have a PublishedContentRequest assigned to it if we are not in the + //execution of a front-end rendered page. In this case set the culture to the default. + //set the culture to the same as is currently rendering + if (_umbracoContext.PublishedContentRequest == null) + { + var defaultLanguage = Language.GetAllAsList().FirstOrDefault(); + contentRequest.Culture = defaultLanguage == null + ? CultureInfo.CurrentUICulture + : new CultureInfo(defaultLanguage.CultureAlias); + } + else + { + contentRequest.Culture = _umbracoContext.PublishedContentRequest.Culture; + } + //set the doc that was found by id contentRequest.PublishedContent = doc; //set the template, either based on the AltTemplate found or the standard template of the doc