Skip to content

Commit

Permalink
Merge branch '5.x' into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Dec 3, 2024
2 parents e900379 + 00a6feb commit a342d9a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 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))

## 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))
- “View” buttons within element indexes are now disabled when the selected view mode has no applicable settings. ([#16242](https://github.com/craftcms/cms/pull/16242))
Expand Down
2 changes: 1 addition & 1 deletion src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return [
'id' => 'CraftCMS',
'name' => 'Craft CMS',
'version' => '5.5.3',
'version' => '5.5.4',
'schemaVersion' => '5.6.0.1',
'minVersionRequired' => '4.5.0',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
12 changes: 4 additions & 8 deletions src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,10 @@ public static function sourcePath(string $sourceKey, string $stepKey, ?string $c
*/
protected static function defineFieldLayouts(?string $source): array
{
if ($source !== null) {
$volumes = [];
if (preg_match('/^volume:(.+)$/', $source, $matches)) {
$volume = Craft::$app->getVolumes()->getVolumeByUid($matches[1]);
if ($volume) {
$volumes[] = $volume;
}
}
if ($source !== null && preg_match('/^volume:(.+)$/', $source, $matches)) {
$volumes = array_filter([
Craft::$app->getVolumes()->getVolumeByUid($matches[1]),
]);
} else {
$volumes = Craft::$app->getVolumes()->getAllVolumes();
}
Expand Down
12 changes: 4 additions & 8 deletions src/elements/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,10 @@ protected static function defineSources(string $context): array
*/
protected static function defineFieldLayouts(?string $source): array
{
if ($source !== null) {
$groups = [];
if (preg_match('/^group:(.+)$/', $source, $matches)) {
$group = Craft::$app->getCategories()->getGroupByUid($matches[1]);
if ($group) {
$groups[] = $group;
}
}
if ($source !== null && preg_match('/^group:(.+)$/', $source, $matches)) {
$groups = array_filter([
Craft::$app->getCategories()->getGroupByUid($matches[1]),
]);
} else {
$groups = Craft::$app->getCategories()->getAllGroups();
}
Expand Down
24 changes: 10 additions & 14 deletions src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,17 @@ public static function modifyCustomSource(array $config): array
*/
protected static function defineFieldLayouts(?string $source): array
{
if ($source !== null) {
if ($source === '*') {
$sections = Craft::$app->getEntries()->getAllSections();
} elseif ($source === 'singles') {
$sections = Craft::$app->getEntries()->getSectionsByType(Section::TYPE_SINGLE);
} else {
$sections = [];
if (preg_match('/^section:(.+)$/', $source, $matches)) {
$section = Craft::$app->getEntries()->getSectionByUid($matches[1]);
if ($section) {
$sections[] = $section;
}
}
}
if ($source === '*') {
$sections = Craft::$app->getEntries()->getAllSections();
} elseif ($source === 'singles') {
$sections = Craft::$app->getEntries()->getSectionsByType(Section::TYPE_SINGLE);
} elseif ($source !== null && preg_match('/^section:(.+)$/', $source, $matches)) {
$sections = array_filter([
Craft::$app->getEntries()->getSectionByUid($matches[1]),
]);
}

if (isset($sections)) {
$entryTypes = array_values(array_unique(array_merge(
...array_map(fn(Section $section) => $section->getEntryTypes(), $sections),
)));
Expand Down
2 changes: 0 additions & 2 deletions src/templates/_layouts/elementindex.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
}) %}
{% endif %}

{% set canHaveDrafts = canHaveDrafts ?? elementInstance.hasDrafts() %}

{% block sidebar %}
{% if sources is not empty %}
{{ tag('a', {
Expand Down
1 change: 1 addition & 0 deletions src/web/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,7 @@ private function _prepareElementIndexVariables(array &$context): null

$context['elementDisplayName'] = $elementType::displayName();
$context['elementPluralDisplayName'] = $elementType::pluralDisplayName();
$context['canHaveDrafts'] ??= $elementType::hasDrafts();

return null;
}
Expand Down

0 comments on commit a342d9a

Please sign in to comment.