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 Add new deprecation notices. #10691

Merged
merged 1 commit into from
Feb 15, 2023
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
3 changes: 3 additions & 0 deletions src/Core/Manifest/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ class Module implements Serializable

/**
* Return value of getCIConfig() when module uses PHPUNit 9
* @deprecated 4.13.0 Will be removed without equivalent functionality
*/
const CI_PHPUNIT_NINE = 'CI_PHPUNIT_NINE';

/**
* Return value of getCIConfig() when module uses PHPUNit 5
* @deprecated 4.13.0 Will be removed without equivalent functionality
*/
const CI_PHPUNIT_FIVE = 'CI_PHPUNIT_FIVE';

/**
* Return value of getCIConfig() when module does not use any CI
* @deprecated 4.13.0 Will be removed without equivalent functionality
*/
const CI_UNKNOWN = 'CI_UNKNOWN';

Expand Down
3 changes: 2 additions & 1 deletion src/Dev/CSVParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* $obj->write();
* }
* </code>
* @deprecated 4.13.0 Use League\Csv\Reader instead
*/
class CSVParser implements Iterator
{
Expand Down Expand Up @@ -115,7 +116,7 @@ class CSVParser implements Iterator
*/
public function __construct($filename, $delimiter = ",", $enclosure = '"')
{
Deprecation::notice('5.0', __CLASS__ . ' is deprecated, use ' . Reader::class . ' instead');
Deprecation::notice('4.13.0', 'Use ' . Reader::class . ' instead', Deprecation::SCOPE_CLASS);
Comment on lines -118 to +119
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm explicitly not wrapping this one in Deprecation::withNoReplacement() because there are only a few instances of it in use in our code, and we can wrap those instead. This seems likely to be used pretty frequently in projects so it's good for their uses to pop up in the main deprecation notices.

$filename = Director::getAbsFile($filename);
$this->filename = $filename;
$this->delimiter = $delimiter;
Expand Down
10 changes: 5 additions & 5 deletions src/Dev/CsvBulkLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ protected function processChunk($filepath, $preview = false)
Deprecation::notice('4.12.0', 'Process rows individually instead');
$results = BulkLoader_Result::create();

$csv = new CSVParser(
$filepath,
$this->delimiter,
$this->enclosure
);
$delimiter = $this->delimiter;
$enclosure = $this->enclosure;
$csv = Deprecation::withNoReplacement(function () use ($filepath, $delimiter, $enclosure) {
return new CSVParser($filepath, $delimiter, $enclosure);
});
Comment on lines -257 to +261
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only usage of this class in our code that I could find.

Since this whole method is deprecated, it's easier to just wrap this instantiation than to replace it with the Reader class. It's gone in CMS 5 anyway.


// ColumnMap has two uses, depending on whether hasHeaderRow is set
if ($this->columnMap) {
Expand Down
8 changes: 8 additions & 0 deletions src/Dev/TestSession_STResponseWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* Wrapper around HTTPResponse to make it look like a SimpleHTTPResposne
* @deprecated 4.13.0 Will be removed without equivalent functionality to replace it
*/
class TestSession_STResponseWrapper
{
Expand All @@ -17,6 +18,13 @@ class TestSession_STResponseWrapper

public function __construct(HTTPResponse $response)
{
Deprecation::withNoReplacement(function () {
Deprecation::notice(
'4.13.0',
'Will be removed without equivalent functionality to replace it',
Deprecation::SCOPE_CLASS
);
});
$this->response = $response;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/php/Dev/CSVParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\Dev\Tests;

use SilverStripe\Dev\CSVParser;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;

class CSVParserTest extends SapphireTest
Expand All @@ -19,6 +20,9 @@ protected function setUp(): void
{
parent::setUp();
$this->csvPath = __DIR__ . '/CsvBulkLoaderTest/csv/';
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
}

public function testParsingWithHeaders()
Expand Down