Skip to content

Commit

Permalink
Merge branch '5.6' into feature/pt-2384-in-the-asset-field-theres-a-v…
Browse files Browse the repository at this point in the history
…isually-hidden-focusable
  • Loading branch information
brandonkelly committed Jan 14, 2025
2 parents 2d294e8 + c90a6d6 commit 7859624
Show file tree
Hide file tree
Showing 69 changed files with 757 additions and 249 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Content Management
- It’s now possible to copy custom field values from other sites. ([#14056](https://github.com/craftcms/cms/pull/14056))
- “Related To”, “Not Related To”, “Author”, and relational field condition rules now allow multiple elements to be specified. ([#16121](https://github.com/craftcms/cms/discussions/16121))
- Added the “Widget Title” setting to Quick Post widgets. ([#16429](https://github.com/craftcms/cms/pull/16429))
- Improved the styling of inline code fragments. ([#16141](https://github.com/craftcms/cms/pull/16141))
- Improved the styling of attribute previews in card view. ([#16324](https://github.com/craftcms/cms/pull/16324))
- Added the “Affiliated Site” user condition rule. ([#16174](https://github.com/craftcms/cms/pull/16174))
Expand All @@ -26,6 +27,8 @@
- Improved the accessibility of “More” and “Advanced” toggle triggers. ([#16293]](https://github.com/craftcms/cms/pull/16293))
- Improved the accessibility of the Craft Support widget. ([#16293]](https://github.com/craftcms/cms/pull/16293))
- Improved the accessibility of field translatable indicators and tooltips.
- Progress bars now announce their progress to screen readers. ([#16398](https://github.com/craftcms/cms/pull/16398))
- Loading spinners within element indexes and inline-editable Matrix fields are now announced to screen readers. ([#16417](https://github.com/craftcms/cms/pull/16417))

### Administration
- Added the “Affiliated Site” native user field. ([#16174](https://github.com/craftcms/cms/pull/16174))
Expand All @@ -47,13 +50,12 @@
- After creating a new field from a field layout designer, the field is now immediately added to the field layout tab. ([#16374](https://github.com/craftcms/cms/pull/16374))
- Templates rendered for “Template” field layout UI elements can now call control panel template functions like `elementChip()` and `elementCard()`. ([#16267](https://github.com/craftcms/cms/issues/16267))
- “Template” field layout UI elements now show suggestions for the Template input.
- Element condition builders now always show field handles within the rule selection menu, for admin users.
- Added the `elements/delete-all-of-type` command. ([#16423](https://github.com/craftcms/cms/pull/16423))
- Added the `utils/delete-empty-volume-folders` command. ([#16388](https://github.com/craftcms/cms/issues/16388))
- Improved the error output for nested elements when they can’t be resaved via `resave` commands.
- `resave` commands’ `--drafts`, `--provisional-drafts`, and `--revisions` options can now be set to `null`, causing elements to be resaved regardless of whether they’re drafts/provisional drafts/revisions.
- Added the `systemTemplateCss` config setting. ([#16344](https://github.com/craftcms/cms/pull/16344))
- The `loginPath`, `logoutPath`, `setPasswordPath`, and `verifyEmailPath` config settings are now respected in headless mode. ([#16344](https://github.com/craftcms/cms/pull/16344))
- Removed the “Show field handles in edit forms” admin user preference. ([#16415](https://github.com/craftcms/cms/pull/16415))

### 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 All @@ -66,14 +68,17 @@
- It’s now possible to set Link field values to arrays with `value` keys set to element instances or IDs. ([#16255](https://github.com/craftcms/cms/pull/16255))
- The `duration` Twig filter now has a `language` argument. ([#16332](https://github.com/craftcms/cms/pull/16332))
- The `indexOf` Twig filter now has a `default` argument, which can be any integer or `null`. (`-1` by default for backwards compatibility.)
- `{% cache %}` tags now cache any JavaScript import map entries registered via `craft\web\View::registerJsImport()` within them.
- The `{% requireAdmin %}` tag now supports passing a boolean value, which determines whether administrative changes must be allowed (defaults to `true`).
- It’s now possible to reference custom field handles in element queries’ `where` params. ([#16318](https://github.com/craftcms/cms/pull/16318))
- Number fields’ scalar values now return an integer if Decimals is set to `0`, and a number formatted with the correct decimal points when using MySQL. ([16369](https://github.com/craftcms/cms/issues/16369))
- Added support for specifying the current site via an `X-Craft-Site` header set to a site ID or handle. ([#16367](https://github.com/craftcms/cms/pull/16367))
- Added the `disable2fa` config setting. ([#16426](https://github.com/craftcms/cms/pull/16426))
- Added support for defining redirects from `config/redirects.php`. ([#16355](https://github.com/craftcms/cms/pull/16355))
- Deprecated the `ucfirst` Twig filter. `capitalize` should be used instead.

### Extensibility
- Added `craft\attributes\EnvName`.
- Added `craft\base\ConfigurableComponentInterface::getReadOnlySettingsHtml()`. ([#16265](https://github.com/craftcms/cms/pull/16265))
- Added `craft\base\CrossSiteCopyableFieldInterface`. ([#14056](https://github.com/craftcms/cms/pull/14056))
- Added `craft\base\Element::EVENT_DEFINE_ALT_ACTIONS`. ([#16294](https://github.com/craftcms/cms/pull/16294))
Expand Down Expand Up @@ -130,11 +135,16 @@
- Added `craft\web\User::getImpersonator()`.
- Added `craft\web\User::getImpersonatorId()`.
- Added `craft\web\User::setImpersonatorId()`.
- Added `craft\web\View::clearJsImportBuffer()`. ([#16414](https://github.com/craftcms/cms/pull/16414))
- Added `craft\web\View::registerJsImport()`. ([#16414](https://github.com/craftcms/cms/pull/16414))
- Added `craft\web\View::registerScriptWithVars()`. ([#16414](https://github.com/craftcms/cms/pull/16414))
- Added `craft\web\View::setTwig()`.
- Added `craft\web\View::startJsImportBuffer()`. ([#16414](https://github.com/craftcms/cms/pull/16414))
- Added `craft\web\twig\variables\Cp::EVENT_REGISTER_READ_ONLY_CP_SETTINGS`. ([#16265](https://github.com/craftcms/cms/pull/16265))
- `GuzzleHttp\Client` is now instantiated via `Craft::createObject()`. ([#16366](https://github.com/craftcms/cms/pull/16366))
- `craft\elements\NestedElementManager::getIndexHtml()` now supports passing `defaultSort` in the `$config` array. ([#16236](https://github.com/craftcms/cms/discussions/16236))
- `craft\elements\conditions\entries\MatrixFieldConditionRule` is now an alias of `FieldConditionRule`.
- `craft\helpers\App::envConfig()` now checks for a `craft\attributes\EnvName` attribute on public properties, which can be used to override the environment variable name (sans prefix) that is associated with the property.
- `craft\helpers\Cp::elementIndexHtml()` now supports passing `defaultSort` in the `$config` array, when `sources` is `null`. ([#16236](https://github.com/craftcms/cms/discussions/16236))
- `craft\helpers\Cp::fieldHtml()` now supports passing an `actionMenuItems` array in the config. ([#16415](https://github.com/craftcms/cms/pull/16415))
- `craft\helpers\DateTimeHelper::humanDuration()` now has a `$language` argument. ([#16332](https://github.com/craftcms/cms/pull/16332))
Expand All @@ -150,6 +160,7 @@
- `_includes/forms/autosuggest.twig` now supports a `suggestTemplates` variable.
- `_includes/forms/colorSelect.twig` now supports `options` and `withBlankOption` variables.
- `_includes/forms/selectize.twig` now supports a `color` property in option data, which can be set to a hex value or a color name.
- Added `Craft.IntervalManager`. ([#16398](https://github.com/craftcms/cms/pull/16398))
- Sortable checkbox selects now always display the selected options first on initial render.

### System
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Fixed a bug where the control panel could display a notice about the Craft CMS license belonging to a different domain, even when accessing the control panel from the correct domain. ([#16396](https://github.com/craftcms/cms/issues/16396))
- Fixed a bug where field layout elements’ action menus could have an empty action group.
- Fixed a bug where Single section entries could be duplicated after running the `entry-types/merge` command. ([#16394](https://github.com/craftcms/cms/issues/16394))
- Fixed a styling bug with the system message modal. ([#16410](https://github.com/craftcms/cms/issues/16410))

## 5.5.9 - 2025-01-06

Expand Down
15 changes: 14 additions & 1 deletion packages/craftcms-webpack/Craft.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Set up interfaces and types
interface ProgressBarInterface {
new ($element: JQuery, displaySteps?: boolean): ProgressBarInterface;
new (
$element: JQuery,
displaySteps?: boolean,
settings?: Object
): ProgressBarInterface;

$progressBar: JQuery;

Expand All @@ -13,6 +17,14 @@ interface ProgressBarInterface {
showProgressBar(): void;
}

interface IntervalManagerInterface {
new (settings?: Object): IntervalManagerInterface;

stop(): void;

start(): void;
}

type Site = {
handle: string;
id: number;
Expand All @@ -25,6 +37,7 @@ declare var Craft: {
csrfTokenName?: string;
csrfTokenValue?: string;
ProgressBar: ProgressBarInterface;
IntervalManager: IntervalManagerInterface;
t(category: string, message: string, params?: object): string;
sendActionRequest(method: string, action: string, options?: object): Promise;
initUiElements($container: JQuery): void;
Expand Down
25 changes: 25 additions & 0 deletions src/attributes/EnvName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/

namespace craft\attributes;

use Attribute;

/**
* Attribute EnvName
*
* @author Pixel & Tonic, Inc. <[email protected]>
* @since 5.6.0
*/
#[Attribute]
class EnvName
{
public function __construct(
public readonly string $name,
) {
}
}
25 changes: 14 additions & 11 deletions src/base/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,9 @@ public function getCpEditUrl(): ?string
public function getActionMenuItems(): array
{
$items = [];
$userSessionService = Craft::$app->getUser();

if ($this->id && Craft::$app->getUser()->getIsAdmin()) {
if ($this->id && $userSessionService->getIsAdmin()) {
$view = Craft::$app->getView();

if (Craft::$app->getConfig()->getGeneral()->allowAdminChanges) {
Expand All @@ -561,13 +562,14 @@ public function getActionMenuItems(): array
}

// Copy field handle
$copyId = sprintf('action-copy-handle-%s', mt_rand());
$items[] = [
'id' => $copyId,
'icon' => 'clipboard',
'label' => Craft::t('app', 'Copy field handle'),
];
$view->registerJsWithVars(fn($id, $attribute) => <<<JS
if (!$userSessionService->getIdentity()->getPreference('showFieldHandles')) {
$copyId = sprintf('action-copy-handle-%s', mt_rand());
$items[] = [
'id' => $copyId,
'icon' => 'clipboard',
'label' => Craft::t('app', 'Copy field handle'),
];
$view->registerJsWithVars(fn($id, $attribute) => <<<JS
(() => {
$('#' + $id).on('click', () => {
Craft.ui.createCopyTextPrompt({
Expand All @@ -577,9 +579,10 @@ public function getActionMenuItems(): array
});
})();
JS, [
$view->namespaceInputId($copyId),
$this->handle,
]);
$view->namespaceInputId($copyId),
$this->handle,
]);
}
}

return $items;
Expand Down
69 changes: 67 additions & 2 deletions src/config/GeneralConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Closure;
use Craft;
use craft\attributes\EnvName;
use craft\helpers\ConfigHelper;
use craft\helpers\DateTimeHelper;
use craft\helpers\Localization;
Expand Down Expand Up @@ -944,6 +945,24 @@ class GeneralConfig extends BaseConfig
*/
public bool $devMode = false;

/**
* @var bool Whether two-step verification features should be disabled.
*
* ::: code
* ```php Static Config
* ->disable2fa()
* ```
* ```shell Environment Override
* CRAFT_DISABLE_2FA=true
* ```
* :::
*
* @group Users
* @since 5.6.0
*/
#[EnvName('DISABLE_2FA')]
public bool $disable2fa = false;

/**
* @var string[]|string|null Array of plugin handles that should be disabled, regardless of what the project config says.
*
Expand Down Expand Up @@ -2694,12 +2713,23 @@ class GeneralConfig extends BaseConfig
/**
* @var string A private, random, cryptographically-secure key that is used for hashing and encrypting data in [[\craft\services\Security]].
*
* This value should be the same across all environments. If this key ever changes, any data that was encrypted with it will be inaccessible.
* ::: warning
* **Do not** share this key publicly. If exposed, it could lead to a compromised system.
* :::
*
* In the event that the key is compromised, a new secure key can be generated with the command:
*
* ```sh
* php craft setup/security-key
* ```
*
* Note that if the key changes, any data that is encrypted with it (e.g. user session cookies) will be inaccessible.
*
* ```php Static Config
* ->securityKey('2cf24dba5...')
* ```
*
* @see https://craftcms.com/knowledge-base/securing-craft
* @group Security
*/
public string $securityKey = '';
Expand Down Expand Up @@ -4316,6 +4346,30 @@ public function devMode(bool $value = true): self
return $this;
}

/**
* Whether two-step verification features should be disabled.
*
* ::: code
* ```php Static Config
* ->disable2fa()
* ```
* ```shell Environment Override
* CRAFT_DISABLE_2FA=true
* ```
* :::
*
* @group Users
* @param bool $value
* @return self
* @see $disable2fa
* @since 5.6.0
*/
public function disable2fa(bool $value = true): self
{
$this->disable2fa = $value;
return $this;
}

/**
* Array of plugin handles that should be disabled, regardless of what the project config says.
*
Expand Down Expand Up @@ -6302,7 +6356,17 @@ public function sanitizeSvgUploads(bool $value = true): self
/**
* A private, random, cryptographically-secure key that is used for hashing and encrypting data in [[\craft\services\Security]].
*
* This value should be the same across all environments. If this key ever changes, any data that was encrypted with it will be inaccessible.
* ::: warning
* **Do not** share this key publicly. If exposed, it could lead to a compromised system.
* :::
*
* In the event that the key is compromised, a new secure key can be generated with the command:
*
* ```sh
* php craft setup/security-key
* ```
*
* Note that if the key changes, any data that is encrypted with it (e.g. user session cookies) will be inaccessible.
*
* ```php
* ->securityKey('2cf24dba5...')
Expand All @@ -6312,6 +6376,7 @@ public function sanitizeSvgUploads(bool $value = true): self
* @param string $value
* @return self
* @see $securityKey
* @see https://craftcms.com/knowledge-base/securing-craft
* @since 4.2.0
*/
public function securityKey(string $value): self
Expand Down
Loading

0 comments on commit 7859624

Please sign in to comment.