Skip to content

Commit

Permalink
Merge branch '5.x' into 5.5
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/config/app.php
#	src/web/assets/cp/dist/cp.js
#	src/web/assets/cp/dist/cp.js.map
#	src/web/assets/cp/dist/css/cp.css
#	src/web/assets/cp/dist/css/cp.css.map
  • Loading branch information
brandonkelly committed Oct 10, 2024
2 parents ead0a97 + 7f26db4 commit 0c7ff1f
Show file tree
Hide file tree
Showing 71 changed files with 1,479 additions and 76 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
# Release Notes for Craft CMS 5

## Unreleased
## 5.4.7.1 - 2024-10-09

- Custom field condition rules are now ignored if they reference a field with an incompatible type. ([#15850](https://github.com/craftcms/cms/issues/15850))
- Fixed an error that could occur if Hyper was installed. ([#15867](https://github.com/craftcms/cms/issues/15867))
- Fixed an error occurred when running `migrate` commands with an invalid `--plugin` option value.

## 5.4.7 - 2024-10-08

- The Plugin Store now displays plugin ratings and reviews. ([#15860](https://github.com/craftcms/cms/pull/15860))
- An `InvalidConfigException` is now thrown if the `defaultCountryCode` config setting is set to an empty string. ([#15812](https://github.com/craftcms/cms/pull/15812))
- Fixed an error that could occur when saving an element, if a Date field’s time zone input was focused.
- Fixed a bug where the time zones listed in Date fields weren’t labelled properly based on the selected date. ([#15805](https://github.com/craftcms/cms/issues/15805))
- Fixed an error that could occur if a native element property was attempted to be eager-loaded. ([#15822](https://github.com/craftcms/cms/issues/15822))
- Fixed errors that could occur if a custom source or field condition referenced a custom field whose type had changed. ([#15850](https://github.com/craftcms/cms/issues/15850))
- Fixed a bug where disclosure menus weren’t sticking to their trigger element as it was scrolled, if it was within a slideout or other inline-scrollable container. ([#15852](https://github.com/craftcms/cms/issues/15852))
- Fixed a bug where the default backup command for MySQL was exporting triggers twice. ([#15854](https://github.com/craftcms/cms/pull/15854))
- Fixed a bug where Multi-select fields were saving the selected options in the user-selected order rather than the field-defined order. ([#15857](https://github.com/craftcms/cms/issues/15857))
- Fixed a bug where field toggling wasn’t working properly for boolean menus and radio groups.
- Fixed a bug where eager-loading wasn’t working properly when multiple fields had the same handle. ([#15796](https://github.com/craftcms/cms/issues/15796))
- Fixed a bug where where required Full Name fields weren’t getting enforced for users. ([#15808](https://github.com/craftcms/cms/issues/15808))
- Fixed a bug where relation fields weren’t merging uploaded asset IDs with the existing field values. ([#15809](https://github.com/craftcms/cms/issues/15809))
- Fixed a bug where the “Add” menu within field layout designer tabs was always being positioned below the button. ([#15852](https://github.com/craftcms/cms/issues/15852))
- Fixed a bug where Number fields weren’t getting sorted properly in PostgreSQL. ([#15828](https://github.com/craftcms/cms/issues/15828))
- Fixed a SQL error that occurred when upgrading to Craft 5 on MySQL, if `sql_generate_invisible_primary_key` was enabled. ([#15853](https://github.com/craftcms/cms/issues/15853))
- Fixed a missing authorization vulnerability.

## 5.4.6 - 2024-09-27
Expand Down
15 changes: 12 additions & 3 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -5032,7 +5032,7 @@ public function hasEagerLoadedElements(string $handle): bool
{
if (!isset($this->_eagerLoadedElements[$handle])) {
// See if we have it stored with the field layout provider’s handle
$providerHandle = $this->getFieldLayout()?->provider?->getHandle();
$providerHandle = $this->providerHandle();
if ($providerHandle !== null && isset($this->_eagerLoadedElements["$providerHandle:$handle"])) {
$handle = "$providerHandle:$handle";
}
Expand All @@ -5048,7 +5048,7 @@ public function getEagerLoadedElements(string $handle): ?ElementCollection
{
if (!isset($this->_eagerLoadedElements[$handle])) {
// See if we have it stored with the field layout provider’s handle
$providerHandle = $this->getFieldLayout()?->provider?->getHandle();
$providerHandle = $this->providerHandle();
if ($providerHandle !== null && isset($this->_eagerLoadedElements["$providerHandle:$handle"])) {
$handle = "$providerHandle:$handle";
} else {
Expand Down Expand Up @@ -5122,7 +5122,7 @@ public function getEagerLoadedElementCount(string $handle): ?int
{
if (!isset($this->_eagerLoadedElementCounts[$handle])) {
// See if we have it stored with the field layout provider’s handle
$providerHandle = $this->getFieldLayout()?->provider?->getHandle();
$providerHandle = $this->providerHandle();
if ($providerHandle !== null && isset($this->_eagerLoadedElements["$providerHandle:$handle"])) {
$handle = "$providerHandle:$handle";
}
Expand All @@ -5139,6 +5139,15 @@ public function setEagerLoadedElementCount(string $handle, int $count): void
$this->_eagerLoadedElementCounts[$handle] = $count;
}

private function providerHandle(): ?string
{
try {
return $this->getFieldLayout()?->provider?->getHandle();
} catch (InvalidConfigException) {
return null;
}
}

/**
* @inheritdoc
*/
Expand Down
6 changes: 6 additions & 0 deletions src/base/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,12 @@ public function getSortOption(): array
$orderBy = "CAST($orderBy AS CHAR(255))";
}

// for pgsql, we have to make sure decimals column type is cast to decimal, otherwise it won't be sorted correctly
// see https://github.com/craftcms/cms/issues/15828
if ($db->getIsPgsql() && is_string($dbType) && Db::parseColumnType($dbType) === Schema::TYPE_DECIMAL) {
$orderBy = "CAST($orderBy AS DECIMAL)";
}

// The attribute name should match the table attribute name,
// per ElementSources::getTableAttributesForFieldLayouts()
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.4.6',
'version' => '5.4.7.1',
'schemaVersion' => '5.5.0.0',
'minVersionRequired' => '4.5.0',
'basePath' => dirname(__DIR__), // Defines the @app alias
Expand Down
2 changes: 1 addition & 1 deletion src/console/controllers/MigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function optionAliases(): array
/**
* @inheritdoc
*/
public function runAction($id, $params = []): int
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();
Expand Down
1 change: 1 addition & 0 deletions src/db/mysql/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public function getDefaultBackupCommand(?array $ignoreTables = null): string

$schemaDump = (clone $baseCommand)
->addArg('--no-data')
->addArg('--skip-triggers')
->addArg('--result-file=', '{file}')
->addArg('{database}');

Expand Down
4 changes: 3 additions & 1 deletion src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1382,8 +1382,10 @@ public function getAvailableEntryTypes(): array
if (isset($this->fieldId)) {
/** @var EntryType[] $entryTypes */
$entryTypes = $this->getField()->getFieldLayoutProviders();
} else {
} elseif (isset($this->sectionId)) {
$entryTypes = $this->getSection()->getEntryTypes();
} else {
throw new InvalidConfigException('Either `sectionId` or `fieldId` + `ownerId` must be set on the entry.');
}

// Fire a 'defineEntryTypes' event
Expand Down
8 changes: 5 additions & 3 deletions src/fields/BaseOptionsField.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,11 @@ public function serializeValue(mixed $value, ?ElementInterface $element): mixed
{
if ($value instanceof MultiOptionsFieldData) {
$serialized = [];
foreach ($value as $selectedValue) {
/** @var OptionData $selectedValue */
$serialized[] = $selectedValue->value;
// Build the list out in the original option order
foreach ($value->getOptions() as $option) {
if ($option->selected) {
$serialized[] = $option->value;
}
}
return $serialized;
}
Expand Down
23 changes: 21 additions & 2 deletions src/fields/conditions/CountryFieldConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Craft;
use craft\base\conditions\BaseMultiSelectConditionRule;
use craft\fields\Country;
use yii\base\InvalidConfigException;

/**
* Options field condition rule.
Expand All @@ -16,16 +17,35 @@ class CountryFieldConditionRule extends BaseMultiSelectConditionRule implements
{
use FieldConditionRuleTrait;

/**
* @inheritdoc
*/
protected function options(): array
{
return Craft::$app->getAddresses()->getCountryList(Craft::$app->language);
}

/**
* @inheritdoc
*/
protected function inputHtml(): string
{
if (!$this->field() instanceof Country) {
throw new InvalidConfigException();
}

return parent::inputHtml();
}

/**
* @inheritdoc
*/
protected function elementQueryParam(): ?array
{
if (!$this->field() instanceof Country) {
return null;
}

return $this->paramValue();
}

Expand All @@ -35,8 +55,7 @@ protected function elementQueryParam(): ?array
protected function matchFieldValue($value): bool
{
if (!$this->field() instanceof Country) {
// No longer a Country field
return false;
return true;
}

return $this->matchValue($value);
Expand Down
20 changes: 18 additions & 2 deletions src/fields/conditions/DateFieldConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use craft\base\conditions\BaseDateRangeConditionRule;
use craft\fields\Date;
use DateTime;
use yii\base\InvalidConfigException;

/**
* Date field condition rule.
Expand All @@ -16,11 +17,27 @@ class DateFieldConditionRule extends BaseDateRangeConditionRule implements Field
{
use FieldConditionRuleTrait;

/**
* @inheritdoc
*/
protected function inputHtml(): string
{
if (!$this->field() instanceof Date) {
throw new InvalidConfigException();
}

return parent::inputHtml();
}

/**
* @inheritdoc
*/
protected function elementQueryParam(): array|string|null
{
if (!$this->field() instanceof Date) {
return null;
}

return $this->queryParamValue();
}

Expand All @@ -30,8 +47,7 @@ protected function elementQueryParam(): array|string|null
protected function matchFieldValue($value): bool
{
if (!$this->field() instanceof Date) {
// No longer a Date field
return false;
return true;
}

/** @var DateTime|null $value */
Expand Down
22 changes: 19 additions & 3 deletions src/fields/conditions/LightswitchFieldConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use craft\base\conditions\BaseLightswitchConditionRule;
use craft\fields\Lightswitch;
use yii\base\InvalidConfigException;

/**
* Lightswitch field condition rule.
Expand All @@ -18,8 +19,24 @@ class LightswitchFieldConditionRule extends BaseLightswitchConditionRule impleme
/**
* @inheritdoc
*/
protected function elementQueryParam(): bool
protected function inputHtml(): string
{
if (!$this->field() instanceof Lightswitch) {
throw new InvalidConfigException();
}

return parent::inputHtml();
}

/**
* @inheritdoc
*/
protected function elementQueryParam(): ?bool
{
if (!$this->field() instanceof Lightswitch) {
return null;
}

return $this->value;
}

Expand All @@ -29,8 +46,7 @@ protected function elementQueryParam(): bool
protected function matchFieldValue($value): bool
{
if (!$this->field() instanceof Lightswitch) {
// No longer a Lightswitch field
return false;
return true;
}

/** @var bool $value */
Expand Down
11 changes: 6 additions & 5 deletions src/fields/conditions/MoneyFieldConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,8 @@ protected function inputHtml(): string
*/
protected function inputOptions(): array
{
/** @var Money $field */
$field = $this->field();
if (!$field instanceof Money) {
throw new InvalidConfigException();
}
$defaultValue = null;
if ($field->defaultValue !== null) {
$defaultValue = MoneyHelper::toNumber(new MoneyLibrary($field->defaultValue, new Currency($field->currency)));
Expand Down Expand Up @@ -136,6 +134,10 @@ protected function inputOptions(): array
*/
protected function elementQueryParam(): ?string
{
if (!$this->field() instanceof Money) {
return null;
}

return $this->paramValue();
}

Expand All @@ -145,8 +147,7 @@ protected function elementQueryParam(): ?string
protected function matchFieldValue($value): bool
{
if (!$this->field() instanceof Money) {
// No longer a Money field
return false;
return true;
}

/** @var int|float|null $value */
Expand Down
20 changes: 18 additions & 2 deletions src/fields/conditions/OptionsFieldConditionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use craft\fields\data\OptionData;
use craft\fields\data\SingleOptionFieldData;
use Illuminate\Support\Collection;
use yii\base\InvalidConfigException;

/**
* Options field condition rule.
Expand Down Expand Up @@ -37,11 +38,27 @@ protected function options(): array
->all();
}

/**
* @inheritdoc
*/
protected function inputHtml(): string
{
if (!$this->field() instanceof BaseOptionsField) {
throw new InvalidConfigException();
}

return parent::inputHtml();
}

/**
* @inheritdoc
*/
protected function elementQueryParam(): ?array
{
if (!$this->field() instanceof BaseOptionsField) {
return null;
}

return $this->paramValue();
}

Expand All @@ -51,8 +68,7 @@ protected function elementQueryParam(): ?array
protected function matchFieldValue($value): bool
{
if (!$this->field() instanceof BaseOptionsField) {
// No longer an options field
return false;
return true;
}

if ($value instanceof MultiOptionsFieldData) {
Expand Down
Loading

0 comments on commit 0c7ff1f

Please sign in to comment.