Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Stop using deprecated API #1177

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions code/Extension/UserFormFieldEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions code/Model/EditableFormField/EditableFileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
9 changes: 3 additions & 6 deletions code/Model/EditableFormField/EditableMultipleOptionField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions code/Model/Recipient/EmailRecipient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<nav aria-label="Pages in this form">
<ul class="step-buttons">
<% loop $Steps %>
<li class="step-button-wrapper<% if $First %> current<% end_if %>" data-for="$Name">
<li class="step-button-wrapper<% if $IsFirst %> current<% end_if %>" data-for="$Name">
<%-- Remove js-align class to remove javascript positioning --%>
<button class="step-button-jump js-align" disabled="disabled" data-step="$Pos"><% if $Top.ButtonText %>$Top.ButtonText <% end_if %>$Pos</button>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testValidateAddsErrorWhenMinValueIsGreaterThanMaxValue()

$result = $field->validate();
$this->assertFalse($result->isValid(), 'Validation should fail when min is greater than max');
$this->assertStringContainsString('Minimum length should be less than the maximum length', $result->serialize());
$this->assertStringContainsString('Minimum length should be less than the maximum length', json_encode($result->__serialize()));
}

public function testValidate()
Expand Down
4 changes: 4 additions & 0 deletions tests/php/Model/EditableFormFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use SilverStripe\UserForms\Model\EditableFormField\EditableRadioField;
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
use SilverStripe\UserForms\Model\UserDefinedForm;
use SilverStripe\Dev\Deprecation;

/**
* @package userforms
Expand Down Expand Up @@ -62,6 +63,9 @@ public function testFormFieldPermissions()

public function testCustomRules()
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$this->logInWithPermission('ADMIN');
$form = $this->objFromFixture(UserDefinedForm::class, 'custom-rules-form');

Expand Down
7 changes: 4 additions & 3 deletions tests/php/Model/UserDefinedFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class UserDefinedFormTest extends FunctionalTest
protected function setUp(): void
{
parent::setUp();
Email::config()->update('admin_email', 'no-reply@example.com');
Email::config()->set('admin_email', 'no-reply@example.com');
}

public function testRollbackToVersion()
Expand All @@ -51,6 +51,7 @@ public function testRollbackToVersion()

// @todo
$this->logInWithPermission('ADMIN');
/** @var UserDefinedForm|Versioned $form */
$form = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');

$form->SubmitButtonText = 'Button Text';
Expand All @@ -66,7 +67,7 @@ public function testRollbackToVersion()
$updated = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
$this->assertEquals($updated->SubmitButtonText, 'Updated Button Text');

$form->doRollbackTo($origVersion);
$form->rollbackRecursive($origVersion);

$orignal = Versioned::get_one_by_stage(UserDefinedForm::class, 'Stage', "\"UserDefinedForm\".\"ID\" = $form->ID");
$this->assertEquals($orignal->SubmitButtonText, 'Button Text');
Expand Down Expand Up @@ -521,7 +522,7 @@ public function testIndex()
{
// Test that the $UserDefinedForm is stripped out
$page = $this->objFromFixture(UserDefinedForm::class, 'basic-form-page');
$page->publish('Stage', 'Live');
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);

$result = $this->get($page->Link());
$body = Convert::nl2os($result->getBody(), ''); // strip out newlines
Expand Down