V14: Deleted code marked as obsolete for V14 (#15998)

* Obsoletions related to Delivery API

* Fix TypeLoader and TypeFinder tests

* Remove obsolete and default implementations of IFileSource and IFileTypeCollection

* More Delivery API related obsoletions

* VariationContextAccessor related

* ValueFactories obsoletion and fix references

* ValueSetBuilders obsoletions

* ValueConverters obsoletions

* Other obsolete ctors and methods

* Forgotten VariationContextAccessor obsoletion

* More obsoletions

* XPath related obsoletions

* Revert XmlHelper changes

* Delete RenamedRootNavigator and its tests

* Fix test

* XmlHelper obsoletion

* Return null instead of GetXPathValue

* Obsolete entire class instead

* Remove XPath obsoletions from IPublishedCache

* Remove XPath-related if-block that is no longer needed

* Change obsolete msg for classes needed for NuCache

* Moving classes to NuCache and making them internal

* Remove more XPath-related obsoletions

* Remove NavigableNavigator and its tests

* Cleanup

* Remove Xpath references from tests

* Revert interface deletion in MediaCache

* Using XOR operation

Co-authored-by: Nuklon <Nuklon@users.noreply.github.com>

---------

Co-authored-by: Nuklon <Nuklon@users.noreply.github.com>
This commit is contained in:
Elitsa Marinovska
2024-04-09 09:06:48 +02:00
committed by GitHub
parent 187d45860a
commit 9c18cd22e0
103 changed files with 86 additions and 4751 deletions

View File

@@ -1,13 +1,10 @@
using System.Globalization;
using System.Xml.XPath;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Xml;
using Umbraco.Cms.Core.Xml.XPath;
using Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
using Umbraco.Extensions;
@@ -360,82 +357,6 @@ public class ContentCache : PublishedCacheBase, IPublishedContentCache, INavigab
? _snapshot.IsEmpty == false
: _snapshot.GetAtRoot().Any(x => x.PublishedModel != null);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IPublishedContent? GetSingleByXPath(bool preview, string xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetSingleByXPath(iterator);
}
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IPublishedContent? GetSingleByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetSingleByXPath(iterator);
}
private static IPublishedContent? GetSingleByXPath(XPathNodeIterator iterator)
{
if (iterator.MoveNext() == false)
{
return null;
}
var xnav = iterator.Current as NavigableNavigator;
var xcontent = xnav?.UnderlyingObject as NavigableContent;
return xcontent?.InnerContent;
}
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IEnumerable<IPublishedContent> GetByXPath(bool preview, string xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetByXPath(iterator);
}
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IEnumerable<IPublishedContent> GetByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetByXPath(iterator);
}
private static IEnumerable<IPublishedContent> GetByXPath(XPathNodeIterator iterator)
{
iterator = iterator.Clone();
while (iterator.MoveNext())
{
var xnav = iterator.Current as NavigableNavigator;
var xcontent = xnav?.UnderlyingObject as NavigableContent;
if (xcontent == null)
{
continue;
}
yield return xcontent.InnerContent;
}
}
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override XPathNavigator CreateNavigator(bool preview)
{
var source = new Source(this, preview);
var navigator = new NavigableNavigator(source);
return navigator;
}
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override XPathNavigator? CreateNodeNavigator(int id, bool preview)
{
var source = new Source(this, preview);
var navigator = new NavigableNavigator(source);
return navigator.CloneWithNewRoot(id, 0);
}
public override IPublishedContentType? GetContentType(int id) => _snapshot.GetContentType(id);
public override IPublishedContentType? GetContentType(string alias) => _snapshot.GetContentType(alias);

View File

@@ -1,9 +1,6 @@
using System.Xml.XPath;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Xml;
using Umbraco.Cms.Core.Xml.XPath;
using Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
using Umbraco.Extensions;
@@ -93,89 +90,6 @@ public class MediaCache : PublishedCacheBase, IPublishedMediaCache, INavigableDa
#endregion
#region XPath
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IPublishedContent? GetSingleByXPath(bool preview, string xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetSingleByXPath(iterator);
}
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IPublishedContent? GetSingleByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetSingleByXPath(iterator);
}
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IEnumerable<IPublishedContent> GetByXPath(bool preview, string xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetByXPath(iterator);
}
private static IPublishedContent? GetSingleByXPath(XPathNodeIterator iterator)
{
if (iterator.MoveNext() == false)
{
return null;
}
if (iterator.Current is not NavigableNavigator xnav)
{
return null;
}
var xcontent = xnav.UnderlyingObject as NavigableContent;
return xcontent?.InnerContent;
}
public override IEnumerable<IPublishedContent> GetByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars)
{
XPathNavigator navigator = CreateNavigator(preview);
XPathNodeIterator iterator = navigator.Select(xpath, vars);
return GetByXPath(iterator);
}
public override XPathNavigator CreateNavigator(bool preview)
{
var source = new Source(this, preview);
var navigator = new NavigableNavigator(source);
return navigator;
}
private static IEnumerable<IPublishedContent> GetByXPath(XPathNodeIterator iterator)
{
while (iterator.MoveNext())
{
if (iterator.Current is not NavigableNavigator xnav)
{
continue;
}
if (xnav.UnderlyingObject is not NavigableContent xcontent)
{
continue;
}
yield return xcontent.InnerContent;
}
}
public override XPathNavigator? CreateNodeNavigator(int id, bool preview)
{
var source = new Source(this, preview);
var navigator = new NavigableNavigator(source);
return navigator.CloneWithNewRoot(id, 0);
}
#endregion
#region Content types
public override IPublishedContentType? GetContentType(int id) => _snapshot.GetContentType(id);

View File

@@ -0,0 +1,63 @@
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
/// <summary>
/// Represents a content that can be navigated via XPath.
/// </summary>
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v15. Still needed for NuCache")]
internal interface INavigableContent
{
/// <summary>
/// Gets the unique identifier of the navigable content.
/// </summary>
/// <remarks>The root node identifier should be <c>-1</c>.</remarks>
int Id { get; }
/// <summary>
/// Gets the unique identifier of parent of the navigable content.
/// </summary>
/// <remarks>
/// The top-level content parent identifiers should be <c>-1</c> ie the identifier
/// of the root node, whose parent identifier should in turn be <c>-1</c>.
/// </remarks>
int ParentId { get; }
/// <summary>
/// Gets the type of the navigable content.
/// </summary>
INavigableContentType Type { get; }
/// <summary>
/// Gets the unique identifiers of the children of the navigable content.
/// </summary>
IList<int>? ChildIds { get; }
/// <summary>
/// Gets the value of a field of the navigable content for XPath navigation use.
/// </summary>
/// <param name="index">The field index.</param>
/// <returns>The value of the field for XPath navigation use.</returns>
/// <remarks>
/// <para>
/// Fields are attributes or elements depending on their relative index value compared
/// to source.LastAttributeIndex.
/// </para>
/// <para>For attributes, the value must be a string.</para>
/// <para>
/// For elements, the value should an <c>XPathNavigator</c> instance if the field is xml
/// and has content (is not empty), <c>null</c> to indicate that the element is empty, or a string
/// which can be empty, whitespace... depending on what the data type wants to expose.
/// </para>
/// </remarks>
object? Value(int index);
// TODO: implement the following one
///// <summary>
///// Gets the value of a field of the navigable content, for a specified language.
///// </summary>
///// <param name="index">The field index.</param>
///// <param name="languageKey">The language key.</param>
///// <returns>The value of the field for the specified language.</returns>
///// <remarks>...</remarks>
// object Value(int index, string languageKey);
}

View File

@@ -0,0 +1,19 @@
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
/// <summary>
/// Represents the type of a content that can be navigated via XPath.
/// </summary>
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v15. Still needed for NuCache")]
internal interface INavigableContentType
{
/// <summary>
/// Gets the name of the content type.
/// </summary>
string? Name { get; }
/// <summary>
/// Gets the field types of the content type.
/// </summary>
/// <remarks>This includes the attributes and the properties.</remarks>
INavigableFieldType[] FieldTypes { get; }
}

View File

@@ -0,0 +1,23 @@
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
/// <summary>
/// Represents the type of a field of a content that can be navigated via XPath.
/// </summary>
/// <remarks>A field can be an attribute or a property.</remarks>
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v15. Still needed for NuCache")]
internal interface INavigableFieldType
{
/// <summary>
/// Gets the name of the field type.
/// </summary>
string Name { get; }
/// <summary>
/// Gets a method to convert the field value to a string.
/// </summary>
/// <remarks>
/// This is for built-in properties, ie attributes. User-defined properties have their
/// own way to convert their value for XPath.
/// </remarks>
Func<object, string>? XmlStringConverter { get; }
}

View File

@@ -0,0 +1,31 @@
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
/// <summary>
/// Represents a source of content that can be navigated via XPath.
/// </summary>
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v15. Still needed for NuCache")]
internal interface INavigableSource
{
/// <summary>
/// Gets the index of the last attribute in the fields collections.
/// </summary>
int LastAttributeIndex { get; }
/// <summary>
/// Gets the content at the root of the source.
/// </summary>
/// <remarks>
/// That content should have unique identifier <c>-1</c> and should not be gettable,
/// ie Get(-1) should return null. Its <c>ParentId</c> should be <c>-1</c>. It should provide
/// values for the attribute fields.
/// </remarks>
INavigableContent Root { get; }
/// <summary>
/// Gets a content identified by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier.</param>
/// <returns>The content identified by the unique identifier, or null.</returns>
/// <remarks>When <c>id</c> is <c>-1</c> (root content) implementations should return <c>null</c>.</remarks>
INavigableContent? Get(int id);
}

View File

@@ -1,5 +1,4 @@
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Xml.XPath;
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
@@ -62,15 +61,8 @@ internal class NavigableContent : INavigableContent
return _builtInValues[index];
}
index -= NavigableContentType.BuiltinProperties.Length;
IPublishedProperty[] properties = _content.PropertiesArray;
if (index >= properties.Length)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
// custom property, ie element
return properties[index].GetXPathValue();
return null;
}
#endregion

View File

@@ -1,7 +1,6 @@
using System.Runtime.CompilerServices;
using System.Xml;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Xml.XPath;
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;

View File

@@ -1,5 +1,3 @@
using Umbraco.Cms.Core.Xml.XPath;
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
internal class NavigablePropertyType : INavigableFieldType

View File

@@ -1,5 +1,3 @@
using Umbraco.Cms.Core.Xml.XPath;
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;
internal class RootContent : INavigableContent

View File

@@ -1,5 +1,4 @@
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Xml.XPath;
namespace Umbraco.Cms.Infrastructure.PublishedCache.Navigable;

View File

@@ -293,29 +293,6 @@ internal class Property : PublishedPropertyBase
return value;
}
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override object? GetXPathValue(string? culture = null, string? segment = null)
{
_content.VariationContextAccessor.ContextualizeVariation(_variations, _content.Id, ref culture, ref segment);
lock (_locko)
{
CacheValue cacheValues = GetCacheValues(PropertyType.CacheLevel).For(culture, segment);
// initial reference cache level always is .Content
const PropertyCacheLevel initialCacheLevel = PropertyCacheLevel.Element;
if (cacheValues.XPathInitialized)
{
return cacheValues.XPathValue;
}
cacheValues.XPathValue = PropertyType.ConvertInterToXPath(_content, initialCacheLevel, GetInterValue(culture, segment), _isPreviewing);
cacheValues.XPathInitialized = true;
return cacheValues.XPathValue;
}
}
public override object? GetDeliveryApiValue(bool expanding, string? culture = null, string? segment = null)
{
_content.VariationContextAccessor.ContextualizeVariation(_variations, _content.Id, ref culture, ref segment);