From cfd7b6e2a95a4eb6b17bcd2e30fe61a3d641ea95 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Mon, 2 Dec 2024 11:30:36 -0800 Subject: [PATCH 1/4] Finish 4.13.4 --- CHANGELOG.md | 2 +- src/config/app.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2eacf96cd..b67ffaefffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release Notes for Craft CMS 4 -## Unreleased +## 4.13.4 - 2024-12-02 - Reduced the likelihood of a deadlock error occurring when updating search indexes. ([#15221](https://github.com/craftcms/cms/issues/15221)) - The PHP Info utility is no longer shown in environments where the `phpinfo()` function is disabled. ([#16229](https://github.com/craftcms/cms/pull/16229)) diff --git a/src/config/app.php b/src/config/app.php index 6d018001f47..936469da88b 100644 --- a/src/config/app.php +++ b/src/config/app.php @@ -3,7 +3,7 @@ return [ 'id' => 'CraftCMS', 'name' => 'Craft CMS', - 'version' => '4.13.3', + 'version' => '4.13.4', 'schemaVersion' => '4.5.3.0', 'minVersionRequired' => '3.7.11', 'basePath' => dirname(__DIR__), // Defines the @app alias From f2231f182f65657f48741926c2d3e126cf76739d Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Mon, 2 Dec 2024 11:36:44 -0800 Subject: [PATCH 2/4] Fixed element index error --- src/templates/_layouts/elementindex.twig | 2 -- src/web/View.php | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/templates/_layouts/elementindex.twig b/src/templates/_layouts/elementindex.twig index 08e9744a723..dcf5346f633 100644 --- a/src/templates/_layouts/elementindex.twig +++ b/src/templates/_layouts/elementindex.twig @@ -32,8 +32,6 @@ }) %} {% endif %} -{% set canHaveDrafts = canHaveDrafts ?? elementInstance.hasDrafts() %} - {% block sidebar %} {% if sources is not empty %} {{ tag('a', { diff --git a/src/web/View.php b/src/web/View.php index 1edf8a62f57..a200ef8ac02 100644 --- a/src/web/View.php +++ b/src/web/View.php @@ -2414,6 +2414,7 @@ private function _prepareElementIndexVariables(array &$context): null $context['elementDisplayName'] = $elementType::displayName(); $context['elementPluralDisplayName'] = $elementType::pluralDisplayName(); + $context['canHaveDrafts'] ??= $elementType::hasDrafts(); return null; } From c89aea32f0ec77d4e32d5c1cdf282ef917d60aa9 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Mon, 2 Dec 2024 11:37:31 -0800 Subject: [PATCH 3/4] Finish 5.5.4 --- CHANGELOG.md | 2 +- src/config/app.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ce2a71185..60cb12922a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release Notes for Craft CMS 5 -## Unreleased +## 5.5.4 - 2024-12-02 - Reduced the likelihood of a deadlock error occurring when updating search indexes. ([#15221](https://github.com/craftcms/cms/issues/15221)) - The PHP Info utility is no longer shown in environments where the `phpinfo()` function is disabled. ([#16229](https://github.com/craftcms/cms/pull/16229)) diff --git a/src/config/app.php b/src/config/app.php index 719bdfd90ff..86f036d27dc 100644 --- a/src/config/app.php +++ b/src/config/app.php @@ -3,7 +3,7 @@ return [ 'id' => 'CraftCMS', 'name' => 'Craft CMS', - 'version' => '5.5.3', + 'version' => '5.5.4', 'schemaVersion' => '5.5.0.0', 'minVersionRequired' => '4.5.0', 'basePath' => dirname(__DIR__), // Defines the @app alias From 3a34393634d39681105c738f0c270ab1857ab80a Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Mon, 2 Dec 2024 15:28:49 -0800 Subject: [PATCH 4/4] Fallback to all field layouts for event-defined sources --- CHANGELOG.md | 4 ++++ src/elements/Asset.php | 14 +++++++------- src/elements/Category.php | 16 ++++++++-------- src/elements/Entry.php | 12 ++++++------ 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b67ffaefffe..8abb03e3d13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft CMS 4 +## Unreleased + +- Fixed a bug where asset, category, and entry sources defined by the `EVENT_REGISTER_SOURCES` event didn’t have any custom fields available to them, unless the `EVENT_REGISTER_FIELD_LAYOUTS` event was also used to define the available field layouts for the event-defined source. ([#16256](https://github.com/craftcms/cms/discussions/16256)) + ## 4.13.4 - 2024-12-02 - Reduced the likelihood of a deadlock error occurring when updating search indexes. ([#15221](https://github.com/craftcms/cms/issues/15221)) diff --git a/src/elements/Asset.php b/src/elements/Asset.php index 82c3da92eed..529880cdd83 100644 --- a/src/elements/Asset.php +++ b/src/elements/Asset.php @@ -442,14 +442,14 @@ public static function sourcePath(string $sourceKey, string $stepKey, ?string $c */ protected static function defineFieldLayouts(string $source): array { - $fieldLayouts = []; - if ( - preg_match('/^volume:(.+)$/', $source, $matches) && - ($volume = Craft::$app->getVolumes()->getVolumeByUid($matches[1])) - ) { - $fieldLayouts[] = $volume->getFieldLayout(); + if (preg_match('/^volume:(.+)$/', $source, $matches)) { + $volume = Craft::$app->getVolumes()->getVolumeByUid($matches[1]); + return array_filter([ + $volume?->getFieldLayout(), + ]); } - return $fieldLayouts; + + return parent::defineFieldLayouts($source); } /** diff --git a/src/elements/Category.php b/src/elements/Category.php index 089cee9830b..38863ff785b 100644 --- a/src/elements/Category.php +++ b/src/elements/Category.php @@ -212,14 +212,14 @@ protected static function defineSources(string $context): array */ protected static function defineFieldLayouts(string $source): array { - $fieldLayouts = []; - if ( - preg_match('/^group:(.+)$/', $source, $matches) && - ($group = Craft::$app->getCategories()->getGroupByUid($matches[1])) - ) { - $fieldLayouts[] = $group->getFieldLayout(); - } - return $fieldLayouts; + if (preg_match('/^group:(.+)$/', $source, $matches)) { + $group = Craft::$app->getCategories()->getGroupByUid($matches[1]); + return array_filter([ + $group?->getFieldLayout(), + ]); + } + + return parent::defineFieldLayouts($source); } /** diff --git a/src/elements/Entry.php b/src/elements/Entry.php index 84c645f0f8c..938016ab4e6 100644 --- a/src/elements/Entry.php +++ b/src/elements/Entry.php @@ -350,16 +350,16 @@ public static function modifyCustomSource(array $config): array protected static function defineFieldLayouts(string $source): array { // Get all the sections covered by this source - $sections = []; if ($source === '*') { $sections = Craft::$app->getSections()->getAllSections(); } elseif ($source === 'singles') { $sections = Craft::$app->getSections()->getSectionsByType(Section::TYPE_SINGLE); - } elseif ( - preg_match('/^section:(.+)$/', $source, $matches) && - $section = Craft::$app->getSections()->getSectionByUid($matches[1]) - ) { - $sections = [$section]; + } elseif (preg_match('/^section:(.+)$/', $source, $matches)) { + $sections = array_filter([ + Craft::$app->getSections()->getSectionByUid($matches[1]), + ]); + } else { + return parent::defineFieldLayouts($source); } $fieldLayouts = [];