mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Bug fix: Indexing didn't process "unpublish" events
--HG-- branch : dev
This commit is contained in:
@@ -22,24 +22,22 @@ namespace Orchard.Indexing.Handlers {
|
|||||||
_indexingTaskManager = indexingTaskManager;
|
_indexingTaskManager = indexingTaskManager;
|
||||||
_indexNotifierHandlers = indexNotifierHandlers;
|
_indexNotifierHandlers = indexNotifierHandlers;
|
||||||
|
|
||||||
OnPublishing<ContentPart>(CreateIndexingTask);
|
OnPublished<ContentPart>(CreateIndexingTask);
|
||||||
OnRemoved<ContentPart>(RemoveIndexingTask);
|
OnRemoved<ContentPart>(RemoveIndexingTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateIndexingTask(PublishContentContext context, ContentPart part) {
|
void CreateIndexingTask(PublishContentContext context, ContentPart part) {
|
||||||
|
// "Unpublish" case: Same as "remove"
|
||||||
|
if (context.PublishingItemVersionRecord == null) {
|
||||||
|
_indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// "Publish" case: update index
|
||||||
_indexingTaskManager.CreateUpdateIndexTask(context.ContentItem);
|
_indexingTaskManager.CreateUpdateIndexTask(context.ContentItem);
|
||||||
// UpdateIndex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveIndexingTask(RemoveContentContext context, ContentPart part) {
|
void RemoveIndexingTask(RemoveContentContext context, ContentPart part) {
|
||||||
_indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
|
_indexingTaskManager.CreateDeleteIndexTask(context.ContentItem);
|
||||||
// UpdateIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateIndex() {
|
|
||||||
foreach (var handler in _indexNotifierHandlers) {
|
|
||||||
handler.UpdateIndex(SearchIndexName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user