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

Bugfix/16243 show validation error when uri not unique #16252

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Content Management
- The global sidebar no longer shows “Failed” for queue jobs, for users that don’t have access to the Queue Manager. ([#16184](https://github.com/craftcms/cms/issues/16184))
- Elements with non-unique URIs now show a validation error rather than become disabled. ([#16243](https://github.com/craftcms/cms/issues/16243), [#16252](https://github.com/craftcms/cms/pull/16252))

## Administration
- The Queue Manager utility now shows jobs’ class names. ([#16228](https://github.com/craftcms/cms/pull/16228))
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/ElementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ public function actionDuplicate(): ?Response
'isProvisionalDraft' => false,
]);
} catch (InvalidElementException $e) {
return $this->_asFailure($e->element, Craft::t('app', 'Couldn’t duplicate {type}.', [
return $this->_asFailure($element, Craft::t('app', 'Couldn’t duplicate {type}.', [
'type' => $element::lowerDisplayName(),
]));
} catch (Throwable $e) {
Expand Down
6 changes: 0 additions & 6 deletions src/services/Drafts.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,6 @@ public function removeDraftData(ElementInterface $draft): void
$draft->setScenario(Element::SCENARIO_ESSENTIALS);
$draft->validate();

// If there are any errors on the URI, re-validate as disabled
if ($draft->hasErrors('uri') && $draft->enabled) {
$draft->enabled = false;
$draft->validate();
}

try {
if ($draft->hasErrors() || !Craft::$app->getElements()->saveElement($draft, false)) {
throw new InvalidElementException($draft, "Draft $draft->id could not be applied because it doesn't validate.");
Expand Down
6 changes: 0 additions & 6 deletions src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -1636,12 +1636,6 @@ public function duplicateElement(
$mainClone->setScenario(Element::SCENARIO_ESSENTIALS);
$mainClone->validate();

// If there are any errors on the URI, re-validate as disabled
if ($mainClone->hasErrors('uri') && $mainClone->enabled) {
$mainClone->enabled = false;
$mainClone->validate();
}

if ($mainClone->hasErrors()) {
throw new InvalidElementException($mainClone, 'Element ' . $element->id . ' could not be duplicated because it doesn\'t validate.');
}
Expand Down