API Stop using deprecated API

This commit is contained in:
Steve Boyd 2022-11-24 17:39:57 +13:00
parent 8822b0f0b5
commit dc932bd72d
2 changed files with 14 additions and 3 deletions

View File

@ -6,6 +6,7 @@ use Iterator;
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;
@ -281,7 +282,10 @@ class StringTagField extends DropdownField
$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();
}
}

View File

@ -8,6 +8,7 @@ use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Form;
use SilverStripe\TagField\StringTagField;
use SilverStripe\TagField\Tests\Stub\StringTagFieldTestBlogPost;
use SilverStripe\Dev\Deprecation;
class StringTagFieldTest extends SapphireTest
{
@ -63,10 +64,13 @@ class StringTagFieldTest extends SapphireTest
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']);
@ -77,10 +81,13 @@ class StringTagFieldTest extends SapphireTest
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']);