Merge pull request #222 from creative-commoners/pulls/2/stop-using-depr

API Stop using deprecated API
This commit is contained in:
Sabina Talipova 2022-12-05 16:41:12 +13:00 committed by GitHub
commit b5e7981aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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']);