Finds all other instances where a reader would be executed inside another reader's loop and fixes
This commit is contained in:
@@ -64,7 +64,8 @@ namespace Umbraco.Core.Cache
|
||||
[UmbracoWillObsolete("This cache key is only used for legacy business logic caching, remove in v8")]
|
||||
public const string ContentTypePropertiesCacheKey = "ContentType_PropertyTypes_Content:";
|
||||
|
||||
[UmbracoWillObsolete("This cache key is only used for legacy business logic caching, remove in v8")]
|
||||
[Obsolete("No longer used and will be removed in v8")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public const string PropertyTypeCacheKey = "UmbracoPropertyTypeCache";
|
||||
|
||||
[Obsolete("This is no longer used and will be removed from the codebase in the future")]
|
||||
|
||||
@@ -203,15 +203,10 @@ namespace Umbraco.Core
|
||||
var path = Path.Combine(GlobalSettings.FullpathToRoot, "App_Data", "Umbraco.sdf");
|
||||
if (File.Exists(path) == false)
|
||||
{
|
||||
var engine = new SqlCeEngine(connectionString);
|
||||
engine.CreateDatabase();
|
||||
|
||||
// SD: Pretty sure this should be in a using clause but i don't want to cause unknown side-effects here
|
||||
// since it's been like this for quite some time
|
||||
//using (var engine = new SqlCeEngine(connectionString))
|
||||
//{
|
||||
// engine.CreateDatabase();
|
||||
//}
|
||||
using (var engine = new SqlCeEngine(connectionString))
|
||||
{
|
||||
engine.CreateDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
Initialize(providerName);
|
||||
|
||||
@@ -131,9 +131,7 @@ namespace Umbraco.Web.Cache
|
||||
ClearAllIsolatedCacheByEntityType<IMediaType>();
|
||||
ClearAllIsolatedCacheByEntityType<IMember>();
|
||||
ClearAllIsolatedCacheByEntityType<IMemberType>();
|
||||
|
||||
//all property type cache
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.PropertyTypeCacheKey);
|
||||
|
||||
//all content type property cache
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheByKeySearch(CacheKeys.ContentTypePropertiesCacheKey);
|
||||
//all content type cache
|
||||
@@ -266,12 +264,6 @@ namespace Umbraco.Web.Cache
|
||||
/// </returns>
|
||||
private static void ClearContentTypeCache(JsonPayload payload)
|
||||
{
|
||||
//clears the cache for each property type associated with the content type
|
||||
foreach (var pid in payload.PropertyTypeIds)
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(CacheKeys.PropertyTypeCacheKey + pid);
|
||||
}
|
||||
|
||||
//clears the cache associated with the Content type itself
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(string.Format("{0}{1}", CacheKeys.ContentTypeCacheKey, payload.Id));
|
||||
//clears the cache associated with the content type properties collection
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using Umbraco.Core.IO;
|
||||
using System.Linq;
|
||||
@@ -11,6 +12,8 @@ namespace umbraco.controls
|
||||
/// <summary>
|
||||
/// Summary description for ContentTypeControl.
|
||||
/// </summary>
|
||||
[Obsolete("No longer used, will be removed in v8")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public class ContentTypeControl : uicontrols.TabView
|
||||
{
|
||||
public event System.EventHandler OnSave;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Configuration.Provider;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
@@ -320,13 +321,14 @@ namespace umbraco.cms.presentation.user
|
||||
}
|
||||
|
||||
// Populate dropdowns
|
||||
foreach (DocumentType dt in DocumentType.GetAllAsList())
|
||||
cDocumentType.Items.Add(
|
||||
new ListItem(dt.Text, dt.Alias)
|
||||
);
|
||||
var allContentTypes = Services.ContentTypeService.GetAllContentTypes().ToList();
|
||||
foreach (var dt in allContentTypes)
|
||||
{
|
||||
cDocumentType.Items.Add(new ListItem(dt.Name, dt.Alias));
|
||||
}
|
||||
|
||||
// populate fields
|
||||
ArrayList fields = new ArrayList();
|
||||
var fields = new ArrayList();
|
||||
cDescription.ID = "cDescription";
|
||||
cCategories.ID = "cCategories";
|
||||
cExcerpt.ID = "cExcerpt";
|
||||
@@ -334,9 +336,9 @@ namespace umbraco.cms.presentation.user
|
||||
cCategories.Items.Add(new ListItem(ui.Text("choose"), ""));
|
||||
cExcerpt.Items.Add(new ListItem(ui.Text("choose"), ""));
|
||||
|
||||
foreach (PropertyType pt in PropertyType.GetAll())
|
||||
foreach (var pt in allContentTypes.SelectMany(x => x.PropertyTypes).OrderBy(x => x.Name))
|
||||
{
|
||||
if (!fields.Contains(pt.Alias))
|
||||
if (fields.Contains(pt.Alias) == false)
|
||||
{
|
||||
cDescription.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias));
|
||||
cCategories.Items.Add(new ListItem(string.Format("{0} ({1})", pt.Name, pt.Alias), pt.Alias));
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace umbraco.cms.businesslogic.Tags
|
||||
{
|
||||
Document cnode = new Document(rr.GetInt("nodeid"));
|
||||
|
||||
if (cnode != null && cnode.Published)
|
||||
if (cnode.Published)
|
||||
docs.Add(cnode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,32 +54,31 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
public PropertyType(int id)
|
||||
{
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr = sqlHelper.ExecuteReader(
|
||||
"Select mandatory, DataTypeId, propertyTypeGroupId, ContentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id",
|
||||
sqlHelper.CreateParameter("@id", id)))
|
||||
var found = ApplicationContext.Current.DatabaseContext.Database
|
||||
.SingleOrDefault<dynamic>(
|
||||
"Select mandatory, DataTypeId, propertyTypeGroupId, contentTypeId, sortOrder, alias, name, validationRegExp, description from cmsPropertyType where id=@id",
|
||||
new {id = id});
|
||||
|
||||
if (found == null)
|
||||
throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!");
|
||||
|
||||
_mandatory = found.mandatory;
|
||||
_id = id;
|
||||
|
||||
if (found.propertyTypeGroupId != null)
|
||||
{
|
||||
if (!dr.Read())
|
||||
throw new ArgumentException("Propertytype with id: " + id + " doesnt exist!");
|
||||
|
||||
_mandatory = dr.GetBoolean("mandatory");
|
||||
_id = id;
|
||||
|
||||
if (!dr.IsNull("propertyTypeGroupId"))
|
||||
{
|
||||
_propertyTypeGroup = dr.GetInt("propertyTypeGroupId");
|
||||
//TODO: Remove after refactoring!
|
||||
_tabId = _propertyTypeGroup;
|
||||
}
|
||||
|
||||
_sortOrder = dr.GetInt("sortOrder");
|
||||
_alias = dr.GetString("alias");
|
||||
_name = dr.GetString("Name");
|
||||
_validationRegExp = dr.GetString("validationRegExp");
|
||||
_DataTypeId = dr.GetInt("DataTypeId");
|
||||
_contenttypeid = dr.GetInt("contentTypeId");
|
||||
_description = dr.GetString("description");
|
||||
_propertyTypeGroup = found.propertyTypeGroupId;
|
||||
//TODO: Remove after refactoring!
|
||||
_tabId = _propertyTypeGroup;
|
||||
}
|
||||
|
||||
_sortOrder = found.sortOrder;
|
||||
_alias = found.alias;
|
||||
_name = found.name;
|
||||
_validationRegExp = found.validationRegExp;
|
||||
_DataTypeId = found.DataTypeId;
|
||||
_contenttypeid = found.contentTypeId;
|
||||
_description = found.description;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -92,7 +91,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_DataTypeId = value.Id;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery(
|
||||
"Update cmsPropertyType set DataTypeId = " + value.Id + " where id=" + Id);
|
||||
@@ -119,7 +117,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
{
|
||||
_tabId = value;
|
||||
PropertyTypeGroup = value;
|
||||
InvalidateCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +145,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_mandatory = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set mandatory = @mandatory where id = @id",
|
||||
sqlHelper.CreateParameter("@mandatory", value),
|
||||
@@ -162,7 +158,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_validationRegExp = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set validationRegExp = @validationRegExp where id = @id",
|
||||
sqlHelper.CreateParameter("@validationRegExp", value), sqlHelper.CreateParameter("@id", Id));
|
||||
@@ -199,7 +194,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_description = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set description = @description where id = @id",
|
||||
sqlHelper.CreateParameter("@description", value),
|
||||
@@ -213,7 +207,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_sortOrder = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set sortOrder = @sortOrder where id = @id",
|
||||
sqlHelper.CreateParameter("@sortOrder", value),
|
||||
@@ -227,7 +220,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_alias = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery("Update cmsPropertyType set alias = @alias where id= @id",
|
||||
sqlHelper.CreateParameter("@alias", Casing.SafeAliasWithForcingCheck(_alias)),
|
||||
@@ -264,7 +256,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
InvalidateCache();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
sqlHelper.ExecuteNonQuery(
|
||||
"UPDATE cmsPropertyType SET name=@name WHERE id=@id",
|
||||
@@ -331,17 +322,17 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
public static IEnumerable<PropertyType> GetPropertyTypes()
|
||||
{
|
||||
var result = new List<PropertyType>();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr =
|
||||
sqlHelper.ExecuteReader("select id from cmsPropertyType order by Name"))
|
||||
|
||||
var propertyTypeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"select id from cmsPropertyType order by Name");
|
||||
|
||||
foreach (var propertyTypeId in propertyTypeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
PropertyType pt = GetPropertyType(dr.GetInt("id"));
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
PropertyType pt = GetPropertyType(propertyTypeId);
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -353,18 +344,17 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
public static IEnumerable<PropertyType> GetPropertyTypesByGroup(int groupId)
|
||||
{
|
||||
var result = new List<PropertyType>();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr =
|
||||
sqlHelper.ExecuteReader("SELECT id FROM cmsPropertyType WHERE propertyTypeGroupId = @groupId order by SortOrder",
|
||||
sqlHelper.CreateParameter("@groupId", groupId)))
|
||||
|
||||
var propertyTypeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"SELECT id FROM cmsPropertyType WHERE propertyTypeGroupId = @groupId order by SortOrder", new {groupId = groupId});
|
||||
|
||||
foreach (var propertyTypeId in propertyTypeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
PropertyType pt = GetPropertyType(dr.GetInt("id"));
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
PropertyType pt = GetPropertyType(propertyTypeId);
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -376,20 +366,18 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
public static IEnumerable<PropertyType> GetByDataTypeDefinition(int dataTypeDefId)
|
||||
{
|
||||
var result = new List<PropertyType>();
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr =
|
||||
sqlHelper.ExecuteReader(
|
||||
"select id, Name from cmsPropertyType where dataTypeId=@dataTypeId order by Name",
|
||||
sqlHelper.CreateParameter("@dataTypeId", dataTypeDefId)))
|
||||
|
||||
var propertyTypeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"select id from cmsPropertyType where dataTypeId=@dataTypeId order by Name", new {dataTypeId = dataTypeDefId});
|
||||
|
||||
foreach (var propertyTypeId in propertyTypeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
PropertyType pt = GetPropertyType(dr.GetInt("id"));
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
PropertyType pt = GetPropertyType(propertyTypeId);
|
||||
if (pt != null)
|
||||
result.Add(pt);
|
||||
}
|
||||
return result.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void delete()
|
||||
@@ -411,7 +399,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
// delete cache from either master (via tabid) or current contentype
|
||||
FlushCacheBasedOnTab();
|
||||
InvalidateCache();
|
||||
}
|
||||
|
||||
public void FlushCacheBasedOnTab()
|
||||
@@ -478,8 +465,6 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
protected virtual void FlushCache()
|
||||
{
|
||||
// clear local cache
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(GetCacheKey(Id));
|
||||
|
||||
// clear cache in contentype
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(CacheKeys.ContentTypePropertiesCacheKey + _contenttypeid);
|
||||
@@ -496,31 +481,9 @@ namespace umbraco.cms.businesslogic.propertytype
|
||||
|
||||
public static PropertyType GetPropertyType(int id)
|
||||
{
|
||||
return ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem<PropertyType>(
|
||||
GetCacheKey(id),
|
||||
timeout: TimeSpan.FromMinutes(30),
|
||||
getCacheItem: () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PropertyType(id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void InvalidateCache()
|
||||
{
|
||||
ApplicationContext.Current.ApplicationCache.RuntimeCache.ClearCacheItem(GetCacheKey(Id));
|
||||
}
|
||||
|
||||
private static string GetCacheKey(int id)
|
||||
{
|
||||
return CacheKeys.PropertyTypeCacheKey + id;
|
||||
return new PropertyType(id);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -433,21 +433,20 @@ namespace umbraco.cms.businesslogic.web
|
||||
{
|
||||
XmlDocument xd = new XmlDocument();
|
||||
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader dr = sqlHelper.ExecuteReader("select nodeId from cmsDocument"))
|
||||
var nodeIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
"select nodeId from cmsDocument");
|
||||
|
||||
foreach (var nodeId in nodeIds)
|
||||
{
|
||||
while (dr.Read())
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
new Document(dr.GetInt("nodeId")).SaveXmlPreview(xd);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
LogHelper.Error<Document>("Error generating preview xml", ee);
|
||||
}
|
||||
new Document(nodeId).SaveXmlPreview(xd);
|
||||
}
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
LogHelper.Error<Document>("Error generating preview xml", ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using umbraco.BusinessLogic; // ApplicationBase
|
||||
// ApplicationBase
|
||||
using umbraco.businesslogic;
|
||||
using umbraco.cms.businesslogic; // SaveEventArgs
|
||||
using umbraco.cms.businesslogic.media; // Media
|
||||
@@ -12,6 +11,8 @@ using umbraco.cms.businesslogic.web; // Documentusing umbraco.cms.businesslogic.
|
||||
using umbraco.cms.businesslogic.property;
|
||||
using umbraco.cms.businesslogic.relation;
|
||||
using umbraco.DataLayer;
|
||||
using Umbraco.Core;
|
||||
using Application = umbraco.BusinessLogic.Application;
|
||||
|
||||
namespace umbraco.editorControls.PickerRelations
|
||||
{
|
||||
@@ -212,7 +213,7 @@ namespace umbraco.editorControls.PickerRelations
|
||||
private static void DeleteRelations(RelationType relationType, int contentNodeId, bool reverseIndexing, string instanceIdentifier)
|
||||
{
|
||||
//if relationType is bi-directional or a reverse index then we can't get at the relations via the API, so using SQL
|
||||
string getRelationsSql = "SELECT id FROM umbracoRelation WHERE relType = " + relationType.Id.ToString() + " AND ";
|
||||
string getRelationsSql = "SELECT id FROM umbracoRelation WHERE relType = " + relationType.Id + " AND ";
|
||||
|
||||
if (reverseIndexing || relationType.Dual)
|
||||
{
|
||||
@@ -229,19 +230,16 @@ namespace umbraco.editorControls.PickerRelations
|
||||
|
||||
getRelationsSql += " AND comment = '" + instanceIdentifier + "'";
|
||||
|
||||
using (var sqlHelper = Application.SqlHelper)
|
||||
using (IRecordsReader relations = sqlHelper.ExecuteReader(getRelationsSql))
|
||||
{
|
||||
//clear data
|
||||
Relation relation;
|
||||
while (relations.Read())
|
||||
{
|
||||
relation = new Relation(relations.GetInt("id"));
|
||||
var relationIds = ApplicationContext.Current.DatabaseContext.Database.Fetch<int>(
|
||||
getRelationsSql);
|
||||
foreach (var relationId in relationIds)
|
||||
{
|
||||
var relation = new Relation(relationId);
|
||||
|
||||
// TODO: [HR] check to see if an instance identifier is used
|
||||
relation.Delete();
|
||||
}
|
||||
}
|
||||
// TODO: [HR] check to see if an instance identifier is used
|
||||
relation.Delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user