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 Update deprecations #10525

Merged
merged 8 commits into from
Oct 13, 2022
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
8 changes: 2 additions & 6 deletions src/Control/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,11 @@ public function render($params = null)
* called before Controller::init(). That is, you must call it in your controller's init method
* before it calls parent::init().
*
* @deprecated 4.1.0:5.0.0 Add this controller's url to
* SilverStripe\Security\BasicAuthMiddleware.URLPatterns injected property instead of setting false
* @deprecated 4.1.0 Add this controller's url to SilverStripe\Security\BasicAuthMiddleware.URLPatterns injected property instead
*/
public function disableBasicAuth()
{
Deprecation::notice(
'5.0',
'Add this controller\'s url to ' . BasicAuthMiddleware::class . '.URLPatterns injected property instead'
);
Deprecation::notice('4.1.0', 'Add this controller\'s url to SilverStripe\Security\BasicAuthMiddleware.URLPatterns injected property instead');
$this->basicAuthEnabled = false;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Control/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Control;

use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\FieldType\DBDatetime;
use LogicException;

Expand Down Expand Up @@ -200,10 +201,11 @@ private function cookieIsSecure(string $sameSite, bool $secure): bool
/**
* Get the correct samesite value - Session cookies use a different configuration variable.
*
* @deprecated 5.0 The relevant methods will include a `$sameSite` parameter instead.
* @deprecated 4.12.0 The relevant methods will include a `$sameSite` parameter instead.
*/
private function getSameSite(string $name): string
{
Deprecation::notice('4.12.0', 'The relevant methods will include a `$sameSite` parameter instead.');
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
if ($name === session_name()) {
return Session::config()->get('cookie_samesite');
}
Expand Down
3 changes: 2 additions & 1 deletion src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,11 @@ public function handleRequest(HTTPRequest $request)
*
* @return bool
*
* @deprecated 5.0 Kernel::isFlushed to be used instead
* @deprecated 4.12.0 Use Kernel::isFlushed instead
*/
public static function isManifestFlushed()
{
Deprecation::notice('4.12.0', 'Use Kernel::isFlushed instead');
$kernel = Injector::inst()->get(Kernel::class);

// Only CoreKernel implements this method at the moment
Expand Down
2 changes: 1 addition & 1 deletion src/Control/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ public function BaseURL()
}

/**
* @deprecated Will be removed without equivalent functionality to replace it
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
*
* Debugging help
*
Expand Down
6 changes: 6 additions & 0 deletions src/Control/Email/SwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Control\Email;

use SilverStripe\Dev\Deprecation;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
Expand Down Expand Up @@ -37,6 +38,11 @@ class SwiftMailer implements Mailer
* @param Email $message
* @return bool Whether the sending was "successful" or not
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
*/
public function __construct()
{
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
}

public function send($message)
{
$swiftMessage = $message->getSwiftMessage();
Expand Down
7 changes: 7 additions & 0 deletions src/Control/Email/SwiftPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

namespace SilverStripe\Control\Email;

use SilverStripe\Dev\Deprecation;

/**
* @deprecated 4.12.0 Will be replaced with symfony/mailer
*/
class SwiftPlugin implements \Swift_Events_SendListener
{
public function __construct()
{
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
}

/**
* Before sending a message make sure all our overrides are taken into account
*
Expand Down
26 changes: 14 additions & 12 deletions src/Control/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,43 +372,43 @@ public static function get_mime_type($filename)
/**
* Set the maximum age of this page in web caches, in seconds.
*
* @deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
* @param int $age
*/
public static function set_cache_age($age)
{
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead');
Deprecation::notice('4.2.0', 'Use HTTPCacheControlMiddleware::singleton()->setMaxAge($age) instead');
self::$cache_age = $age;
HTTPCacheControlMiddleware::singleton()->setMaxAge($age);
}

/**
* @param string $dateString
* @deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
*/
public static function register_modification_date($dateString)
{
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware::registerModificationDate() instead');
Deprecation::notice('4.2.0', 'Use HTTPCacheControlMiddleware::registerModificationDate() instead');
HTTPCacheControlMiddleware::singleton()->registerModificationDate($dateString);
}

/**
* @param int $timestamp
* @deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
*/
public static function register_modification_timestamp($timestamp)
{
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware::registerModificationDate() instead');
Deprecation::notice('4.2.0', 'Use HTTPCacheControlMiddleware::registerModificationDate() instead');
HTTPCacheControlMiddleware::singleton()->registerModificationDate($timestamp);
}

/**
* @deprecated 4.2.0:5.0.0 Use ChangeDetectionMiddleware instead
* @deprecated 4.2.0 Use ChangeDetectionMiddleware instead
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
* @param string $etag
*/
public static function register_etag($etag)
{
Deprecation::notice('5.0', 'Use ChangeDetectionMiddleware instead');
Deprecation::notice('4.2.0', 'Use ChangeDetectionMiddleware instead');
if (strpos($etag ?? '', '"') !== 0) {
$etag = "\"{$etag}\"";
}
Expand All @@ -426,11 +426,11 @@ public static function register_etag($etag)
* output directly.
*
* @param HTTPResponse $response
* @deprecated 4.2.0:5.0.0 Headers are added automatically by HTTPCacheControlMiddleware instead.
* @deprecated 4.2.0 Headers are added automatically by HTTPCacheControlMiddleware instead.
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
*/
public static function add_cache_headers($response = null)
{
Deprecation::notice('5.0', 'Headers are added automatically by HTTPCacheControlMiddleware instead.');
Deprecation::notice('4.2.0', 'Headers are added automatically by HTTPCacheControlMiddleware instead.');

// Skip if deprecated API is disabled
if (Config::inst()->get(HTTP::class, 'ignoreDeprecatedCaching')) {
Expand Down Expand Up @@ -473,13 +473,14 @@ public static function add_cache_headers($response = null)
/**
* Ensure that all deprecated HTTP cache settings are respected
*
* @deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware instead
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware instead
* @throws \LogicException
* @param HTTPRequest $request
* @param HTTPResponse $response
*/
public static function augmentState(HTTPRequest $request, HTTPResponse $response)
{
Deprecation::notice('4.2.0', 'Use HTTPCacheControlMiddleware instead');
// Skip if deprecated API is disabled
$config = Config::forClass(HTTP::class);
if ($config->get('ignoreDeprecatedCaching')) {
Expand Down Expand Up @@ -560,11 +561,12 @@ public static function augmentState(HTTPRequest $request, HTTPResponse $response
* is always in GMT: the number of seconds since January 1 1970 00:00:00 GMT)
*
* @param int $timestamp
* @deprecated 4.2.0:5.0.0 Inline if you need this
* @deprecated 4.2.0 Use native php function gmdate() instead
* @return string
*/
public static function gmt_date($timestamp)
{
Deprecation::notice('4.2.0', 'Use native php function gmdate() instead');
return gmdate('D, d M Y H:i:s', $timestamp) . ' GMT';
}

Expand Down
4 changes: 3 additions & 1 deletion src/Control/HTTPRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Control;

use SilverStripe\Dev\Deprecation;
use ArrayAccess;
use BadMethodCallException;
use InvalidArgumentException;
Expand Down Expand Up @@ -910,10 +911,11 @@ private static function isValidHttpMethod($method)
* @param string $origMethod Original HTTP method from the browser request
* @param array $postVars
* @return string HTTP method (all uppercase)
* @deprecated 4.4.7
* @deprecated 4.4.7 Will be removed without equivalent functionality
*/
public static function detect_method($origMethod, $postVars)
{
Deprecation::notice('4.4.7', 'Will be removed without equivalent functionality');
if (isset($postVars['_method'])) {
if (!self::isValidHttpMethod($postVars['_method'])) {
throw new InvalidArgumentException('HTTPRequest::detect_method(): Invalid "_method" parameter');
Expand Down
3 changes: 2 additions & 1 deletion src/Control/RequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Middleware that provides back-support for the deprecated RequestFilter API.
*
* @deprecated 4.0.0:5.0.0 Use HTTPMiddleware directly instead.
* @deprecated 4.0.1 Use HTTPMiddleware directly instead.
*/
class RequestProcessor implements HTTPMiddleware
{
Expand All @@ -29,6 +29,7 @@ class RequestProcessor implements HTTPMiddleware
*/
public function __construct($filters = [])
{
Deprecation::notice('4.0.1', 'Use HTTPMiddleware directly instead.', Deprecation::SCOPE_CLASS);
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
$this->filters = $filters;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Control/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,13 @@ public function save(HTTPRequest $request)
* Recursively apply the changes represented in $data to $dest.
* Used to update $_SESSION
*
* @deprecated 4.1.0:5.0.0 Use recursivelyApplyChanges() instead
* @deprecated 4.1.0 Use recursivelyApplyChanges() instead
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
* @param array $data
* @param array $dest
*/
protected function recursivelyApply($data, &$dest)
{
Deprecation::notice('5.0', 'Use recursivelyApplyChanges() instead');
Deprecation::notice('4.1.0', 'Use recursivelyApplyChanges() instead');
foreach ($data as $k => $v) {
if (is_array($v)) {
if (!isset($dest[$k]) || !is_array($dest[$k])) {
Expand Down
4 changes: 3 additions & 1 deletion src/Control/SimpleResourceURLGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Control;

use SilverStripe\Dev\Deprecation;
use InvalidArgumentException;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
Expand Down Expand Up @@ -159,12 +160,13 @@ protected function resolveModuleResource(ModuleResource $resource)
/**
* Resolve resource in the absence of a public/ folder
*
* @deprecated 4.1.0:5.0.0 Will be removed in 5.0 when public/ folder becomes mandatory
* @deprecated 4.1.0 Will be removed without equivalent functionality when public/ folder becomes mandatory
* @param string $relativePath
* @return array List of [$exists, $absolutePath, $relativePath]
*/
protected function resolveUnsecuredResource($relativePath)
{
Deprecation::notice('4.1.0', 'Will be removed without equivalent functionality when public/ folder becomes mandatory');
// Check if the path requested is public-only, but we have no public folder
$publicOnly = $this->inferPublicResourceRequired($relativePath);
if ($publicOnly) {
Expand Down
10 changes: 6 additions & 4 deletions src/Core/BaseKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,11 @@ protected function bootErrorHandling()
*
* @return string
*
* @deprecated 5.0 use Director::get_environment_type() instead. Since 5.0 it should return only if kernel overrides. No checking SESSION or Environment.
* @deprecated 4.12.0 Use Director::get_environment_type() instead
*/
public function getEnvironment()
{
Deprecation::notice('4.12.0', 'Use Director::get_environment_type() instead');
// Check set
if ($this->enviroment) {
return $this->enviroment;
Expand All @@ -288,10 +289,11 @@ public function getEnvironment()
*
* @return null|string
*
* @deprecated 5.0 Use Director::get_session_environment_type() instead
* @deprecated 4.12.0 Use Director::get_session_environment_type() instead
*/
protected function sessionEnvironment()
{
Deprecation::notice('4.12.0', 'Use Director::get_session_environment_type() instead');
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved
if (!$this->booted) {
// session is not initialyzed yet, neither is manifest
return null;
Expand Down Expand Up @@ -378,11 +380,11 @@ protected function buildManifestCacheFactory()
* The purpose of this method is to avoid loading PHPUnit test files with incompatible definitions.
*
* @return string[] List of CI types to ignore as defined by `Module`.
* @deprecated 5.0.0
* @deprecated 4.12.0 Will be removed without equivalent functionality
*/
protected function getIgnoredCIConfigs(): array
{
Deprecation::notice('5.0.0', 'This method will be removed in CMS 5');
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality');
return [];
}

Expand Down
8 changes: 4 additions & 4 deletions src/Core/ClassInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ public static function dataClassesFor($nameOrObject)
}

/**
* @deprecated 4.0.0:5.0.0
* @deprecated 4.0.1 Use DataObject::getSchema()->baseDataClass()
* @param string $class
* @return string
*/
public static function baseDataClass($class)
{
Deprecation::notice('5.0', 'Use DataObject::getSchema()->baseDataClass()');
Deprecation::notice('4.0.1', 'Use DataObject::getSchema()->baseDataClass()');
return DataObject::getSchema()->baseDataClass($class);
}

Expand Down Expand Up @@ -371,11 +371,11 @@ public static function has_method_from($class, $method, $compclass)
}

/**
* @deprecated 4.0.0:5.0.0
* @deprecated 4.0.1 Use DataObject::getSchema()->tableForField()
*/
public static function table_for_object_field($candidateClass, $fieldName)
{
Deprecation::notice('5.0', 'Use DataObject::getSchema()->tableForField()');
Deprecation::notice('4.0.1', 'Use DataObject::getSchema()->tableForField()');
return DataObject::getSchema()->tableForField($candidateClass, $fieldName);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Core/Config/Config_ForClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public function __set($name, $val)
* @param string $name
* @param mixed $value
* @return $this
* @deprecated 4.12.0 Use merge() instead
*/
public function update($name, $value)
{
Deprecation::notice('5.0', 'Use merge() instead');
Deprecation::notice('4.12.0', 'Use merge() instead');
return $this->merge($name, $value);
}

Expand Down
Loading