Closed TimoTielens closed 1 year ago
Hi @TimoTielens, thank you for taking the time to report this and create a repository of the issue.
At initial quick glance (from my phone), I'm wondering whether it's because the base class for the custom data-source isn't setting the DataListItem's Value
property?
https://github.com/TimoTielens/ContentmentBugDemo/blob/ffecbd6f96ae4c613a4ae95694a57f2c725c2b1b/src/DemoOfTheBug/ADataListSourceBase.cs#L72
I'll try running your demo site later today.
Hi @leekelleher,
I tested it also with a datasource that doesn't have a base. This also doesn't seem to work.
Note I updated it to the test repository
Hi @TimoTielens,
It's the same issue with your non-base version of the custom data-source, it is missing the Value
property being set.
https://github.com/TimoTielens/ContentmentBugDemo/blob/main/src/DemoOfTheBug/TestDataSource.cs#L82-L87
I have sent you a pull request to explain further, with the patched code, which doesn't throw an error in Umbraco on save/publish. https://github.com/TimoTielens/ContentmentBugDemo/pull/1
I'll close this issue off, as it's not a bug in Contentment itself.
Which Contentment version are you using?
4.5.0
Which Umbraco version are you using? For example: 8.14.1 - don't just write v8
12.2.0
Bug summary
If I use DemoDataSource as the source data for Contentment I have some strange behaviour. In most cases I cannot save the Umbraco node when the contentment item is filled in. If I can save it, the data cannot be fetched from the View.
Steps to reproduce
I created an demo project where you can test and see the behaviour. https://github.com/TimoTielens/ContentmentBugDemo.
If I use DemoDataSource as the source data for Contentment I have some strange behaviour. In most cases I cannot save the Umbraco node when the contentment item is filled in. If I can save it, the data cannot be fetched from the View.
Problem 1 - Cannot save If I create an new Umbraco.Community.Contentment.DataList item wihere I use DemoDataSource for the Data Source and one of the following List editors (Buttons, Checkbox list, Item Picker, Radio Button List, Tags (Templated List is not tested)) I cannot save the Umbraco node when the data is selected. If I have not selected any data from the list I can save the node perfectly fine. As soon as the data is filled in I cannot save it.
I get the following error:
An error occurred Object reference not set to an instance of an object.
Exception Details System.NullReferenceException, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: Object reference not set to an instance of an object.
Stacktrace at Umbraco.Extensions.StringExtensions.InvariantStartsWith(String compare, String compareTo) at Umbraco.Community.Contentment.DataEditors.DataListDataValueEditor.GetReferences(Object value)+MoveNext() at Umbraco.Cms.Core.PropertyEditors.DataValueReferenceFactoryCollection.GetAllReferences(IPropertyCollection properties, PropertyEditorCollection propertyEditors) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.ContentRepositoryBase3.PersistRelations(TEntity entity) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent entity) at Umbraco.Cms.Core.Cache.DefaultRepositoryCachePolicy2.Update(TEntity entity, Action1 persistUpdated) at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase2.Save(TEntity entity) at Umbraco.Cms.Core.Services.ContentService.Save(IContent content, Nullable1 userId, ContentScheduleCollection contentSchedule) at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.b56_0(IContent content, ContentScheduleCollection contentSchedule) at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.SaveAndNotify(ContentItemSave contentItem, Func3 saveMethod, Int32 variantCount, Dictionary2 notifications, SimpleNotificationModel globalNotifications, String savedContentHeaderLocalizationAlias, String invariantSavedLocalizationAlias, String variantSavedLocalizationAlias, String cultureForInvariantErrors, ContentScheduleCollection contentSchedule, Boolean& wasCancelled) at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSaveInternal[TVariant](ContentItemSave contentItem, Func3 saveMethod, Func`2 mapToDisplay) at Umbraco.Cms.Web.BackOffice.Controllers.ContentController.PostSave(ContentItemSave contentItem) at lambda_method1202(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gLogged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
Problem 2 - Can be saved but the data is not display in the view. If I create an new Umbraco.Community.Contentment.DataList item wihere I use DemoDataSource for the Data Source and one of the following List editors (Dropdown list) I can save the Umbraco node when the data is selected. When I try to fetch the data from the Model in the view the propery is always null.
Expected result / actual result
That I can save the Umbraco nodes and the data can be handled in the view
Do you have Umbraco ModelsBuilder enabled?
What browsers are you seeing the problem on?
No response