From 7a6cd1c21133cfaf4e5dd749703d5b07c8d3f2a8 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 29 Nov 2022 09:36:08 +1300 Subject: [PATCH] API Stop using deprecated API --- code/Extension/UserFormFieldEditorExtension.php | 6 +++--- code/Model/EditableFormField/EditableFileField.php | 4 ++-- .../EditableFormField/EditableMultipleOptionField.php | 9 +++------ code/Model/Recipient/EmailRecipient.php | 4 ++-- .../UserForms/Form/Includes/UserFormProgress.ss | 2 +- .../Model/EditableFormField/EditableNumericFieldTest.php | 2 +- tests/php/Model/EditableFormFieldTest.php | 4 ++++ tests/php/Model/UserDefinedFormTest.php | 7 ++++--- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/code/Extension/UserFormFieldEditorExtension.php b/code/Extension/UserFormFieldEditorExtension.php index 173c960c2..c1238e449 100644 --- a/code/Extension/UserFormFieldEditorExtension.php +++ b/code/Extension/UserFormFieldEditorExtension.php @@ -56,7 +56,7 @@ public function updateCMSFields(FieldList $fields) { $fieldEditor = $this->getFieldEditorGrid(); - $fields->insertAfter(new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields')), 'Main'); + $fields->insertAfter('Main', new Tab('FormFields', _t(__CLASS__.'.FORMFIELDS', 'Form Fields'))); $fields->addFieldToTab('Root.FormFields', $fieldEditor); return $fields; @@ -192,7 +192,7 @@ public function onAfterPublish() foreach ($this->owner->Fields() as $field) { // store any IDs of fields we publish so we don't unpublish them $seenIDs[] = $field->ID; - $field->doPublish(Versioned::DRAFT, Versioned::LIVE); + $field->publishRecursive(); $field->destroy(); } @@ -291,7 +291,7 @@ public function isModifiedOnDraft() public function onAfterRevertToLive() { foreach ($this->owner->Fields() as $field) { - $field->copyVersionToStage(Versioned::LIVE, Versioned::DRAFT, false); + $field->copyVersionToStage(Versioned::LIVE, Versioned::DRAFT); $field->writeWithoutVersion(); } } diff --git a/code/Model/EditableFormField/EditableFileField.php b/code/Model/EditableFormField/EditableFileField.php index b8b6aaa6e..4d17949a5 100755 --- a/code/Model/EditableFormField/EditableFileField.php +++ b/code/Model/EditableFormField/EditableFileField.php @@ -265,8 +265,8 @@ public function getSubmittedFormField() */ public static function get_php_max_file_size() { - $maxUpload = File::ini2bytes(ini_get('upload_max_filesize')); - $maxPost = File::ini2bytes(ini_get('post_max_size')); + $maxUpload = Convert::memstring2bytes(ini_get('upload_max_filesize')); + $maxPost = Convert::memstring2bytes(ini_get('post_max_size')); return min($maxUpload, $maxPost); } diff --git a/code/Model/EditableFormField/EditableMultipleOptionField.php b/code/Model/EditableFormField/EditableMultipleOptionField.php index e78b40381..dbd86257b 100644 --- a/code/Model/EditableFormField/EditableMultipleOptionField.php +++ b/code/Model/EditableFormField/EditableMultipleOptionField.php @@ -116,16 +116,13 @@ public function getCMSFields() * Duplicate a pages content. We need to make sure all the fields attached * to that page go with it * + * @param bool $doWrite @deprecated + * @param string $manyMany @deprecated * {@inheritDoc} */ public function duplicate($doWrite = true, $manyMany = 'many_many') { - // Versioned 1.0 has a bug where [] will result in _all_ relations being duplicated - if ($manyMany === 'many_many' && !$this->manyMany()) { - $manyMany = null; - } - - $clonedNode = parent::duplicate(true, $manyMany); + $clonedNode = parent::duplicate(true); foreach ($this->Options() as $field) { /** @var EditableOption $newField */ diff --git a/code/Model/Recipient/EmailRecipient.php b/code/Model/Recipient/EmailRecipient.php index 11af738e8..975d8d5f2 100644 --- a/code/Model/Recipient/EmailRecipient.php +++ b/code/Model/Recipient/EmailRecipient.php @@ -332,12 +332,12 @@ public function getCMSFields() if ($templates) { $fields->insertBefore( + 'EmailBodyHtml', DropdownField::create( 'EmailTemplate', _t('SilverStripe\\UserForms\\Model\\UserDefinedForm.EMAILTEMPLATE', 'Email template'), $templates - )->addExtraClass('toggle-html-only'), - 'EmailBodyHtml' + )->addExtraClass('toggle-html-only') ); } diff --git a/templates/SilverStripe/UserForms/Form/Includes/UserFormProgress.ss b/templates/SilverStripe/UserForms/Form/Includes/UserFormProgress.ss index 0eebf13ba..5bfb843df 100644 --- a/templates/SilverStripe/UserForms/Form/Includes/UserFormProgress.ss +++ b/templates/SilverStripe/UserForms/Form/Includes/UserFormProgress.ss @@ -7,7 +7,7 @@