diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index aab8187b05..b9d669038d 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -26,9 +26,6 @@ namespace Umbraco.Core.Configuration { #region Private static fields - - // CURRENT UMBRACO VERSION ID - private const string CurrentUmbracoVersion = "6.0.0"; private static string _reservedUrlsCache; private static string _reservedPathsCache; @@ -408,16 +405,30 @@ namespace Umbraco.Core.Configuration } } + /// + /// Gets the current version of Umbraco. + /// + /// + /// CURRENT UMBRACO VERSION ID + /// + public static Version Version + { + get + { + return typeof(GlobalSettings).Assembly.GetName().Version; + } + } + /// /// Gets the current version. /// /// The current version. + [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] public static string CurrentVersion { get { - // change this to be hardcoded in the binary - return CurrentUmbracoVersion; + return Version.ToString(3); } } @@ -425,12 +436,12 @@ namespace Umbraco.Core.Configuration /// Gets the major version number. /// /// The major version number. + [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] public static int VersionMajor { get { - string[] version = CurrentVersion.Split(".".ToCharArray()); - return int.Parse(version[0]); + return Version.Major; } } @@ -438,12 +449,12 @@ namespace Umbraco.Core.Configuration /// Gets the minor version number. /// /// The minor version number. + [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] public static int VersionMinor { get { - string[] version = CurrentVersion.Split(".".ToCharArray()); - return int.Parse(version[1]); + return Version.Minor; } } @@ -451,12 +462,12 @@ namespace Umbraco.Core.Configuration /// Gets the patch version number. /// /// The patch version number. + [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] public static int VersionPatch { get { - string[] version = CurrentVersion.Split(".".ToCharArray()); - return int.Parse(version[2]); + return Version.Build; } } @@ -464,15 +475,12 @@ namespace Umbraco.Core.Configuration /// Gets the version comment (like beta or RC). /// /// The version comment. + [Obsolete("Use Umbraco.Core.Configuration.GlobalSettings.Version instead", false)] public static string VersionComment { get { - string[] version = CurrentVersion.Split(".".ToCharArray()); - if (version.Length > 3) - return version[3]; - else - return ""; + return ""; } } diff --git a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs index 53572fde09..8452f81ac9 100644 --- a/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/ContentRepository.cs @@ -94,6 +94,8 @@ namespace Umbraco.Core.Persistence.Repositories //NOTE: This doesn't allow properties to be part of the query var dtos = Database.Fetch(sql); + //NOTE: Won't work with language related queries because the language version isn't passed to the Get() method. + //A solution could be to look at the sql for the LanguageLocale column and choose the foreach-loop based on that. foreach (var dto in dtos.DistinctBy(x => x.NodeId)) { yield return Get(dto.NodeId); diff --git a/src/Umbraco.Tests/GlobalSettingsTests.cs b/src/Umbraco.Tests/GlobalSettingsTests.cs index 5d57679b61..ea3a569428 100644 --- a/src/Umbraco.Tests/GlobalSettingsTests.cs +++ b/src/Umbraco.Tests/GlobalSettingsTests.cs @@ -29,6 +29,12 @@ namespace Umbraco.Tests ConfigurationManager.AppSettings.Set("umbracoReservedUrls", ""); } + [Test] + public void Is_Version_From_Assembly_Correct() + { + Assert.That(Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3), Is.EqualTo("6.0.0")); + } + [TestCase("/umbraco/umbraco.aspx")] [TestCase("/umbraco/editContent.aspx")] [TestCase("/install/default.aspx")] diff --git a/src/Umbraco.Web.UI/config/splashes/noNodes.aspx b/src/Umbraco.Web.UI/config/splashes/noNodes.aspx index 03ec792a8a..b41724e1c5 100644 --- a/src/Umbraco.Web.UI/config/splashes/noNodes.aspx +++ b/src/Umbraco.Web.UI/config/splashes/noNodes.aspx @@ -7,7 +7,7 @@ Umbraco - <%=umbraco.GlobalSettings.CurrentVersion%> + <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%> - no pages found diff --git a/src/Umbraco.Web.UI/install/Title.ascx b/src/Umbraco.Web.UI/install/Title.ascx index acf33a7a3b..94eef72f48 100644 --- a/src/Umbraco.Web.UI/install/Title.ascx +++ b/src/Umbraco.Web.UI/install/Title.ascx @@ -1,2 +1,2 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Title.ascx.cs" Inherits="umbraco.presentation.install.Title" %> -Umbraco <%=umbraco.GlobalSettings.CurrentVersion%> Configuration Wizard \ No newline at end of file +Umbraco <%=Umbraco.Core.Configuration.GlobalSettings.Version.ToString(3)%> Configuration Wizard \ No newline at end of file diff --git a/src/Umbraco.Web.UI/install/steps/database.ascx b/src/Umbraco.Web.UI/install/steps/database.ascx index 3de5f6a398..3f743d8052 100644 --- a/src/Umbraco.Web.UI/install/steps/database.ascx +++ b/src/Umbraco.Web.UI/install/steps/database.ascx @@ -209,7 +209,7 @@