Skip to content

Commit 389a8d9

Browse files
committed
Fixed #17696
1 parent dd5dc87 commit 389a8d9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Fixed a bug where reference tags that only referenced an entry’s slug weren’t resolving.
66
- Fixed a race condition that could cause “User is not authorized” errors in the control panel. ([#17694](https://github.com/craftcms/cms/issues/17694))
77
- Fixed a bug where `craft\elements\Asset::getFormattedSizeInBytes()` wasn’t returning `null` when the asset’s `size` property was `null`. ([#17695](https://github.com/craftcms/cms/issues/17695))
8+
- Fixed an error that could occur when saving an address, if any fields contained more than 255 characters, or emoji characters. ([#17696](https://github.com/craftcms/cms/issues/17696))
89

910
## 4.16.8 - 2025-07-25
1011

src/elements/Address.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use craft\fieldlayoutelements\FullNameField;
2121
use craft\models\FieldLayout;
2222
use craft\records\Address as AddressRecord;
23+
use craft\validators\StringValidator;
2324
use yii\base\InvalidConfigException;
2425

2526
/**
@@ -550,6 +551,26 @@ public function defineRules(): array
550551
$rules[] = [['ownerId'], 'number'];
551552
$rules[] = [['countryCode'], 'required'];
552553

554+
$stringFields = [
555+
'countryCode',
556+
'administrativeArea',
557+
'locality',
558+
'dependentLocality',
559+
'postalCode',
560+
'sortingCode',
561+
'addressLine1',
562+
'addressLine2',
563+
'organization',
564+
'organizationTaxId',
565+
'fullName',
566+
'firstName',
567+
'lastName',
568+
'latitude',
569+
'longitude',
570+
];
571+
$rules[] = [$stringFields, 'trim'];
572+
$rules[] = [$stringFields, StringValidator::class, 'max' => 255, 'disallowMb4' => true];
573+
553574
$addressesService = Craft::$app->getAddresses();
554575
$countryCodes = array_keys($addressesService->getCountryRepository()->getList());
555576
$rules[] = [['countryCode'], 'in', 'range' => $countryCodes];

0 commit comments

Comments
 (0)