Fix Examine PR, fix migrations and upgrades
This commit is contained in:
@@ -57,6 +57,16 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
RuntimeLevel Level { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current migration state.
|
||||
/// </summary>
|
||||
string CurrentMigrationState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the final migration state.
|
||||
/// </summary>
|
||||
string FinalMigrationState { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the exception that caused the boot to fail.
|
||||
/// </summary>
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Core.Migrations.Upgrade
|
||||
Chain<DataTypeMigration>("{8640C9E4-A1C0-4C59-99BB-609B4E604981}");
|
||||
Chain<TagsMigration>("{DD1B99AF-8106-4E00-BAC7-A43003EA07F8}");
|
||||
Chain<SuperZero>("{9DF05B77-11D1-475C-A00A-B656AF7E0908}");
|
||||
Chain<PropertyEditorsMigration>("{CA7DB949-3EF4-403D-8464-F9BA36A52E87}");
|
||||
Chain<PropertyEditorsMigration>("{6FE3EF34-44A0-4992-B379-B40BC4EF1C4D}");
|
||||
Chain<LanguageColumns>("{7F59355A-0EC9-4438-8157-EB517E6D2727}");
|
||||
|
||||
// must chain to v8 final state (see at end of file)
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Umbraco.Core.Runtime
|
||||
try
|
||||
{
|
||||
var dbfactory = container.GetInstance<IUmbracoDatabaseFactory>();
|
||||
SetRuntimeStateLevel(_state, dbfactory, Logger);
|
||||
SetRuntimeStateLevel(dbfactory, Logger);
|
||||
Logger.Debug<CoreRuntime>($"Runtime level: {_state.Level}");
|
||||
}
|
||||
catch
|
||||
@@ -233,38 +233,38 @@ namespace Umbraco.Core.Runtime
|
||||
builder.AddCore();
|
||||
}
|
||||
|
||||
private void SetRuntimeStateLevel(RuntimeState runtimeState, IUmbracoDatabaseFactory databaseFactory, ILogger logger)
|
||||
private void SetRuntimeStateLevel(IUmbracoDatabaseFactory databaseFactory, ILogger logger)
|
||||
{
|
||||
var localVersion = UmbracoVersion.Local; // the local, files, version
|
||||
var codeVersion = runtimeState.SemanticVersion; // the executing code version
|
||||
var codeVersion = _state.SemanticVersion; // the executing code version
|
||||
var connect = false;
|
||||
|
||||
// we don't know yet
|
||||
runtimeState.Level = RuntimeLevel.Unknown;
|
||||
_state.Level = RuntimeLevel.Unknown;
|
||||
|
||||
if (localVersion == null)
|
||||
{
|
||||
// there is no local version, we are not installed
|
||||
logger.Debug<CoreRuntime>("No local version, need to install Umbraco.");
|
||||
runtimeState.Level = RuntimeLevel.Install;
|
||||
_state.Level = RuntimeLevel.Install;
|
||||
}
|
||||
else if (localVersion != codeVersion)
|
||||
{
|
||||
// there *is* a local version, but it does not match the code version
|
||||
// need to upgrade
|
||||
logger.Debug<CoreRuntime>($"Local version \"{localVersion}\" != code version \"{codeVersion}\", need to upgrade Umbraco.");
|
||||
runtimeState.Level = RuntimeLevel.Upgrade;
|
||||
_state.Level = RuntimeLevel.Upgrade;
|
||||
}
|
||||
else if (databaseFactory.Configured == false)
|
||||
{
|
||||
// local version *does* match code version, but the database is not configured
|
||||
// install (again? this is a weird situation...)
|
||||
logger.Debug<CoreRuntime>("Database is not configured, need to install Umbraco.");
|
||||
runtimeState.Level = RuntimeLevel.Install;
|
||||
_state.Level = RuntimeLevel.Install;
|
||||
}
|
||||
|
||||
// install? not going to test anything else
|
||||
if (runtimeState.Level == RuntimeLevel.Install)
|
||||
if (_state.Level == RuntimeLevel.Install)
|
||||
return;
|
||||
|
||||
// else, keep going,
|
||||
@@ -284,14 +284,14 @@ namespace Umbraco.Core.Runtime
|
||||
{
|
||||
// cannot connect to configured database, this is bad, fail
|
||||
logger.Debug<CoreRuntime>("Could not connect to database.");
|
||||
runtimeState.Level = RuntimeLevel.BootFailed;
|
||||
_state.Level = RuntimeLevel.BootFailed;
|
||||
|
||||
// in fact, this is bad enough that we want to throw
|
||||
throw new BootFailedException("A connection string is configured but Umbraco could not connect to the database.");
|
||||
}
|
||||
|
||||
// if we already know we want to upgrade, no need to look for migrations...
|
||||
if (runtimeState.Level == RuntimeLevel.Upgrade)
|
||||
if (_state.Level == RuntimeLevel.Upgrade)
|
||||
return;
|
||||
|
||||
// else
|
||||
@@ -302,18 +302,19 @@ namespace Umbraco.Core.Runtime
|
||||
{
|
||||
exists = EnsureUmbracoUpgradeState(databaseFactory, logger);
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
// can connect to the database but cannot access the migration table... need to install
|
||||
logger.Warn<CoreRuntime>(e, "Could not check the upgrade state.");
|
||||
logger.Debug<CoreRuntime>("Could not check the upgrade state, need to install Umbraco.");
|
||||
runtimeState.Level = RuntimeLevel.Install;
|
||||
_state.Level = RuntimeLevel.Install;
|
||||
return;
|
||||
}
|
||||
|
||||
if (exists)
|
||||
{
|
||||
// the database version matches the code & files version, all clear, can run
|
||||
runtimeState.Level = RuntimeLevel.Run;
|
||||
_state.Level = RuntimeLevel.Run;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -323,7 +324,7 @@ namespace Umbraco.Core.Runtime
|
||||
// although the files version matches the code version, the database version does not
|
||||
// which means the local files have been upgraded but not the database - need to upgrade
|
||||
logger.Debug<CoreRuntime>("Has not reached the final upgrade step, need to upgrade Umbraco.");
|
||||
runtimeState.Level = RuntimeLevel.Upgrade;
|
||||
_state.Level = RuntimeLevel.Upgrade;
|
||||
}
|
||||
|
||||
protected virtual bool EnsureUmbracoUpgradeState(IUmbracoDatabaseFactory databaseFactory, ILogger logger)
|
||||
@@ -343,11 +344,12 @@ namespace Umbraco.Core.Runtime
|
||||
state = database.FirstOrDefault<KeyValueDto>(sql)?.Value;
|
||||
}
|
||||
|
||||
var finalState = umbracoPlan.FinalState;
|
||||
_state.CurrentMigrationState = state;
|
||||
_state.FinalMigrationState = umbracoPlan.FinalState;
|
||||
|
||||
logger.Debug<CoreRuntime>($"Final upgrade state is \"{finalState}\", database contains \"{state ?? "<null>"}\".");
|
||||
logger.Debug<CoreRuntime>($"Final upgrade state is \"{_state.FinalMigrationState}\", database contains \"{state ?? "<null>"}\".");
|
||||
|
||||
return state == finalState;
|
||||
return state == _state.FinalMigrationState;
|
||||
}
|
||||
|
||||
#region Locals
|
||||
|
||||
@@ -85,6 +85,12 @@ namespace Umbraco.Core
|
||||
/// <remarks>This is either "/" or eg "/virtual".</remarks>
|
||||
public string ApplicationVirtualPath { get; } = HttpRuntime.AppDomainAppVirtualPath;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string CurrentMigrationState { get; internal set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string FinalMigrationState { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the runtime level of execution.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<div>
|
||||
<h1>Upgrading Umbraco</h1>
|
||||
<p>
|
||||
Welcome to the Umbraco installer. You see this screen because your Umbraco installation needs a quick upgrade of its database and files, which will ensure your website is kept as fast, secure and up to date as possible.
|
||||
Welcome to the Umbraco installer. You see this screen because your Umbraco installation needs a quick upgrade
|
||||
of its database and files, which will ensure your website is kept as fast, secure and up to date as possible.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To read a report of changes between your current version <strong>{{installer.current.model.currentVersion}}</strong> and this version you're upgrading to <strong>{{installer.current.model.newVersion}}</strong>
|
||||
Detected current version <strong>{{installer.current.model.currentVersion}}</strong> ({{installer.current.model.currentState}}),
|
||||
which needs to be upgraded to <strong>{{installer.current.model.newVersion}}</strong> ({{installer.current.model.newState}}).
|
||||
To compare versions and read a report of changes between versions, use the <em>View Report</em> button below.
|
||||
</p>
|
||||
<p>
|
||||
<a ng-href="{{installer.current.model.reportUrl}}" target="_blank" class="btn btn-info">View Report</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Simply click <strong>continue</strong> below to be guided through the rest of the upgrade
|
||||
Simply click <strong>continue</strong> below to be guided through the rest of the upgrade.
|
||||
</p>
|
||||
<p>
|
||||
<button class="btn btn-success" ng-click="install()">Continue</button>
|
||||
|
||||
@@ -54,11 +54,12 @@
|
||||
<Reference Include="AutoMapper, Version=6.1.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AutoMapper.6.1.1\lib\net45\AutoMapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Examine, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Examine.1.0.0-beta020\lib\net45\Examine.dll</HintPath>
|
||||
<Reference Include="ClientDependency.Core, Version=1.9.6.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ClientDependency.1.9.6\lib\net45\ClientDependency.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Examine, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Examine.1.0.0-beta024\lib\net45\Examine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ImageProcessor.Web, Version=4.8.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ImageProcessor.Web.4.8.4\lib\net45\ImageProcessor.Web.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<package id="ClientDependency" version="1.9.6" targetFramework="net461" />
|
||||
<package id="ClientDependency-Mvc5" version="1.8.0.0" targetFramework="net461" />
|
||||
<package id="CSharpTest.Net.Collections" version="14.906.1403.1082" targetFramework="net461" />
|
||||
<package id="Examine" version="1.0.0-beta020" targetFramework="net461" />
|
||||
<package id="Examine" version="1.0.0-beta024" targetFramework="net461" />
|
||||
<package id="ImageProcessor" version="2.5.4" targetFramework="net461" />
|
||||
<package id="ImageProcessor.Web" version="4.8.4" targetFramework="net461" />
|
||||
<package id="ImageProcessor.Web.Config" version="2.3.0.0" targetFramework="net461" />
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Umbraco.Core.Configuration;
|
||||
using System;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Web.Install.Models;
|
||||
|
||||
namespace Umbraco.Web.Install.InstallSteps
|
||||
@@ -9,26 +11,28 @@ namespace Umbraco.Web.Install.InstallSteps
|
||||
[InstallSetupStep(InstallationType.Upgrade, "Upgrade", "upgrade", 1, "Upgrading Umbraco to the latest and greatest version.")]
|
||||
internal class UpgradeStep : InstallSetupStep<object>
|
||||
{
|
||||
public override bool RequiresExecution(object model)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public override bool RequiresExecution(object model) => true;
|
||||
|
||||
public override InstallSetupResult Execute(object model)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override InstallSetupResult Execute(object model) => null;
|
||||
|
||||
public override object ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
// fixme where is the "detected current version"?
|
||||
var currentVersion = UmbracoVersion.Local.ToString();
|
||||
var newVersion = UmbracoVersion.Current.ToString();
|
||||
var newVersion = UmbracoVersion.SemanticVersion.ToString();
|
||||
|
||||
var state = Current.RuntimeState; // fixme inject
|
||||
var currentState = state.CurrentMigrationState;
|
||||
if (string.IsNullOrWhiteSpace(currentState)) currentState = "unknown";
|
||||
var newState = state.FinalMigrationState?.Trim('{', '}');
|
||||
if (string.IsNullOrWhiteSpace(newState)) newState = "unknown";
|
||||
else if (Guid.TryParse(newState, out _))
|
||||
newState = newState.Substring(0, 8);
|
||||
|
||||
var reportUrl = $"https://our.umbraco.org/contribute/releases/compare?from={currentVersion}&to={newVersion}¬es=1";
|
||||
|
||||
return new { currentVersion, newVersion, reportUrl };
|
||||
return new { currentVersion, newVersion, currentState, newState, reportUrl };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,18 +48,13 @@ namespace Umbraco.Web.Search
|
||||
// but greater that SafeXmlReaderWriter priority which is 60
|
||||
private const int EnlistPriority = 80;
|
||||
|
||||
public void Initialize(IRuntimeState runtime, PropertyEditorCollection propertyEditors, IExamineManager examineManager, ProfilingLogger profilingLogger, IScopeProvider scopeProvider, UrlSegmentProviderCollection urlSegmentProviderCollection, ServiceContext services)
|
||||
internal void Initialize(IRuntimeState runtime, MainDom mainDom, PropertyEditorCollection propertyEditors, IExamineManager examineManager, ProfilingLogger profilingLogger, IScopeProvider scopeProvider, UrlSegmentProviderCollection urlSegmentProviderCollection, ServiceContext services)
|
||||
{
|
||||
_services = services;
|
||||
_urlSegmentProviders = urlSegmentProviderCollection;
|
||||
_scopeProvider = scopeProvider;
|
||||
_examineManager = examineManager;
|
||||
|
||||
//fixme we cannot inject MainDom since it's internal, so thsi is the only way we can get it, alternatively we can add the container to the container and resolve
|
||||
//directly from the container but that's not nice either
|
||||
if (!(runtime is RuntimeState coreRuntime))
|
||||
throw new NotSupportedException($"Unsupported IRuntimeState implementation {runtime.GetType().FullName}, expecting {typeof(RuntimeState).FullName}.");
|
||||
|
||||
//We want to manage Examine's appdomain shutdown sequence ourselves so first we'll disable Examine's default behavior
|
||||
//and then we'll use MainDom to control Examine's shutdown
|
||||
ExamineManager.DisableDefaultHostingEnvironmentRegistration();
|
||||
@@ -74,7 +69,7 @@ namespace Umbraco.Web.Search
|
||||
};
|
||||
|
||||
//let's deal with shutting down Examine with MainDom
|
||||
var examineShutdownRegistered = coreRuntime.MainDom.Register(() =>
|
||||
var examineShutdownRegistered = mainDom.Register(() =>
|
||||
{
|
||||
using (profilingLogger.TraceDuration<ExamineComponent>("Examine shutting down"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user