Skip to content

Commit

Permalink
Merge pull request #6794 from getkirby/v5/changes/version-is-identica…
Browse files Browse the repository at this point in the history
…l-fix

Version::isIdentical now uses form values to check for identical versions
  • Loading branch information
distantnative authored Nov 14, 2024
2 parents 13100f0 + cbcb705 commit 9d2041e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Api/Controller/Changes.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ public static function save(ModelWithContent $model, array $input): array
);

if ($changes->isIdentical(version: $latest, language: 'current')) {
$changes->delete();
$changes->delete(
language: 'current'
);
}

return [
Expand Down
19 changes: 17 additions & 2 deletions src/Content/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Kirby\Cms\ModelWithContent;
use Kirby\Cms\Page;
use Kirby\Exception\NotFoundException;
use Kirby\Form\Form;

/**
* The Version class handles all actions for a single
Expand Down Expand Up @@ -191,7 +192,6 @@ public function isIdentical(
$version = $this->model->version($version);
}


if ($version->id()->is($this->id) === true) {
return true;
}
Expand All @@ -213,7 +213,22 @@ public function isIdentical(
$b['uuid']
);

// ensure both arrays of fields are sorted the same
$a = Form::for(
model: $this->model,
props: [
'language' => $language->code(),
'values' => $a,
]
)->values();

$b = Form::for(
model: $this->model,
props: [
'language' => $language->code(),
'values' => $b
]
)->values();

ksort($a);
ksort($b);

Expand Down

0 comments on commit 9d2041e

Please sign in to comment.