Skip to content

Commit

Permalink
Merge branch 'develop' into 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Oct 27, 2022
2 parents 29768b9 + 70f922d commit c3ea31d
Show file tree
Hide file tree
Showing 24 changed files with 129 additions and 98 deletions.
20 changes: 15 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# Release Notes for Craft CMS 4

## Unreleased

- Numeric values are no longer automatically formatted within element indexes. ([#12205](https://github.com/craftcms/cms/issues/12205))
- When `craft\base\Element::EVENT_DEFINE_URL` event handlers set `craft\events\DefineUrlEvent::$url` to `null`, that will no longer be respected unless `$handled` was also set to `true`. ([#12210](https://github.com/craftcms/cms/issues/12210), [nystudio107/craft-imageoptimize#359](https://github.com/nystudio107/craft-imageoptimize/issues/359))
- Fixed a bug where locked users’ remaining cooldown times could be calculated incorrectly on PHP 8.0.
- Fixed an infinite recursion bug that occurred when editing a Matrix field with a custom propagation method. ([#12176](https://github.com/craftcms/cms/issues/12176))
- Fixed a bug where element index source lists were showing headings that didn’t have any visible nested sources. ([#12193](https://github.com/craftcms/cms/issues/12193))
- Fixed a JavaScript 404 error that occurred when users’ Language was set to Chinese. ([#12194](https://github.com/craftcms/cms/issues/12194))
- Fixed a bug where users couldn’t delete their own addresses. ([craftcms/commerce#3011](https://github.com/craftcms/commerce/issues/3011))
- Fixed a bug where the `users/save-address` action wasn’t validating addresses properly.
- Fixed an error that could occur during garbage collection, if any nested volume folders were missing their path. ([#12195](https://github.com/craftcms/cms/issues/12195))

## 4.3.0 - 2022-10-25

### Authoring
### Content Management
- Added a “View” menu to element indexes, which enable users to customize the visible table columns for themselves, without affecting other users. ([#11915](https://github.com/craftcms/cms/pull/11915))
- Added source setting menus to element index pages, which now contain the “Customize sources” option when allowed, and “New subfolder”, “Rename folder”, and “Delete folder” actions on the Assets index page. ([#11906](https://github.com/craftcms/cms/pull/11906))
- Added the “Editable” rule to asset and entry conditions. ([#11995](https://github.com/craftcms/cms/discussions/11995))
Expand Down Expand Up @@ -65,7 +77,7 @@
- Element sources now have a “Default Sort” setting in the Customize Sources modal. ([#12002](https://github.com/craftcms/cms/discussions/12002))
- Control panel-defined image transforms can now have custom quality values. ([#9622](https://github.com/craftcms/cms/discussions/9622))
- Added support for the `CRAFT_DOTENV_PATH` PHP constant. ([#11894](https://github.com/craftcms/cms/discussions/11894))
- Added support for `CRAFT_WEB_URL` and `CRAFT_WEB_ROOT` PHP constants, which can be used to set the default `@web` and `@webroot` alias values. ([#11912](https://github.com/craftcms/cms/pull/11912))
- Added support for `CRAFT_WEB_URL` and `CRAFT_WEB_ROOT` environment variables/PHP constants, which can be used to set the default `@web` and `@webroot` alias values. ([#11912](https://github.com/craftcms/cms/pull/11912))

### Development
- Added the `canCreateDrafts()` Twig function. ([#11797](https://github.com/craftcms/cms/discussions/11797), [#11808](https://github.com/craftcms/cms/pull/11808))
Expand All @@ -90,7 +102,7 @@
- The `elements/save-draft` action now supports being called from the front end. ([#12131](https://github.com/craftcms/cms/issues/12131))
- The `users/upload-user-photo` action now includes a `photoId` key in the response data. ([#12175](https://github.com/craftcms/cms/pull/12175))

### Extending
### Extensibility
- Added `craft\base\conditions\BaseTextConditionRule::inputOptions()`.
- Added `craft\base\Element::EVENT_DEFINE_URL`. ([#12168](https://github.com/craftcms/cms/pull/12168))
- Added `craft\base\ExpirableElementInterface`. ([#11901](https://github.com/craftcms/cms/pull/11901))
Expand Down Expand Up @@ -191,8 +203,6 @@
- Improved GraphQL cache reliability. ([#11994](https://github.com/craftcms/cms/issues/11994), [#12086](https://github.com/craftcms/cms/pull/12086))
- Control panel `.twig` templates are now prioritized over `.html`. ([#11809](https://github.com/craftcms/cms/discussions/11809), [#11840](https://github.com/craftcms/cms/pull/11840))
- Updated Yii to 2.0.46.

### Fixes
- Fixed a bug where addresses weren’t validating their country codes. ([#12161](https://github.com/craftcms/cms/issues/12161))
- Fixed a bug where Entry URI Format, Template, and Default Status switches were focusable within sections’ Site Settings tables, for disabled sites.
- Fixed a bug where `craft\helpers\Db::parseParam()` wasn’t generating conditions that would include `null` values when it should have. ([#11931](https://github.com/craftcms/cms/issues/11931))
Expand Down
15 changes: 11 additions & 4 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,10 @@ public function getUrl(): ?string
'url' => $url,
]);
$this->trigger(self::EVENT_DEFINE_URL, $event);
$url = $event->url;
// If DefineAssetUrlEvent::$url is set to null, only respect that if $handled is true
if ($event->url !== null || $event->handled) {
$url = $event->url;
}
}

return $url !== null ? Html::encodeSpaces($url) : $url;
Expand Down Expand Up @@ -4019,10 +4022,14 @@ public function setFieldValuesFromRequest(string $paramNamespace = ''): void
continue;
}

$this->setFieldValue($field->handle, $value);

// Normalize it now in case the system language changes later
$this->normalizeFieldValue($field->handle);
// (we'll do this with the value directly rather than using setFieldValue() + normalizeFieldValue(),
// because it's slightly more efficient and to workaround an infinite loop bug caused by Matrix
// needing to render an object template on the owner element during normalization, which would in turn
// cause the Matrix field value to be (re-)normalized based on the POST data, and on and on...)
$value = $field->normalizeValue($value, $this);
$this->setFieldValue($field->handle, $value);
$this->_normalizedFieldValues[$field->handle] = true;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,9 @@ public function actionSaveAddress(): ?Response
throw new ForbiddenHttpException('User is not permitted to edit this address.');
}

// Addresses have no status, and the default element save controller also sets the address scenario to live
$address->setScenario(Element::SCENARIO_LIVE);

// Name attributes
$this->populateNameAttributes($address);

Expand Down
2 changes: 1 addition & 1 deletion src/elements/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public function canDelete(User $user): bool
return false;
}

return Craft::$app->getElements()->canDelete($owner, $user);
return Craft::$app->getElements()->canSave($owner, $user);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,10 @@ public function getUrl(mixed $transform = null, ?bool $immediately = null): ?str
'asset' => $this,
]);
$this->trigger(self::EVENT_DEFINE_URL, $event);
$url = $event->url;
// If DefineAssetUrlEvent::$url is set to null, only respect that if $handled is true
if ($event->url !== null || $event->handled) {
$url = $event->url;
}
}

return $url !== null ? Html::encodeSpaces($url) : $url;
Expand Down
5 changes: 3 additions & 2 deletions src/elements/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use craft\validators\UserPasswordValidator;
use DateInterval;
use DateTime;
use DateTimeZone;
use Throwable;
use yii\base\ErrorHandler;
use yii\base\Exception;
Expand Down Expand Up @@ -1423,9 +1424,9 @@ public function getRemainingCooldownTime(): ?DateInterval
{
if ($this->locked) {
$currentTime = DateTimeHelper::currentUTCDateTime();
$cooldownEnd = $this->getCooldownEndTime();
$cooldownEnd = $this->getCooldownEndTime()?->setTimezone(new DateTimeZone('UTC'));

if ($currentTime < $cooldownEnd) {
if ($cooldownEnd && $currentTime < $cooldownEnd) {
return $currentTime->diff($cooldownEnd);
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/helpers/ElementHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,6 @@ public static function attributeHtml(mixed $value): string
]);
}

if (Number::isIntOrFloat($value)) {
return Craft::$app->getFormatter()->asDecimal($value);
}

try {
$value = (string)$value;
} catch (Throwable) {
Expand Down
3 changes: 2 additions & 1 deletion src/services/Gc.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,15 @@ public function removeEmptyTempFolders(): void
$this->_stdout(' > removing empty temp folders ... ');

$emptyFolders = (new Query())
->from(['folders' => Table::VOLUMEFOLDERS])
->select(['folders.id', 'folders.path'])
->from(['folders' => Table::VOLUMEFOLDERS])
->leftJoin(['assets' => Table::ASSETS], '[[assets.folderId]] = [[folders.id]]')
->where([
'folders.volumeId' => null,
'assets.id' => null,
])
->andWhere(['not', ['folders.parentId' => null]])
->andWhere(['not', ['folders.path' => null]])
->pairs();

$fs = Craft::createObject(Temp::class);
Expand Down
2 changes: 1 addition & 1 deletion src/translations/ar/app.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/translations/fa/app.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c3ea31d

Please sign in to comment.