Skip to content

Commit b901b1a

Browse files
authored
Merge pull request #15 from umbraco/deploy-484
deploy-484 RelatedLinksValueConnector expects UDI values, but int val…
2 parents 356a71b + d987bbc commit b901b1a

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/RelatedLinksValueConnector.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,30 @@ public void SetValue(IContentBase content, string alias, string value)
106106
if (!isInternal)
107107
continue;
108108

109-
//Get the UDI value in the JSON
110-
var pickedUdi = GuidUdi.Parse(relatedLink["link"].ToString());
111-
112-
//Lets use entitiy sevice to get the int ID for this item on the new environment
113-
//Get the Id corresponding to the Guid
114-
//it *should* succeed when deploying, due to dependencies management
115-
//nevertheless, assume it can fail, and then create an invalid localLink
116-
var idAttempt = _entityService.GetIdForKey(pickedUdi.Guid, UmbracoObjectTypes.Document);
117-
118-
//Update the JSON back to the int ids on this env
119-
relatedLink["link"] = idAttempt.Success ? idAttempt.Result : 0;
120-
relatedLink["internal"] = idAttempt.Success ? idAttempt.Result : 0;
109+
var relatedLinkValue = relatedLink["link"].ToString();
110+
111+
//Check if related links is stored as an int
112+
if (int.TryParse(relatedLinkValue, out var relatedLinkInt))
113+
{
114+
//Update the JSON back to the int ids on this env
115+
relatedLink["link"] = relatedLinkInt;
116+
relatedLink["internal"] = relatedLinkInt;
117+
}
118+
else
119+
{
120+
//Get the UDI value in the JSON
121+
var pickedUdi = GuidUdi.Parse(relatedLinkValue);
122+
123+
//Lets use entitiy sevice to get the int ID for this item on the new environment
124+
//Get the Id corresponding to the Guid
125+
//it *should* succeed when deploying, due to dependencies management
126+
//nevertheless, assume it can fail, and then create an invalid localLink
127+
var idAttempt = _entityService.GetIdForKey(pickedUdi.Guid, UmbracoObjectTypes.Document);
128+
129+
//Update the JSON back to the int ids on this env
130+
relatedLink["link"] = idAttempt.Success ? idAttempt.Result : 0;
131+
relatedLink["internal"] = idAttempt.Success ? idAttempt.Result : 0;
132+
}
121133
}
122134

123135
//Save the updated JSON with replaced UDIs for int IDs

0 commit comments

Comments
 (0)