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

IBX-7579:Richtext: Rows are added to ezurl_object_link on every save #242

Open
wants to merge 2 commits into
base: 2.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/lib/eZ/FieldType/RichText/RichTextStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
16 changes: 16 additions & 0 deletions src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@
return $this->urlGateway->insertUrl($url);
}

/**
* Return a list of URLs used by the given field and version.
*
* array<string, boolean> An array of URLs, with urls as keys
*/
public function getUrlsFromUrlLink(int $fieldId, int $versionNo): array

Check failure on line 86 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (7.3)

Method EzSystems\EzPlatformRichText\eZ\FieldType\RichText\RichTextStorage\Gateway::getUrlsFromUrlLink() return type has no value type specified in iterable type array.

Check failure on line 86 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (7.4)

Method EzSystems\EzPlatformRichText\eZ\FieldType\RichText\RichTextStorage\Gateway::getUrlsFromUrlLink() return type has no value type specified in iterable type array.

Check failure on line 86 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (8.0)

Method EzSystems\EzPlatformRichText\eZ\FieldType\RichText\RichTextStorage\Gateway::getUrlsFromUrlLink() return type has no value type specified in iterable type array.

Check failure on line 86 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (8.1)

Method EzSystems\EzPlatformRichText\eZ\FieldType\RichText\RichTextStorage\Gateway::getUrlsFromUrlLink() return type has no value type specified in iterable type array.
{
$rows = $this->urlGateway->getUrlsFromUrlLink($fieldId, $versionNo);

Check failure on line 88 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (7.3)

Call to an undefined method eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway::getUrlsFromUrlLink().

Check failure on line 88 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (7.4)

Call to an undefined method eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway::getUrlsFromUrlLink().

Check failure on line 88 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (8.0)

Call to an undefined method eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway::getUrlsFromUrlLink().

Check failure on line 88 in src/lib/eZ/FieldType/RichText/RichTextStorage/Gateway.php

View workflow job for this annotation

GitHub Actions / Tests (8.1)

Call to an undefined method eZ\Publish\Core\FieldType\Url\UrlStorage\Gateway::getUrlsFromUrlLink().
$result = [];
foreach ($rows as $url) {
$result[$url] = true;
}

return $result;
}

/**
* Creates link to URL with $urlId for field with $fieldId in $versionNo.
*
Expand Down
14 changes: 12 additions & 2 deletions tests/lib/eZ/FieldType/RichText/RichTextStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ public function testStoreFieldDataThrowsNotFoundException(
->method('getContentIds')
->with($this->equalTo($remoteIds))
->willReturn($contentIds);

$gateway
->expects($this->once())
->method('getUrlsFromUrlLink')
->with($this->equalTo(42), $this->equalTo(1))
->willReturn([]);

$gateway->expects($this->never())->method('getIdUrlMap');
if (empty($insertLinks)) {
$gateway->expects($this->never())->method('insertUrl');
Expand All @@ -338,9 +345,12 @@ public function testStoreFieldDataThrowsNotFoundException(
->willReturn($linkMap['id']);
}

$versionInfo = new VersionInfo();
$versionInfo = new VersionInfo(['versionNo' => 1]);
$value = new FieldValue(['data' => $xmlString]);
$field = new Field(['value' => $value]);
$field = new Field([
'value' => $value,
'id' => 42,
]);

$storage = $this->getPartlyMockedStorage($gateway);
$storage->storeFieldData(
Expand Down
Loading