Skip to content

Commit

Permalink
Merge and build
Browse files Browse the repository at this point in the history
  • Loading branch information
Lupe Camacho authored and Lupe Camacho committed May 24, 2024
2 parents a0862e1 + d0e0cae commit 912b948
Show file tree
Hide file tree
Showing 46 changed files with 722 additions and 185 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,42 @@
- The `db/restore` command now autodetects the backup format for PostgreSQL installs, if `--format` isn’t passed. ([#14931](https://github.com/craftcms/cms/pull/14931))
- The `install` command and web-based installer now validate the existing project config files at the outset, and abort installation if there are any issues.
- The `resave/entries` command now has an `--all-sections` flag.
- The web-based installer now displays the error message when installation fails.
- The web-based installer now displays the error message when installation fails.
- Edit Entry Type pages now have a “Delete” action. ([#14983](https://github.com/craftcms/cms/discussions/14983))

### Development
- Added the `withCustomFields` element query param. ([#15003](https://github.com/craftcms/cms/pull/15003))
- Entry queries now support passing `*` to the `section` param, to filter the results to all section entries. ([#14978](https://github.com/craftcms/cms/discussions/14978))

### Accessibility
- Added the “Status” column option to category, entry, and user indexes. ([#14968](https://github.com/craftcms/cms/pull/14968))
- Element cards now display a textual status label rather than just the indicator. ([#14968](https://github.com/craftcms/cms/pull/14968))
- Darkened the color of page sidebar toggle icons to meet the minimum contrast for UI components.
- Darkened the color of context labels to meet the minimum contrast for text.
- Darkened the color of footer links to meet the minimum contrast for text.
- Set the language of the Craft edition in the footer, to improve screen reader pronunciation for non-English languages.
- The accessible name of “Select site” buttons is now translated to the current language.

### Extensibility
- Added `craft\db\getBackupFormat()`.
- Added `craft\db\getRestoreFormat()`.
- Added `craft\db\setBackupFormat()`.
- Added `craft\db\setRestoreFormat()`.
- Added `craft\enums\Color::tryFromStatus()`.
- Added `craft\events\InvalidateElementcachesEvent::$element`.
- `craft\base\Element::defineTableAttributes()` now returns common attribute definitions used by most element types.
- Added `craft\fields\BaseRelationField::existsQueryCondition()`.
- Added `craft\helpers\Cp::componentStatusIndicatorHtml()`.
- Added `craft\helpers\Cp::componentStatusLabelHtml()`.
- Added `craft\helpers\Cp::statusLabelHtml()`.
- Added `craft\helpers\StringHelper::indent()`.
- Added `craft\queue\Queue::getJobId()`.
- Added the `reloadOnBroadcastSave` setting to `Craft.ElementEditor`. ([#14814](https://github.com/craftcms/cms/issues/14814))
- Added the `waitForDoubleClicks` setting to `Garnish.Select`, `Craft.BaseElementIndex`, and `Craft.BaseElementIndexView`.

### System
- Improved overall system performance. ([#15003](https://github.com/craftcms/cms/pull/15003))
- Improved the performance of `exists()` element queries.
- Improved the performance of `craft\base\Element::toArray()`.
- The Debug Toolbar now pre-serializes objects stored as request parameters, fixing a bug where closures could prevent the entire Request panel from showing up. ([#14982](https://github.com/craftcms/cms/discussions/14982))
- Batched queue jobs now verify that they are still reserved before each step, and before spawning additional batch jobs. ([#14986](https://github.com/craftcms/cms/discussions/14986))
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
# Release Notes for Craft CMS 5

## Unreleased
## 5.1.6 - 2024-05-23

- Added `craft\services\Fields::getRelationalFieldTypes()`.
- Fixed a bug where `craft\helpers\Typecast::properties()` wasn’t typecasting numeric strings to ints for `int|string|null` properties. ([#14618](https://github.com/craftcms/cms/issues/14618))
- Fixed a bug where “Related To” conditions weren’t allowing entries to be selected. ([#15058](https://github.com/craftcms/cms/issues/15058))

## 5.1.5 - 2024-05-22

- Scalar element queries now set `$select` to the scalar expression, and `$orderBy`, `$limit`, and `$offset` to `null`, on the element query. ([#15001](https://github.com/craftcms/cms/issues/15001))
- Added `craft\fieldlayoutelements\TextareaField::inputTemplateVariables()`.
- Fixed a bug where `craft\helpers\Assets::prepareAssetName()` wasn’t sanitizing filenames if `$preventPluginModifications` was `true`.
- Fixed a bug where element queries’ `count()` methods were factoring in the `limit` param when searching with `orderBy` set to `score`. ([#15001](https://github.com/craftcms/cms/issues/15001))
- Fixed a bug where soft-deleted structure data associated with elements that belonged to a revision could be deleted by garbage collection. ([#14995](https://github.com/craftcms/cms/pull/14995))
- Fixed a bug where element edit pages’ scroll positions weren’t always retained when automatically refreshed.
- Fixed a bug where the `up` command could remove component name comments from the project config YAML files, for newly-added components. ([#15012](https://github.com/craftcms/cms/issues/15012))
- Fixed a bug where assets’ Alternative Text fields didn’t expand to match the content height. ([#15026](https://github.com/craftcms/cms/issues/15026))
- Fixed a bug where `craft\helpers\UrlHelper::isAbsoluteUrl()` was returning `true` for Windows file paths. ([#15043](https://github.com/craftcms/cms/issues/15043))
- Fixed an error that occurred on the current user’s Profile screen if they didn’t have permission to access the primary site. ([#15022](https://github.com/craftcms/cms/issues/15022))
- Fixed a bug where non-localizable elements’ edit screens were displaying a site breadcrumb.
- Fixed a bug where entry GraphQL queries weren’t available if only nested entry field queries were selected in the schema.
- Fixed a bug where chip labels could wrap unnecessarily. ([#15000](https://github.com/craftcms/cms/issues/15000), [#15017](https://github.com/craftcms/cms/pull/15017))
- Fixed a bug where date/time clear buttons could bleed out of their container. ([#15017](https://github.com/craftcms/cms/pull/15017))
- Fixed an error that occurred when editing an element, if any field layout conditions referenced a custom field that was no longer included in the layout. ([#14838](https://github.com/craftcms/cms/issues/14838))
- Fixed a “User not authorized to create this element.” error that could occur when creating a new entry within a Matrix field, if the field had Max Entries set. ([#15015](https://github.com/craftcms/cms/issues/15015))
- Fixed a bug where nested entries weren’t showing up within Matrix fields set to the element index view mode, when viewing entry revisions. ([#15038](https://github.com/craftcms/cms/pull/15038))
- Fixed the styling of element chips displayed within an element card. ([#15044](https://github.com/craftcms/cms/issues/15044))
- Fixed styling issues with inline-editing within element indexes. ([#15040](https://github.com/craftcms/cms/issues/15040), [#15049](https://github.com/craftcms/cms/pull/15049))
- Fixed a bug where sticky scrollbars could stop working when switching between element index sources. ([#15047](https://github.com/craftcms/cms/issues/15047))

## 5.1.4 - 2024-05-17

Expand Down
7 changes: 7 additions & 0 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,10 @@ protected static function defineTableAttributes(): array
'uid' => ['label' => Craft::t('app', 'UID')],
];

if (static::hasStatuses()) {
$attributes['status'] = ['label' => Craft::t('app', 'Status')];
}

if (static::hasUris()) {
$attributes = array_merge($attributes, [
'link' => ['label' => Craft::t('app', 'Link'), 'icon' => 'world'],
Expand Down Expand Up @@ -5226,6 +5230,9 @@ protected function attributeHtml(string $attribute): string
$parent = $this->getParent();
return $parent ? Cp::elementChipHtml($parent) : '';

case 'status':
return Cp::componentStatusLabelHtml($this);

case 'link':
if (ElementHelper::isDraftOrRevision($this)) {
return '';
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.1.4',
'version' => '5.1.6',
'schemaVersion' => '5.0.0.20',
'minVersionRequired' => '4.4.0',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
37 changes: 27 additions & 10 deletions src/console/controllers/MigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,33 @@ public function optionAliases(): array
return $aliases;
}

/**
* @inheritdoc
*/
public function runAction($id, $params = []): int
{
// Make sure that the project config YAML exists in case any migrations need to check incoming YAML values
$projectConfig = Craft::$app->getProjectConfig();
if ($projectConfig->writeYamlAutomatically && !$projectConfig->getDoesExternalConfigExist()) {
$projectConfig->regenerateExternalConfig();
} elseif ($projectConfig->areChangesPending(force: true)) {
// allow project config changes, but don't overwrite the pending changes
$readOnly = $projectConfig->readOnly;
$writeYamlAutomatically = $projectConfig->writeYamlAutomatically;
$projectConfig->readOnly = false;
$projectConfig->writeYamlAutomatically = false;
}

try {
return parent::runAction($id, $params);
} finally {
if (isset($readOnly, $writeYamlAutomatically)) {
$projectConfig->readOnly = $readOnly;
$projectConfig->writeYamlAutomatically = $writeYamlAutomatically;
}
}
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -204,16 +231,6 @@ public function beforeAction($action): bool
$this->migrationPath = $this->getMigrator()->migrationPath;
}

// Make sure that the project config YAML exists in case any migrations need to check incoming YAML values
$projectConfig = Craft::$app->getProjectConfig();
if ($projectConfig->writeYamlAutomatically && !$projectConfig->getDoesExternalConfigExist()) {
$projectConfig->regenerateExternalConfig();
} elseif ($projectConfig->areChangesPending(force: true)) {
// allow project config changes, but don't overwrite the pending changes
$projectConfig->readOnly = false;
$projectConfig->writeYamlAutomatically = false;
}

try {
if (!$this->traitBeforeAction($action)) {
return false;
Expand Down
4 changes: 0 additions & 4 deletions src/controllers/ElementIndexesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use craft\events\ElementActionEvent;
use craft\helpers\ArrayHelper;
use craft\helpers\Component;
use craft\helpers\Cp;
use craft\helpers\ElementHelper;
use craft\helpers\Html;
use craft\helpers\StringHelper;
Expand Down Expand Up @@ -1064,9 +1063,6 @@ public function actionElementTableHtml(): Response
}

return $this->asJson([
'elementHtml' => Cp::elementChipHtml($element, [
'context' => $this->context,
]),
'attributeHtml' => $attributeHtml,
]);
}
Expand Down
111 changes: 67 additions & 44 deletions src/controllers/EntryTypesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function actionEdit(?int $entryTypeId = null, ?EntryType $entryType = nul
$title = Craft::t('app', 'Create a new entry type');
}

return $this->asCpScreen()
$response = $this->asCpScreen()
->editUrl($entryType->getCpEditUrl())
->title($title)
->addCrumb(Craft::t('app', 'Settings'), 'settings')
Expand All @@ -87,46 +87,56 @@ public function actionEdit(?int $entryTypeId = null, ?EntryType $entryType = nul
'entryType' => $entryType,
'typeName' => Entry::displayName(),
'lowerTypeName' => Entry::lowerDisplayName(),
])
->metaSidebarHtml($entryType->id ? Cp::metadataHtml([
Craft::t('app', 'ID') => $entryType->id,
Craft::t('app', 'Used by') => function() use ($entryType) {
$usages = $entryType->findUsages();
if (empty($usages)) {
return Html::tag('i', Craft::t('app', 'No usages'));
}

$labels = [];
$items = array_map(function(Section|ElementContainerFieldInterface $usage) use (&$labels) {
if ($usage instanceof Section) {
$label = Craft::t('site', $usage->name);
$url = $usage->getCpEditUrl();
$icon = 'newspaper';
} else {
$label = Craft::t('site', $usage->name);
$url = UrlHelper::cpUrl("settings/fields/edit/$usage->id");
$icon = $usage::icon();
]);

if ($entryType->id) {
$response
->addAltAction(Craft::t('app', 'Delete'), [
'action' => 'entry-types/delete',
'destructive' => true,
])
->metaSidebarHtml(Cp::metadataHtml([
Craft::t('app', 'ID') => $entryType->id,
Craft::t('app', 'Used by') => function() use ($entryType) {
$usages = $entryType->findUsages();
if (empty($usages)) {
return Html::tag('i', Craft::t('app', 'No usages'));
}
$labels[] = $label;
$labelHtml = Html::beginTag('span', [
'class' => ['flex', 'flex-nowrap', 'gap-s'],
]) .
Html::tag('div', Cp::iconSvg($icon), [
'class' => ['cp-icon', 'small'],
]) .
Html::tag('span', Html::encode($label)) .
Html::endTag('span');
return Html::a($labelHtml, $url);
}, $entryType->findUsages());

// sort by label
array_multisort($labels, SORT_ASC, $items);

return Html::ul($items, [
'encode' => false,
]);
},
]) : null);

$labels = [];
$items = array_map(function(Section|ElementContainerFieldInterface $usage) use (&$labels) {
if ($usage instanceof Section) {
$label = Craft::t('site', $usage->name);
$url = $usage->getCpEditUrl();
$icon = 'newspaper';
} else {
$label = Craft::t('site', $usage->name);
$url = UrlHelper::cpUrl("settings/fields/edit/$usage->id");
$icon = $usage::icon();
}
$labels[] = $label;
$labelHtml = Html::beginTag('span', [
'class' => ['flex', 'flex-nowrap', 'gap-s'],
]) .
Html::tag('div', Cp::iconSvg($icon), [
'class' => ['cp-icon', 'small'],
]) .
Html::tag('span', Html::encode($label)) .
Html::endTag('span');
return Html::a($labelHtml, $url);
}, $entryType->findUsages());

// sort by label
array_multisort($labels, SORT_ASC, $items);

return Html::ul($items, [
'encode' => false,
]);
},
]));
}

return $response;
}

/**
Expand Down Expand Up @@ -187,12 +197,25 @@ public function actionSave(): ?Response
public function actionDelete(): Response
{
$this->requirePostRequest();
$this->requireAcceptsJson();

$entryTypeId = $this->request->getRequiredBodyParam('id');
$entryTypeId = $this->request->getBodyParam('entryTypeId') ?? $this->request->getRequiredBodyParam('id');

$entriesService = Craft::$app->getEntries();
$entryType = $entriesService->getEntryTypeById($entryTypeId);

if (!$entryType) {
throw new BadRequestHttpException("Invalid entry type ID: $entryType");
}

if (!$entriesService->deleteEntryType($entryType)) {
return $this->asFailure(Craft::t('app', 'Couldn’t delete “{name}”.', [
'name' => $entryType->getUiLabel(),
]));
}

$success = Craft::$app->getEntries()->deleteEntryTypeById($entryTypeId);
return $success ? $this->asSuccess() : $this->asFailure();
return $this->asSuccess(Craft::t('app', '“{name}” deleted.', [
'name' => $entryType->getUiLabel(),
]));
}

/**
Expand Down
19 changes: 18 additions & 1 deletion src/debug/RequestPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace craft\debug;

use Craft;
use craft\helpers\StringHelper;

/**
* Debugger panel that collects and displays request data.
Expand All @@ -23,6 +24,22 @@ class RequestPanel extends \yii\debug\panels\RequestPanel
public function save(): array
{
$data = parent::save();
return Craft::$app->getSecurity()->redactIfSensitive('', $data);
$data = Craft::$app->getSecurity()->redactIfSensitive('', $data);
if (isset($data['actionParams'])) {
$this->serializeObjects($data['actionParams']);
}
return $data;
}

private function serializeObjects(array &$arr, int $indent = 1): void
{
foreach ($arr as &$value) {
if (is_object($value)) {
$dump = trim(Craft::dump($value, 10, false, true));
$value = ltrim(StringHelper::indent($dump, str_repeat(' ', $indent)));
} elseif (is_array($value)) {
$this->serializeObjects($value, $indent + 1);
}
}
}
}
1 change: 1 addition & 0 deletions src/elements/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ protected static function defineTableAttributes(): array
protected static function defineDefaultTableAttributes(string $source): array
{
return [
'status',
'link',
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ protected static function defineTableAttributes(): array
*/
protected static function defineDefaultTableAttributes(string $source): array
{
$attributes = [];
$attributes = ['status'];

if ($source === '*') {
$attributes[] = 'section';
Expand Down
14 changes: 11 additions & 3 deletions src/elements/NestedElementManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,23 @@ function(string $id, array $config, string $attribute, array &$settings) use ($o
$elementType = $this->elementType;
$view = Craft::$app->getView();

$criteria = [
$this->ownerIdParam => $owner->id,
];

if ($owner->getIsRevision()) {
$criteria['revisions'] = null;
$criteria['trashed'] = null;
$criteria['drafts'] = false;
}

$settings['indexSettings'] = [
'namespace' => $view->getNamespace(),
'allowedViewModes' => $config['allowedViewModes']
? array_map(fn($mode) => StringHelper::toString($mode), $config['allowedViewModes'])
: null,
'showHeaderColumn' => $config['showHeaderColumn'],
'criteria' => array_merge([
$this->ownerIdParam => $owner->id,
], $this->criteria),
'criteria' => array_merge($criteria, $this->criteria),
'batchSize' => $config['pageSize'],
'actions' => [],
'canHaveDrafts' => $elementType::hasDrafts(),
Expand Down
1 change: 1 addition & 0 deletions src/elements/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ protected static function defineTableAttributes(): array
protected static function defineDefaultTableAttributes(string $source): array
{
return [
'status',
'fullName',
'email',
'dateCreated',
Expand Down
Loading

0 comments on commit 912b948

Please sign in to comment.