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

EZP-31681: Fixed Image Value comparison via FT Comparable contract #3060

Merged
merged 19 commits into from
Nov 18, 2020
Merged
Changes from 3 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
17 changes: 16 additions & 1 deletion eZ/Publish/Core/Repository/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ protected function copyTranslationsFromPublishedVersion(APIVersionInfo $versionI

if ($newValue !== null
&& $field->value !== null
&& $fieldType->toHash($newValue) === $fieldType->toHash($field->value)) {
&& $this->isHashEqual($fieldType, $newValue, $field->value)) {
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved
continue;
}

Expand All @@ -1742,6 +1742,21 @@ protected function copyTranslationsFromPublishedVersion(APIVersionInfo $versionI
$this->internalUpdateContent($versionInfo, $updateStruct);
}

protected function isHashEqual($fieldType, $newValue, $fieldValue): bool
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved
{
$newHash = $fieldType->toHash($newValue);
$currentHash = $fieldType->toHash($fieldValue);
if ($newHash === $currentHash) {
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved
return true;
} elseif ($fieldType instanceof \eZ\Publish\Core\FieldType\Image\Type) {
$imageHashDiff = array_diff($newHash, $currentHash);

return count($imageHashDiff) === 1 && !empty($imageHashDiff['imageId']);
}
mateuszdebinski marked this conversation as resolved.
Show resolved Hide resolved

return false;
}

/**
* Publishes a content version.
*
Expand Down