Skip to content

Commit

Permalink
Better element labels
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 6, 2024
1 parent b2eb047 commit 98fa5a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Section condition rules now have a “has a value” operator. ([#16270](https://github.com/craftcms/cms/discussions/16270))
- The Queue Manager utility now shows jobs’ class names. ([#16228](https://github.com/craftcms/cms/pull/16228))
- Improved the wording of field instance action labels. ([#16261](https://github.com/craftcms/cms/discussions/16261))
- Improved the error output for nested elements when they can’t be resaved via `resave` commands.

### Development
- Added support for fallback element partial templates, e.g. `_partials/entry.twig` as opposed to `_partials/entry/typeHandle.twig`. ([#16125](https://github.com/craftcms/cms/pull/16125))
Expand Down
6 changes: 4 additions & 2 deletions src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -1583,12 +1583,14 @@ public function resaveElements(

// Make sure this isn't a revision
if ($skipRevisions) {
$label = $element->getUiLabel();
$label = $label !== '' ? "$label ($element->id)" : sprintf('%s %s', $element::lowerDisplayName(), $element->id);
try {
if (ElementHelper::isRevision($element)) {
throw new InvalidElementException($element, "Skipped resaving {$element->getUiLabel()} ($element->id) because it's a revision.");
throw new InvalidElementException($element, "Skipped resaving $label because it's a revision.");
}
} catch (Throwable $rootException) {
throw new InvalidElementException($element, "Skipped resaving {$element->getUiLabel()} ($element->id) due to an error obtaining its root element: " . $rootException->getMessage());
throw new InvalidElementException($element, "Skipped resaving $label due to an error obtaining its root element: " . $rootException->getMessage());
}
}
} catch (InvalidElementException $e) {
Expand Down

0 comments on commit 98fa5a3

Please sign in to comment.