Merge branch '1.8.x' into 1.x

Conflicts:
	src/Orchard.Web/Modules/Orchard.Indexing/Settings/EditorEvents.cs
	src/Orchard.Web/Modules/Orchard.MediaLibrary/Views/EditorTemplates/Fields/MediaLibraryPicker.Edit.cshtml
This commit is contained in:
Sebastien Ros
2014-09-19 10:19:29 -07:00
13 changed files with 47 additions and 17 deletions

View File

@@ -42,7 +42,6 @@ namespace Orchard.Core.Scheduling.Services {
foreach (var taskEntry in taskEntries) {
_transactionManager.RequireNew();
_contentManager.Clear();
try {
// fetch the task

View File

@@ -89,7 +89,6 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
pendingAsset.UploadState.BytesComplete = 0;
pendingAsset.UploadState.CompletedUtc = null;
_transactionManager.RequireNew();
_contentManager.Clear();
var assetProgressMoniker = Guid.NewGuid();
var assetCancellationTokenSource = new CancellationTokenSource();
@@ -186,7 +185,6 @@ namespace Orchard.Azure.MediaServices.Services.Assets {
if ((_clock.UtcNow - lastUpdateUtc).Seconds >= 5) {
progressAsset.UploadState.BytesComplete = progressInfo.Data.BytesTransferred;
_transactionManager.RequireNew();
_contentManager.Clear();
lastUpdateUtc = _clock.UtcNow;
}

View File

@@ -207,8 +207,7 @@ namespace Orchard.Indexing.Services {
}
else {
_transactionManager.RequireNew();
_contentManager.Clear();
}
}
} while (loop);
@@ -266,7 +265,6 @@ namespace Orchard.Indexing.Services {
}
else {
_transactionManager.RequireNew();
_contentManager.Clear();
}
}
while (loop);

View File

@@ -26,10 +26,16 @@ namespace Orchard.Indexing.Services {
public ILogger Logger { get; set; }
private void CreateTask(ContentItem contentItem, int action) {
if ( contentItem == null ) {
if (contentItem == null) {
throw new ArgumentNullException("contentItem");
}
if (contentItem.Record == null) {
// ignore that case, when Update is called on a content item which has not be "created" yet
return;
}
foreach (var task in _repository.Table.Where(task => task.ContentItemRecord == contentItem.Record)) {
_repository.Delete(task);
}

View File

@@ -78,10 +78,22 @@ namespace Orchard.Indexing.Settings {
}
private void CreateTasksForType(string type) {
var index = 0;
bool contentItemProcessed;
// todo: load ids only, or create a queued job
// we create a task even for draft items, and the executor will filter based on the settings
foreach (var contentItem in _contentManager.Query(VersionOptions.Latest, new [] { type }).List()) {
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
}
do {
contentItemProcessed = false;
var contentItemsToIndex = _contentManager.Query(VersionOptions.Latest, new [] { type }).Slice(index, 50);
foreach (var contentItem in contentItemsToIndex) {
contentItemProcessed = true;
_indexingTaskManager.CreateUpdateIndexTask(contentItem);
}
} while (contentItemProcessed);
}
}
}

View File

@@ -20,6 +20,8 @@ namespace Orchard.MediaLibrary.Services {
private readonly IStorageProvider _storageProvider;
private readonly IEnumerable<IMediaFactorySelector> _mediaFactorySelectors;
private static char[] HttpUnallowed = new char[] { '<', '>', '*', '%', '&', ':', '\\', '?' };
public MediaLibraryService(
IOrchardServices orchardServices,
IMimeTypeProvider mimeTypeProvider,
@@ -125,6 +127,12 @@ namespace Orchard.MediaLibrary.Services {
}
public string GetUniqueFilename(string folderPath, string filename) {
// remove any char which is unallowed in an HTTP request
foreach (var unallowedChar in HttpUnallowed) {
filename = filename.Replace(unallowedChar.ToString(), "");
}
// compute a unique filename
var uniqueFilename = filename;
var index = 1;

View File

@@ -47,6 +47,8 @@
.overlay h3 {
padding-right:5px;
font-size: 12px;
height: 40px;
overflow: hidden;
}
.media-thumbnail {

View File

@@ -2,6 +2,8 @@
@using Orchard.MediaLibrary.Settings;
@{
var settings = Model.Field.PartFieldDefinition.Settings.GetModel<MediaLibraryPickerFieldSettings>();
<div class="thumbnail" title="@Html.ItemDisplayText(contentItem)">
<h3>@Html.ItemDisplayText(contentItem)</h3>
}
@Display.MediaLibraryPicker(
FieldName: Html.FieldNameFor(m => m.SelectedIds),

View File

@@ -129,7 +129,7 @@ namespace Orchard.Projections.Services {
var contentItems = new List<ContentItem>();
// aggregate the result for each group query
foreach(var contentQuery in GetContentQueries(queryRecord, queryRecord.SortCriteria)) {
foreach(var contentQuery in GetContentQueries(queryRecord, queryRecord.SortCriteria.OrderBy(sc => sc.Position))) {
contentItems.AddRange(contentQuery.Slice(skip, count));
}

View File

@@ -63,7 +63,6 @@ namespace Orchard.Recipes.RecipeHandlers {
//Create a new transaction for each batch
if (startIndex < elementDictionary.Count) {
_transactionManager.RequireNew();
_orchardServices.ContentManager.Clear();
}
}
}

View File

@@ -649,9 +649,6 @@ namespace Orchard.ContentManagement {
}
public void Clear() {
var session = _sessionLocator.Value.For(typeof(ContentItemRecord));
session.Clear();
_contentManagerSession().Clear();
}
public IContentQuery<ContentItem> Query() {

View File

@@ -6,6 +6,7 @@ using System.Linq;
using NHibernate;
using NHibernate.SqlCommand;
using NHibernate.Type;
using Orchard.ContentManagement;
using Orchard.Exceptions;
using Orchard.Logging;
using Orchard.Security;
@@ -14,13 +15,19 @@ namespace Orchard.Data {
public class SessionLocator : ISessionLocator, ITransactionManager, IDisposable {
private readonly ISessionFactoryHolder _sessionFactoryHolder;
private readonly IEnumerable<ISessionInterceptor> _interceptors;
private Func<IContentManagerSession> _contentManagerSessionFactory;
private ISession _session;
private IContentManagerSession _contentManagerSession;
public SessionLocator(
ISessionFactoryHolder sessionFactoryHolder,
ISessionFactoryHolder sessionFactoryHolder,
Func<IContentManagerSession> contentManagerSessionFactory,
IEnumerable<ISessionInterceptor> interceptors) {
_sessionFactoryHolder = sessionFactoryHolder;
_interceptors = interceptors;
_contentManagerSessionFactory = contentManagerSessionFactory;
Logger = NullLogger.Instance;
IsolationLevel = IsolationLevel.ReadCommitted;
}
@@ -69,6 +76,8 @@ namespace Orchard.Data {
}
}
finally {
_contentManagerSession.Clear();
Logger.Debug("Disposing session");
_session.Close();
_session.Dispose();
@@ -86,6 +95,7 @@ namespace Orchard.Data {
Logger.Debug("Opening NHibernate session");
_session = sessionFactory.OpenSession(new OrchardSessionInterceptor(_interceptors.ToArray(), Logger));
_session.BeginTransaction(level);
_contentManagerSession = _contentManagerSessionFactory();
}
class OrchardSessionInterceptor : IInterceptor {

View File

@@ -36,7 +36,6 @@ namespace Orchard.Tasks {
public void Sweep() {
foreach(var task in _tasks) {
try {
_contentManager.Clear();
_transactionManager.RequireNew();
task.Sweep();
}