Skip to content
New issue

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

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

Already on GitHub? # to your account

EZP-31136: Fixed removal of outdated links when publishing #3015

Merged
merged 1 commit into from
Apr 17, 2020
Merged
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
22 changes: 22 additions & 0 deletions eZ/Publish/Core/FieldType/Tests/Url/UrlStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ public function testStoreFieldDataWithExistingUrl()
->method('linkUrl')
->with(12, 42, 24);

$gateway
->expects($this->once())
->method('unlinkUrl')
->with(
42,
24,
[12]
);

$storage = $this->getPartlyMockedStorage($gateway);
$result = $storage->storeFieldData($versionInfo, $field, $this->getContext());

Expand Down Expand Up @@ -67,6 +76,15 @@ public function testStoreFieldDataWithNewUrl()
->method('linkUrl')
->with(12, 42, 24);

$gateway
->expects($this->once())
->method('unlinkUrl')
->with(
42,
24,
[12]
);

$storage = $this->getPartlyMockedStorage($gateway);
$result = $storage->storeFieldData($versionInfo, $field, $this->getContext());

Expand All @@ -93,6 +111,10 @@ public function testStoreFieldDataWithEmptyUrl()
->expects($this->never())
->method('linkUrl');

$gateway
->expects($this->never())
->method('unlinkUrl');

$storage = $this->getPartlyMockedStorage($gateway);
$result = $storage->storeFieldData($versionInfo, $field, $this->getContext());

Expand Down
6 changes: 6 additions & 0 deletions eZ/Publish/Core/FieldType/Url/UrlStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $co

$this->gateway->linkUrl($urlId, $field->id, $versionInfo->versionNo);

$this->gateway->unlinkUrl(
$field->id,
$versionInfo->versionNo,
[$urlId]
);
alongosz marked this conversation as resolved.
Show resolved Hide resolved

$field->value->data['urlId'] = $urlId;

// Signals that the Value has been modified and that an update is to be performed
Expand Down