Skip to content

Commit

Permalink
Fixed #15075
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed May 27, 2024
1 parent 9d48deb commit ddc72c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 5

## Unreleased

- Fixed a bug where entry type condition rules prefixed their option labels with section names. ([#15075](https://github.com/craftcms/cms/issues/15075))

## 5.1.7 - 2024-05-25

- Scalar element queries no longer set their `$select` property to the scalar expression, fixing an error that could occur when executing scalar queries for relation fields. ([#15071](https://github.com/craftcms/cms/issues/15071))
Expand Down
27 changes: 4 additions & 23 deletions src/elements/conditions/entries/TypeConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use craft\elements\db\ElementQueryInterface;
use craft\elements\db\EntryQuery;
use craft\elements\Entry;
use craft\models\Section;

/**
* Entry type condition rule.
Expand All @@ -35,21 +34,6 @@ public function getExclusiveQueryParams(): array
return ['type', 'typeId'];
}

/**
* @var Section[]
*/
private array $_sections = [];

/**
* @inheritdoc
*/
public function init(): void
{
$this->_sections = Craft::$app->getEntries()->getAllSections();

parent::init();
}

/**
* @inheritdoc
*/
Expand All @@ -69,12 +53,9 @@ public function setAttributes($values, $safeOnly = true): void
protected function options(): array
{
$options = [];
foreach ($this->_sections as $section) {
foreach ($section->getEntryTypes() as $entryType) {
$options[$entryType->uid] = sprintf('%s - %s', $section->name, $entryType->name);
}
foreach (Craft::$app->getEntries()->getAllEntryTypes() as $entryType) {
$options[$entryType->uid] = $entryType->getUiLabel();
}

return $options;
}

Expand All @@ -84,8 +65,8 @@ protected function options(): array
public function modifyQuery(ElementQueryInterface $query): void
{
/** @var EntryQuery $query */
$sections = Craft::$app->getEntries();
$query->typeId($this->paramValue(fn($uid) => $sections->getEntryTypeByUid($uid)->id ?? null));
$entriesService = Craft::$app->getEntries();
$query->typeId($this->paramValue(fn($uid) => $entriesService->getEntryTypeByUid($uid)->id ?? null));
}

/**
Expand Down

0 comments on commit ddc72c2

Please sign in to comment.