Umbraco-CMS
Umbraco-CMS copied to clipboard
fix udi leaking in the management api
Description
UDI's are an internal (backend) notation to differentiate multiple string based Guids for different resources. This should ideally not be leaked trough the management api.
The aim is to keep the UDI's in the persistance layer, but not present them trough the managment api. So we need a conversion from and to the persistance layer. This is accomplished by overwriting the DataValueEditor.ToEditor() & .FromEditor() for each propertyEditor that currently leaks UDI's
Content picker
Straightforward conversion to the guid in the UDI and back. Also received a int conversion FROM the db as it might contain old values when upgrading.
MultiNodeTreePicker
Configuration dictates what the type is when picking, so use that to build the UDI and store it. Going the other way, we simple return the extracted value. If the configuration has changed between saving and retrieving, then the client will get a not found on the picked items just as if they had been deleted.
MultiUrlPicker
Client will now pass in a different model that gives a type
and unique
value. if the type
is not link, we parse it to a UDI.
Updated the LinkDisplay model to mirror the new client model and added static helper methods to make the local ValueEditor mapping logic more readable
Rich Text Editor & Blocks
Will be tackled later
Testing
- Consider creating a documentType + document with properties for all mentioned property editors that hold all permutations of content references (document,media,external) on an instance from before this PR and.
- Create the same documenttype + document on an instance running this PR
- When posting the document, it should not contain UDIs for any of the properties (see example below) and the value in the database should have the UDIs in place.
Example post body
{
"urls": [],
"template": null,
"values": [
{
"culture": null,
"segment": null,
"alias": "contentPicker",
"value": "a3c498b2-6304-4d69-8005-d51d5bbe80f3"
},
{
"culture": null,
"segment": null,
"alias": "mntpdocument",
"value": ["a3c498b2-6304-4d69-8005-d51d5bbe80f3","a3c498b2-6304-4d69-8005-d51d5bbe80f3"]
},
{
"culture": null,
"segment": null,
"alias": "mntpmedia",
"value": ["a3c498b2-6304-4d69-8005-d51d5bbe80f3","a3c498b2-6304-4d69-8005-d51d5bbe80f3"]
},
{
"culture": null,
"segment": null,
"alias": "multiUrl",
"value": [
{
"name" : "externalLink",
"type" : "external",
"url" : "https://google.dk"
},
{
"name" : "documentLink",
"type" : "document",
"unique" : "a3c498b2-6304-4d69-8005-d51d5bbe80f3"
},
{
"name" : "mediaLink",
"type" : "media",
"unique" : "a3c498b2-6304-4d69-8005-d51d5bbe80f3"
}
]
}
],
"variants": [
{
"state": "Draft",
"publishDate": null,
"createDate": "2024-02-07T14:17:54.2708025",
"updateDate": "2024-02-07T14:17:54.2708025",
"culture": null,
"segment": null,
"name": "other document"
}
]
}