Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Blocks: Handle JArray data (typically when nested) #391

Conversation

marcemarc
Copy link
Contributor

Description

Handle the 'sometimes' when the stored ContentBlock data appears as a JArray instead of a string

In some circumstances

eg when a ContentmentBlocks is nested inside the Core Umbraco BlockList

(yes I know)

and it's moved between environments (uSync/Cloud) then the ContentBlock content although 'transferred' successfully doesn't get rendered by the ContentBlocksValueConverter because of the check to see if it is a string.

When Umbraco saves ContentBlocks within the BlockList JSON, then it escapes all the things \\\ and when it's ready in the ConvertSourceToIntermediate it is interpreted as a string as it's no longer valid JArray...

but when it's moved by a serialisation/deserialisation tool, then actually the stored value is a valid JArray and Umbraco returns the object to ConvertSourceToIntermediate as a JArray...

... which is why this PropertyValueConverter skips displaying it ...

(but it loads the content fine in the backoffice)

this pragmatic suggestion sort of caters for this quite niche scenario - but also I don't think does any harm to non-niche scenarios and is the place in the whole setup with the least moving parts, but also also, spiritually I recognise this probably isn't the internationally agreed place to fix this sort of thing...

Related Issues?

Here is a related conversation: Jumoo/uSync.Complete.Issues#226

Types of changes

  • Documentation change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Pragmatic Hack

Checklist

  • My code follows the coding style of this project.
  • My changes generate no new warnings.
  • My change requires a change to the documentation.
  • I have updated the corresponding documentation.
  • I have read the CONTRIBUTING and CODE_OF_CONDUCT documents.

… JArray instead of a string

In some circumstances

eg when a ContentmentBlocks is nested inside the Core Umbraco BlockList 

(yes I know)

and it's moved between environments (uSync/Cloud) then the ContentBlock content although 'transferred' successfully doesn't get rendered by the ContentBlocksValueConverter because of the check to see if it is a string.

When Umbraco saves ContentBlocks within the BlockList JSON, then it escapes all the things \\\\\\ and when it's ready in the ConvertSourceToIntermediate it is interpreted as a string as it's no longer valid JArray...

but when it's moved by a serialisation/deserialisation tool, then actually the stored value is a valid JArray and Umbraco returns the object to ConvertSourceToIntermediate as a JArray...

... which is why this PropertyValueConverter skips displaying it ...

(but it loads the content fine in the backoffice)

this pragmatic suggestion sort of caters for this quite niche scenario - but also I don't think does any harm to non-niche scenarios and is the place in the whole setup with the least moving parts, but also also, spiritually I recognise this probably isn't the internationally agreed place to fix this sort of thing...
@leekelleher leekelleher self-assigned this Apr 6, 2024
@leekelleher leekelleher self-requested a review April 11, 2024 10:46
@leekelleher
Copy link
Owner

@marcemarc Just to note, I haven't forgotten about this. I'll try to take a look towards the end of this week, (once the Umb v14 RC is release).

@marcemarc
Copy link
Contributor Author

Thanks @leekelleher I haven't forgotten either :-P we are running a patched version of Contentment in production and it's solved the issue, it wasn't just an issue when it was embedded inside block list, but also when it was just a contentment blocks property editor....

@leekelleher leekelleher changed the title Handle the 'sometimes' when the stored ContentBlock data appears as a… Content Blocks: Handle JArray data (typically when nested) Apr 19, 2024
Copy link
Owner

@leekelleher leekelleher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, thanks @marcemarc!

I made an adjustment with the JArray deserialization, to save doing the .ToString() step.

I'll aim to get a patch release out soon.

@leekelleher leekelleher merged commit 82c7327 into leekelleher:develop Apr 19, 2024
@leekelleher
Copy link
Owner

@marcemarc ...and it's been released in Contentment v4.7.0!

@marcemarc
Copy link
Contributor Author

Thanking you! @leekelleher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants