From c467fa73c105aecac1356d5b1f225f530b57aba7 Mon Sep 17 00:00:00 2001 From: Brandon Kelly Date: Thu, 9 Jan 2020 10:37:33 -0800 Subject: [PATCH] Update unsaved element URIs on autosave Resolves #4581 --- CHANGELOG-v3.4.md | 1 + CHANGELOG-v3.md | 1 + src/validators/ElementUriValidator.php | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-v3.4.md b/CHANGELOG-v3.4.md index b61412604c2..7c0b622d415 100644 --- a/CHANGELOG-v3.4.md +++ b/CHANGELOG-v3.4.md @@ -208,6 +208,7 @@ - The Assets index page now updates the URL when the selected volume changes. - Sections’ entry URI format settings are now shown when running Craft in headless mode. ([#4934](https://github.com/craftcms/cms/issues/4934)) - The “Primary entry page” preview target is now user-customizable alongside all other preview targets in sections’ settings. ([#4520](https://github.com/craftcms/cms/issues/4520)) +- Unsaved entries’ URIs are now updated on each autosave. ([#4581](https://github.com/craftcms/cms/issues/4581)) - Plain Text fields can now specify a maximum size in bytes. ([#5099](https://github.com/craftcms/cms/issues/5099)) - Plain Text fields’ Column Type settings now have an “Automatic” option, which is selected by default for new fields. ([#5099](https://github.com/craftcms/cms/issues/5099)) - Matrix fields now show an accurate description of their propagation behavior in the translation icon tooltip. ([#5304](https://github.com/craftcms/cms/issues/5304)) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index eb6c7f8fb00..b2cef6bb03d 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -20,6 +20,7 @@ - The queue info in the global sidebar no longer shows an HUD with job details when clicked; the user is now brought to the new Queue Manager utility, if they have permission to view it. ([#4040](https://github.com/craftcms/cms/issues/4040)) - Element index pages once again link to elements’ edit pages even if `getIsEditable()` returns `false`. - “Edit” Asset pages now have a read-only mode for assets that the user is allowed to view but not modify. +- Unsaved entries’ URIs are now updated on each autosave. ([#4581](https://github.com/craftcms/cms/issues/4581)) - Replaced the deprecated zend-feed library with laminas-feed. ([#5400](https://github.com/craftcms/cms/issues/5400)) - Updated yii2-queue to 2.3. diff --git a/src/validators/ElementUriValidator.php b/src/validators/ElementUriValidator.php index 0bd60ca29f0..16918aa1ffd 100644 --- a/src/validators/ElementUriValidator.php +++ b/src/validators/ElementUriValidator.php @@ -46,7 +46,13 @@ public function validateAttribute($model, $attribute) // If this is a draft or revision and it already has a URI, leave it alone /** @var Element $model */ - if (($model->getIsDraft() || $model->getIsRevision()) && $model->uri) { + if ( + $model->uri && + ( + ($model->getIsDraft() && !$model->getIsUnsavedDraft()) || + $model->getIsRevision() + ) + ) { return; }