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 #222

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: 5 additions & 1 deletion src/StringTagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\Validator;
use SilverStripe\ORM\ArrayList;
Expand Down Expand Up @@ -281,7 +282,10 @@ public function saveInto(DataObjectInterface $record)

$record->$name = $this->dataValue();

if (self::config()->get('immediate_write_enabled')) {
$immediate_write_enabled = Deprecation::withNoReplacement(function () {
return self::config()->get('immediate_write_enabled');
});
if ($immediate_write_enabled) {
$record->write();
}
}
Expand Down
11 changes: 9 additions & 2 deletions tests/StringTagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SilverStripe\Forms\Form;
use SilverStripe\TagField\StringTagField;
use SilverStripe\TagField\Tests\Stub\StringTagFieldTestBlogPost;
use SilverStripe\Dev\Deprecation;

class StringTagFieldTest extends SapphireTest
{
Expand Down Expand Up @@ -63,10 +64,13 @@ public function testItSavesTagsOnExistingRecords()

public function testImmediateWriteEnabled()
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
$record->write();

StringTagField::config()->update('immediate_write_enabled', true);
StringTagField::config()->set('immediate_write_enabled', true);

$field = new StringTagField('Tags');
$field->setValue(['Tag1', 'Tag2']);
Expand All @@ -77,10 +81,13 @@ public function testImmediateWriteEnabled()

public function testImmediateWriteDisabled()
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$record = $this->getNewStringTagFieldTestBlogPost('BlogPost1');
$record->write();

StringTagField::config()->update('immediate_write_enabled', false);
StringTagField::config()->set('immediate_write_enabled', false);

$field = new StringTagField('Tags');
$field->setValue(['Tag1', 'Tag2']);
Expand Down