From 5aa397501026e7606ea0a884e885e0548b95b8f8 Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Tue, 13 Feb 2024 12:09:22 +0100 Subject: [PATCH] IBX-7579:Richtext: Rows are added to ezurl_object_link on every save --- src/lib/eZ/FieldType/RichText/RichTextStorage.php | 5 ++++- .../eZ/FieldType/RichText/RichTextStorage/Gateway.php | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/eZ/FieldType/RichText/RichTextStorage.php b/src/lib/eZ/FieldType/RichText/RichTextStorage.php index e59029ad..2286c519 100644 --- a/src/lib/eZ/FieldType/RichText/RichTextStorage.php +++ b/src/lib/eZ/FieldType/RichText/RichTextStorage.php @@ -83,7 +83,10 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $co $urlIdMap = $this->gateway->getUrlIdMap(array_keys($urlSet)); $contentIds = $this->gateway->getContentIds(array_keys($remoteIdSet)); - $urlLinkSet = []; + $urlLinkSet = $this->gateway->getUrlsFromUrlLink( + $field->id, + $versionInfo->versionNo + ); foreach ($links as $index => $link) { list(, $scheme, $url, $fragment) = $linksInfo[$index]; diff --git a/src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php b/src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php index 2a3e8dd3..03f3415c 100644 --- a/src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php +++ b/src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php @@ -78,6 +78,16 @@ public function insertUrl($url) return $this->urlGateway->insertUrl($url); } + /** + * Return a list of URLs used by the given field and version. + * + * @return bool[] An array of URLs, with urls as keys + */ + public function getUrlsFromUrlLink(int $fieldId, int $versionNo): array + { + return $this->urlGateway->getUrlsFromUrlLink($fieldId, $versionNo); + } + /** * Creates link to URL with $urlId for field with $fieldId in $versionNo. *