Fixed an issue with old aliases being kept in memory.

This commit is contained in:
Sipke Schoorstra
2015-07-21 13:11:24 +01:00
parent a9ff7d5973
commit f60643d460
4 changed files with 10 additions and 25 deletions

View File

@@ -73,7 +73,7 @@ namespace Orchard.Autoroute.Handlers {
}
// Update the home alias to point to this item being published.
_homeAliasService.SetHomeAlias(part);
_homeAliasService.PublishHomeAlias(part);
}
_autorouteService.Value.PublishAlias(part);

View File

@@ -113,23 +113,6 @@ namespace Orchard.Autoroute.Services {
}
public void RemoveAliases(AutoroutePart part) {
//// https://github.com/OrchardCMS/Orchard/issues/5137
//// If the alias of the specified part is empty while not being the homepage,
//// we need to make sure we are not removing all empty aliases in order to prevent losing the homepage content item being the homepage.
//if (String.IsNullOrWhiteSpace(part.Path)) {
// if (!IsHomePage(part)) {
// // The item being removed is NOT the homepage, so we need to make sure we're not removing the alias for the homepage.
// var aliasRecordId = GetHomePageAliasRecordId();
// // Remove all aliases EXCEPT for the alias of the homepage.
// _aliasStorage.Remove(x => x.Path == part.Path && x.Source == AliasSource && x.Id != aliasRecordId);
// // Done.
// return;
// }
//}
//// Safe to delete all aliases for the specified part since it is definitely not the homepage.
_aliasService.Delete(part.Path, AliasSource);
}

View File

@@ -37,16 +37,18 @@ namespace Orchard.Autoroute.Services {
return homePage;
}
public void SetHomeAlias(IContent content) {
public void PublishHomeAlias(IContent content) {
var routeValues = _contentManager.GetItemMetadata(content).DisplayRouteValues;
SetHomeAlias(routeValues);
PublishHomeAlias(routeValues);
}
public void SetHomeAlias(string route) {
public void PublishHomeAlias(string route) {
_aliasService.DeleteBySource(AliasSource);
_aliasService.Set(HomeAlias, route, AliasSource);
}
public void SetHomeAlias(RouteValueDictionary route) {
public void PublishHomeAlias(RouteValueDictionary route) {
_aliasService.DeleteBySource(AliasSource);
_aliasService.Set(HomeAlias, route, AliasSource);
}
}

View File

@@ -7,8 +7,8 @@ namespace Orchard.Autoroute.Services {
RouteValueDictionary GetHomeRoute();
int? GetHomePageId();
IContent GetHomePage(VersionOptions version = null);
void SetHomeAlias(IContent content);
void SetHomeAlias(string route);
void SetHomeAlias(RouteValueDictionary route);
void PublishHomeAlias(IContent content);
void PublishHomeAlias(string route);
void PublishHomeAlias(RouteValueDictionary route);
}
}