Skip to content

Commit

Permalink
API Update deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 7, 2022
1 parent c573262 commit 5a505ae
Show file tree
Hide file tree
Showing 48 changed files with 142 additions and 65 deletions.
3 changes: 1 addition & 2 deletions src/Control/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ 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 of setting false
*/
public function disableBasicAuth()
{
Expand Down
2 changes: 2 additions & 0 deletions 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 @@ -204,6 +205,7 @@ private function cookieIsSecure(string $sameSite, bool $secure): bool
*/
private function getSameSite(string $name): string
{
Deprecation::notice('4.12.0', 'The relevant methods will include a `$sameSite` parameter instead.');
if ($name === session_name()) {
return Session::config()->get('cookie_samesite');
}
Expand Down
1 change: 1 addition & 0 deletions src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ public function handleRequest(HTTPRequest $request)
*/
public static function isManifestFlushed()
{
Deprecation::notice('4.12.0', 'Kernel::isFlushed to be used instead');
$kernel = Injector::inst()->get(Kernel::class);

// Only CoreKernel implements this method at the moment
Expand Down
5 changes: 5 additions & 0 deletions src/Control/Email/SwiftMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class SwiftMailer implements Mailer
* @param Email $message
* @return bool Whether the sending was "successful" or not
*/
public function __construct()
{
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
}

public function send($message)
{
$swiftMessage = $message->getSwiftMessage();
Expand Down
5 changes: 5 additions & 0 deletions src/Control/Email/SwiftPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class SwiftPlugin implements \Swift_Events_SendListener
*
* @param \Swift_Events_SendEvent $evt
*/
public function __construct()
{
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
}

public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
/** @var \Swift_Message $message */
Expand Down
16 changes: 9 additions & 7 deletions src/Control/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ 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
* @param int $age
*/
public static function set_cache_age($age)
Expand All @@ -384,7 +384,7 @@ public static function set_cache_age($age)

/**
* @param string $dateString
* @deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
*/
public static function register_modification_date($dateString)
{
Expand All @@ -394,7 +394,7 @@ public static function register_modification_date($dateString)

/**
* @param int $timestamp
* @deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware::registerModificationDate() instead
*/
public static function register_modification_timestamp($timestamp)
{
Expand All @@ -403,7 +403,7 @@ public static function register_modification_timestamp($timestamp)
}

/**
* @deprecated 4.2.0:5.0.0 Use ChangeDetectionMiddleware instead
* @deprecated 4.2.0 Use ChangeDetectionMiddleware instead
* @param string $etag
*/
public static function register_etag($etag)
Expand All @@ -426,7 +426,7 @@ 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.
*/
public static function add_cache_headers($response = null)
{
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 Inline if you need this
* @return string
*/
public static function gmt_date($timestamp)
{
Deprecation::notice('4.2.0', 'Inline if you need this');
return gmdate('D, d M Y H:i:s', $timestamp) . ' GMT';
}

Expand Down
2 changes: 2 additions & 0 deletions 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 @@ -914,6 +915,7 @@ private static function isValidHttpMethod($method)
*/
public static function detect_method($origMethod, $postVars)
{
Deprecation::notice('4.4.7');
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.0 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.12.0', 'Use HTTPMiddleware directly instead.', Deprecation::SCOPE_CLASS);
$this->filters = $filters;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Control/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ 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
* @param array $data
* @param array $dest
*/
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 in 5.0 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 in 5.0 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
2 changes: 2 additions & 0 deletions src/Core/BaseKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ protected function bootErrorHandling()
*/
public function getEnvironment()
{
Deprecation::notice('4.12.0', 'Use Director::get_environment_type() instead. Since 5.0 it should return only if kernel overrides. No checking SESSION or Environment.');
// Check set
if ($this->enviroment) {
return $this->enviroment;
Expand Down Expand Up @@ -292,6 +293,7 @@ public function getEnvironment()
*/
protected function sessionEnvironment()
{
Deprecation::notice('4.12.0', 'Use Director::get_session_environment_type() instead');
if (!$this->booted) {
// session is not initialyzed yet, neither is manifest
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/ClassInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static function dataClassesFor($nameOrObject)
}

/**
* @deprecated 4.0.0:5.0.0
* @deprecated 4.0.0
* @param string $class
* @return string
*/
Expand Down Expand Up @@ -371,7 +371,7 @@ public static function has_method_from($class, $method, $compclass)
}

/**
* @deprecated 4.0.0:5.0.0
* @deprecated 4.0.0
*/
public static function table_for_object_field($candidateClass, $fieldName)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Core/Convert.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static function raw2js($val)
* Encode a value as a JSON encoded string. You can optionally pass a bitmask of
* JSON constants as options through to the encode function.
*
* @deprecated 4.4.0:5.0.0 Use json_encode() instead
* @deprecated 4.4.0 Use json_encode() instead
* @param mixed $val Value to be encoded
* @param int $options Optional bitmask of JSON constants
* @return string JSON encoded string
Expand All @@ -176,7 +176,7 @@ public static function raw2json($val, $options = 0)
/**
* Encode an array as a JSON encoded string.
*
* @deprecated 4.4.0:5.0.0 Use json_encode() instead
* @deprecated 4.4.0 Use json_encode() instead
* @param array $val Array to convert
* @param int $options Optional bitmask of JSON constants
* @return string JSON encoded string
Expand Down Expand Up @@ -261,7 +261,7 @@ public static function xml2raw($val)
/**
* Convert a JSON encoded string into an object.
*
* @deprecated 4.4.0:5.0.0 Use json_decode() instead
* @deprecated 4.4.0 Use json_decode() instead
* @param string $val
* @return object|boolean
*/
Expand All @@ -275,7 +275,7 @@ public static function json2obj($val)
/**
* Convert a JSON string into an array.
*
* @deprecated 4.4.0:5.0.0 Use json_decode() instead
* @deprecated 4.4.0 Use json_decode() instead
* @param string $val JSON string to convert
* @return array|boolean
*/
Expand All @@ -295,7 +295,7 @@ public static function json2array($val)
* @param boolean $disableDoctypes Disables the use of DOCTYPE, and will trigger an error if encountered.
* false by default.
* @param boolean $disableExternals Does nothing because xml entities are removed
* @deprecated 4.11.0:5.0.0
* @deprecated 4.11.0
* @return array
* @throws Exception
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Injector/Injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ protected function setObjectProperty($object, $name, $value)
}

/**
* @deprecated 4.0.0:5.0.0 Use Injector::has() instead
* @deprecated 4.0.0 Use Injector::has() instead
* @param $name
* @return string
*/
Expand Down
10 changes: 6 additions & 4 deletions src/Core/Manifest/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public function __unserialize(array $data): void
*/
public function serialize()
{
Deprecation::notice('4.12.0', 'Will be removed in 5.0');
return json_encode([$this->path, $this->basePath, $this->composerData]);
}

Expand All @@ -223,6 +224,7 @@ public function serialize()
*/
public function unserialize($serialized)
{
Deprecation::notice('4.12.0', 'Will be removed in 5.0');
list($this->path, $this->basePath, $this->composerData) = json_decode($serialized ?? '', true);
$this->resources = [];
}
Expand Down Expand Up @@ -275,7 +277,7 @@ public function getResource($path)
}

/**
* @deprecated 4.0.0:5.0.0 Use getResource($path)->getRelativePath() instead
* @deprecated 4.0.0 Use getResource($path)->getRelativePath() instead
* @param string $path
* @return string
*/
Expand All @@ -288,7 +290,7 @@ public function getRelativeResourcePath($path)
}

/**
* @deprecated 4.0.0:5.0.0 Use ->getResource($path)->getPath() instead
* @deprecated 4.0.0 Use ->getResource($path)->getPath() instead
* @param string $path
* @return string
*/
Expand All @@ -301,7 +303,7 @@ public function getResourcePath($path)
}

/**
* @deprecated 4.0.0:5.0.0 Use ->getResource($path)->getURL() instead
* @deprecated 4.0.0 Use ->getResource($path)->getURL() instead
* @param string $path
* @return string
*/
Expand All @@ -314,7 +316,7 @@ public function getResourceURL($path)
}

/**
* @deprecated 4.0.0:5.0.0 Use ->getResource($path)->exists() instead
* @deprecated 4.0.0 Use ->getResource($path)->exists() instead
* @param string $path
* @return string
*/
Expand Down
5 changes: 5 additions & 0 deletions src/Core/Startup/AbstractConfirmationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ abstract class AbstractConfirmationToken
* @param HTTPRequest $request
* @return static The token container for the unvalidated $key given with the highest priority
*/
public function __construct()
{
Deprecation::notice('4.12.0', 'To be removed in SilverStripe 5.0', Deprecation::SCOPE_CLASS);
}

public static function prepare_tokens($keys, HTTPRequest $request)
{
$target = null;
Expand Down
5 changes: 5 additions & 0 deletions src/Core/Startup/ConfirmationTokenChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class ConfirmationTokenChain
/**
* @param AbstractConfirmationToken $token
*/
public function __construct()
{
Deprecation::notice('4.12.0', 'To be removed in SilverStripe 5.0', Deprecation::SCOPE_CLASS);
}

public function pushToken(AbstractConfirmationToken $token)
{
$this->tokens[] = $token;
Expand Down
5 changes: 5 additions & 0 deletions src/Core/Startup/ErrorControlChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class ErrorControlChain
*
* @return bool
*/
public function __construct()
{
Deprecation::notice('4.12.0', 'To be removed in SilverStripe 5.0', Deprecation::SCOPE_CLASS);
}

public function hasErrored()
{
return $this->error;
Expand Down
5 changes: 5 additions & 0 deletions src/Core/Startup/ErrorDirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class ErrorDirector extends Director
* @param Kernel $kernel
* @return null|HTTPResponse Redirection response, or null if not able to redirect
*/
public function __construct()
{
Deprecation::notice('4.12.0', 'To be removed in SilverStripe 5.0', Deprecation::SCOPE_CLASS);
}

public function handleRequestWithTokenChain(
HTTPRequest $request,
ConfirmationTokenChain $confirmationTokenChain,
Expand Down
1 change: 1 addition & 0 deletions src/Core/Startup/ParameterConfirmationToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ParameterConfirmationToken extends AbstractConfirmationToken
*/
public function __construct($parameterName, HTTPRequest $request)
{
Deprecation::notice('4.12.0', 'To be removed in SilverStripe 5.0', Deprecation::SCOPE_CLASS);
// Store the parameter name
$this->parameterName = $parameterName;
$this->request = $request;
Expand Down
Loading

0 comments on commit 5a505ae

Please sign in to comment.