diff --git a/code/Extension/UserFormFieldEditorExtension.php b/code/Extension/UserFormFieldEditorExtension.php index 682d6a9c..ee8bf4d8 100644 --- a/code/Extension/UserFormFieldEditorExtension.php +++ b/code/Extension/UserFormFieldEditorExtension.php @@ -3,6 +3,7 @@ namespace SilverStripe\UserForms\Extension; use SilverStripe\Admin\AdminRootController; +use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\GridField\GridFieldPaginator; use SilverStripe\Forms\Tab; @@ -49,6 +50,10 @@ class UserFormFieldEditorExtension extends DataExtension 'Fields' ]; + private static $cascade_duplicates = [ + 'Fields' + ]; + /** * Adds the field editor to the page. * @@ -235,38 +240,13 @@ public function onAfterUnpublish() * @param bool $doWrite * @param string $manyMany * @return DataObject + * @deprecated 5.3.0 Will be removed without equivalent functionality to replace it */ public function onAfterDuplicate($oldPage, $doWrite, $manyMany) { - // List of EditableFieldGroups, where the key of the array is the ID of the old end group - $fieldGroups = []; - foreach ($oldPage->Fields() as $field) { - /** @var EditableFormField $newField */ - $newField = $field->duplicate(false); - $newField->ParentID = $this->owner->ID; - $newField->ParentClass = $this->owner->ClassName; - $newField->Version = 0; - $newField->write(); - - // If we encounter a group start, record it for later use - if ($field instanceof EditableFieldGroup) { - $fieldGroups[$field->EndID] = $newField; - } - - // If we encounter an end group, link it back to the group start - if ($field instanceof EditableFieldGroupEnd && isset($fieldGroups[$field->ID])) { - $groupStart = $fieldGroups[$field->ID]; - $groupStart->EndID = $newField->ID; - $groupStart->write(); - } - - foreach ($field->DisplayRules() as $customRule) { - $newRule = $customRule->duplicate(false); - $newRule->ParentID = $newField->ID; - $newRule->Version = 0; - $newRule->write(); - } - } + Deprecation::withNoReplacement( + fn() => Deprecation::notice('5.3.0', 'Will be removed without equivalent functionality to replace it') + ); } /** diff --git a/code/Model/EditableFormField.php b/code/Model/EditableFormField.php index e9f3af4b..37f438ba 100755 --- a/code/Model/EditableFormField.php +++ b/code/Model/EditableFormField.php @@ -181,7 +181,9 @@ class EditableFormField extends DataObject 'DisplayRules', ]; - private static $cascade_duplicates = false; + private static $cascade_duplicates = [ + 'DisplayRules', + ]; /** * This is protected rather that private so that it's unit testable diff --git a/code/Model/EditableFormField/EditableMultipleOptionField.php b/code/Model/EditableFormField/EditableMultipleOptionField.php index feb2a981..a8f76fb2 100644 --- a/code/Model/EditableFormField/EditableMultipleOptionField.php +++ b/code/Model/EditableFormField/EditableMultipleOptionField.php @@ -55,6 +55,10 @@ class EditableMultipleOptionField extends EditableFormField 'Options', ]; + private static $cascade_duplicates = [ + 'Options', + ]; + private static $table_name = 'EditableMultipleOptionField'; /** @@ -112,25 +116,6 @@ public function getCMSFields() return $fields; } - /** - * Duplicate a pages content. We need to make sure all the fields attached - * to that page go with it - * {@inheritDoc} - */ - public function duplicate(bool $doWrite = true, array|null $relations = null): static - { - $clonedNode = parent::duplicate(true); - - foreach ($this->Options() as $field) { - $newField = $field->duplicate(false); - $newField->ParentID = $clonedNode->ID; - $newField->Version = 0; - $newField->write(); - } - - return $clonedNode; - } - /** * Return whether or not this field has addable options such as a * {@link EditableDropdown} or {@link EditableRadioField} diff --git a/code/Model/Recipient/EmailRecipient.php b/code/Model/Recipient/EmailRecipient.php index c5b9ee7e..5e456e2a 100644 --- a/code/Model/Recipient/EmailRecipient.php +++ b/code/Model/Recipient/EmailRecipient.php @@ -103,6 +103,10 @@ class EmailRecipient extends DataObject 'CustomRules', ]; + private static $cascade_duplicates = [ + 'CustomRules', + ]; + private static $summary_fields = [ 'EmailAddress', 'EmailSubject', diff --git a/code/UserForm.php b/code/UserForm.php index 82540a89..4858b0bc 100644 --- a/code/UserForm.php +++ b/code/UserForm.php @@ -125,7 +125,9 @@ trait UserForm 'EmailRecipients', ]; - private static $cascade_duplicates = false; + private static $cascade_duplicates = [ + 'EmailRecipients', + ]; /** * @var array @@ -161,9 +163,8 @@ trait UserForm private static $non_live_permissions = ['SITETREE_VIEW_ALL']; /** - * Temporary storage of field ids when the form is duplicated. - * Example layout: array('EditableCheckbox3' => 'EditableCheckbox14') - * @var array + * Unused property + * @deprecated 5.3.0 Will be removed without equivalent functionality to replace it */ protected $fieldsFromTo = [];