mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4' into 5
This commit is contained in:
commit
6e9d3ab632
@ -528,15 +528,11 @@ class Controller extends RequestHandler implements TemplateGlobalProvider
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Control;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use LogicException;
|
||||
|
||||
@ -200,10 +201,11 @@ class CookieJar implements Cookie_Backend
|
||||
/**
|
||||
* 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.');
|
||||
if ($name === session_name()) {
|
||||
return Session::config()->get('cookie_samesite');
|
||||
}
|
||||
|
@ -386,10 +386,11 @@ class Director implements TemplateGlobalProvider
|
||||
*
|
||||
* @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
|
||||
|
@ -372,43 +372,43 @@ class HTTP
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
* @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}\"";
|
||||
}
|
||||
@ -426,11 +426,11 @@ class HTTP
|
||||
* 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)
|
||||
{
|
||||
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')) {
|
||||
@ -473,13 +473,14 @@ class HTTP
|
||||
/**
|
||||
* 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')) {
|
||||
@ -560,11 +561,12 @@ class HTTP
|
||||
* 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';
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Control;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use ArrayAccess;
|
||||
use BadMethodCallException;
|
||||
use InvalidArgumentException;
|
||||
@ -910,10 +911,11 @@ class HTTPRequest implements ArrayAccess
|
||||
* @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');
|
||||
|
@ -9,7 +9,7 @@ use SilverStripe\Dev\Deprecation;
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
@ -29,6 +29,7 @@ class RequestProcessor implements HTTPMiddleware
|
||||
*/
|
||||
public function __construct($filters = [])
|
||||
{
|
||||
Deprecation::notice('4.0.1', 'Use HTTPMiddleware directly instead.', Deprecation::SCOPE_CLASS);
|
||||
$this->filters = $filters;
|
||||
}
|
||||
|
||||
|
@ -586,13 +586,13 @@ class Session
|
||||
* 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
|
||||
*/
|
||||
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])) {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Control;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
@ -159,12 +160,13 @@ class SimpleResourceURLGenerator implements ResourceURLGenerator
|
||||
/**
|
||||
* 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) {
|
||||
|
@ -248,10 +248,11 @@ abstract class BaseKernel implements Kernel
|
||||
*
|
||||
* @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;
|
||||
|
@ -156,13 +156,13 @@ class ClassInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -371,11 +371,11 @@ class ClassInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -43,10 +43,11 @@ class Config_ForClass
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -161,14 +161,14 @@ class Convert
|
||||
* 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
|
||||
*/
|
||||
public static function raw2json($val, $options = 0)
|
||||
{
|
||||
Deprecation::notice('4.4', 'Please use json_encode() instead.');
|
||||
Deprecation::notice('4.4.0', 'Use json_encode() instead');
|
||||
|
||||
return json_encode($val, $options ?? 0);
|
||||
}
|
||||
@ -176,14 +176,14 @@ class Convert
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static function array2json($val, $options = 0)
|
||||
{
|
||||
Deprecation::notice('4.4', 'Please use json_encode() instead.');
|
||||
Deprecation::notice('4.4.0', 'Use json_encode() instead');
|
||||
|
||||
return json_encode($val, $options ?? 0);
|
||||
}
|
||||
@ -261,13 +261,13 @@ class Convert
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static function json2obj($val)
|
||||
{
|
||||
Deprecation::notice('4.4', 'Please use json_decode() instead.');
|
||||
Deprecation::notice('4.4.0', 'Use json_decode() instead');
|
||||
|
||||
return json_decode($val ?? '');
|
||||
}
|
||||
@ -275,13 +275,13 @@ class Convert
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static function json2array($val)
|
||||
{
|
||||
Deprecation::notice('4.4', 'Please use json_decode() instead.');
|
||||
Deprecation::notice('4.4.0', 'Use json_decode() instead');
|
||||
|
||||
return json_decode($val ?? '', true);
|
||||
}
|
||||
@ -295,13 +295,13 @@ class Convert
|
||||
* @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 Use a dedicated XML library instead
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function xml2array($val, $disableDoctypes = false, $disableExternals = false)
|
||||
{
|
||||
Deprecation::notice('4.10', 'Use a dedicated XML library instead');
|
||||
Deprecation::notice('4.11.0', 'Use a dedicated XML library instead');
|
||||
|
||||
// Check doctype
|
||||
if ($disableDoctypes && strpos($val ?? '', '<!DOCTYPE') !== false) {
|
||||
|
@ -2,18 +2,36 @@
|
||||
|
||||
namespace SilverStripe\Core\Injector;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A class for creating new objects by the injector.
|
||||
*/
|
||||
class InjectionCreator implements Factory
|
||||
{
|
||||
/**
|
||||
* Create a new instance of a class
|
||||
*
|
||||
* Passing an object for $class will result from using an anonymous class in unit testing, e.g.
|
||||
* Injector::inst()->load([SomeClass::class => ['class' => new class { ... }]]);
|
||||
*
|
||||
* @param string|object $class - string: The FQCN of the class, object: A class instance
|
||||
*/
|
||||
public function create($class, array $params = [])
|
||||
{
|
||||
if (!class_exists($class ?? '')) {
|
||||
if (is_object($class ?? '')) {
|
||||
$class = get_class($class);
|
||||
}
|
||||
if (!is_string($class ?? '')) {
|
||||
throw new InvalidArgumentException('$class parameter must be a string or an object');
|
||||
}
|
||||
if (!class_exists($class)) {
|
||||
throw new InjectorNotFoundException("Class {$class} does not exist");
|
||||
}
|
||||
|
||||
// Ensure there are no string keys as they cannot be unpacked with the `...` operator
|
||||
$values = array_values($params ?? []);
|
||||
$values = array_values($params);
|
||||
|
||||
return new $class(...$values);
|
||||
}
|
||||
}
|
||||
|
@ -854,13 +854,13 @@ class Injector implements ContainerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use Injector::has() instead
|
||||
* @deprecated 4.0.1 Use Injector::has() instead
|
||||
* @param $name
|
||||
* @return string
|
||||
*/
|
||||
public function hasService($name)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use Injector::has() instead');
|
||||
Deprecation::notice('4.0.1', 'Use Injector::has() instead');
|
||||
|
||||
return $this->has($name);
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ use BadMethodCallException;
|
||||
*/
|
||||
class InjectorLoader
|
||||
{
|
||||
public const NO_MANIFESTS_AVAILABLE = 'No injector manifests available';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @var self
|
||||
@ -42,7 +44,7 @@ class InjectorLoader
|
||||
);
|
||||
}
|
||||
if (empty($this->manifests)) {
|
||||
throw new BadMethodCallException("No injector manifests available");
|
||||
throw new BadMethodCallException(self::NO_MANIFESTS_AVAILABLE);
|
||||
}
|
||||
return $this->manifests[count($this->manifests) - 1];
|
||||
}
|
||||
|
@ -137,10 +137,11 @@ class ClassLoader
|
||||
*
|
||||
* @param string $class
|
||||
* @return bool
|
||||
* @deprecated 4.0.1 Use ClassInfo::exists() instead
|
||||
*/
|
||||
public function classExists($class)
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use ClassInfo::exists.');
|
||||
Deprecation::notice('4.0.1', 'Use ClassInfo::exists() instead');
|
||||
return ClassInfo::exists($class);
|
||||
}
|
||||
}
|
||||
|
@ -187,10 +187,11 @@ class Module implements Serializable
|
||||
* The __serialize() magic method will be automatically used instead of this
|
||||
*
|
||||
* @return string
|
||||
* @deprecated will be removed in 5.0
|
||||
* @deprecated 4.12.0 Use __serialize() instead
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Use __serialize() instead');
|
||||
return json_encode([$this->path, $this->basePath, $this->composerData]);
|
||||
}
|
||||
|
||||
@ -200,10 +201,11 @@ class Module implements Serializable
|
||||
* and the PHP version used in less than PHP 9.0
|
||||
*
|
||||
* @param string $serialized
|
||||
* @deprecated will be removed in 5.0
|
||||
* @deprecated 4.12.0 Use __unserialize() instead
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Use __unserialize() instead');
|
||||
list($this->path, $this->basePath, $this->composerData) = json_decode($serialized ?? '', true);
|
||||
$this->resources = [];
|
||||
}
|
||||
@ -256,52 +258,52 @@ class Module implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use getResource($path)->getRelativePath() instead
|
||||
* @deprecated 4.0.1 Use getResource($path)->getRelativePath() instead
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getRelativeResourcePath($path)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use getResource($path)->getRelativePath() instead');
|
||||
Deprecation::notice('4.0.1', 'Use getResource($path)->getRelativePath() instead');
|
||||
return $this
|
||||
->getResource($path)
|
||||
->getRelativePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use ->getResource($path)->getPath() instead
|
||||
* @deprecated 4.0.1 Use getResource($path)->getPath() instead
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getResourcePath($path)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use getResource($path)->getPath() instead');
|
||||
Deprecation::notice('4.0.1', 'Use getResource($path)->getPath() instead');
|
||||
return $this
|
||||
->getResource($path)
|
||||
->getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use ->getResource($path)->getURL() instead
|
||||
* @deprecated 4.0.1 Use getResource($path)->getURL() instead
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceURL($path)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use getResource($path)->getURL() instead');
|
||||
Deprecation::notice('4.0.1', 'Use getResource($path)->getURL() instead');
|
||||
return $this
|
||||
->getResource($path)
|
||||
->getURL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use ->getResource($path)->exists() instead
|
||||
* @deprecated 4.0.1 Use getResource($path)->exists() instead
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function hasResource($path)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use getResource($path)->exists() instead');
|
||||
Deprecation::notice('4.0.1', 'Use getResource($path)->exists() instead');
|
||||
return $this
|
||||
->getResource($path)
|
||||
->exists();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Core\Startup;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
@ -15,7 +16,7 @@ use SilverStripe\Security\RandomGenerator;
|
||||
*
|
||||
* @internal This class is designed specifically for use pre-startup and may change without warning
|
||||
*
|
||||
* @deprecated 5.0 To be removed in SilverStripe 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
abstract class AbstractConfirmationToken
|
||||
{
|
||||
@ -39,6 +40,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', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
}
|
||||
|
||||
public static function prepare_tokens($keys, HTTPRequest $request)
|
||||
{
|
||||
$target = null;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Core\Startup;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
@ -13,7 +14,7 @@ use SilverStripe\Core\Convert;
|
||||
*
|
||||
* @internal This class is designed specifically for use pre-startup and may change without warning
|
||||
*
|
||||
* @deprecated 5.0 To be removed in SilverStripe 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
class ConfirmationTokenChain
|
||||
{
|
||||
@ -25,6 +26,11 @@ class ConfirmationTokenChain
|
||||
/**
|
||||
* @param AbstractConfirmationToken $token
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
}
|
||||
|
||||
public function pushToken(AbstractConfirmationToken $token)
|
||||
{
|
||||
$this->tokens[] = $token;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Core\Startup;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@ -17,7 +18,7 @@ use Exception;
|
||||
*
|
||||
* @internal This class is designed specifically for use pre-startup and may change without warning
|
||||
*
|
||||
* @deprecated 5.0 To be removed in SilverStripe 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
class ErrorControlChain
|
||||
{
|
||||
@ -62,6 +63,11 @@ class ErrorControlChain
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
}
|
||||
|
||||
public function hasErrored()
|
||||
{
|
||||
return $this->error;
|
||||
|
@ -16,7 +16,7 @@ use SilverStripe\Security\Security;
|
||||
*
|
||||
* @internal This class is designed specifically for use pre-startup and may change without warning
|
||||
*
|
||||
* @deprecated 5.0 To be removed in SilverStripe 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
class ErrorControlChainMiddleware implements HTTPMiddleware
|
||||
{
|
||||
@ -40,9 +40,9 @@ class ErrorControlChainMiddleware implements HTTPMiddleware
|
||||
*/
|
||||
public function __construct(Application $application, $legacy = false)
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
$this->application = $application;
|
||||
$this->legacy = $legacy;
|
||||
Deprecation::notice('5.0', 'ErrorControlChainMiddleware is deprecated and will be removed completely');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Core\Startup;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
@ -15,7 +16,7 @@ use SilverStripe\Security\Security;
|
||||
*
|
||||
* @internal This class is experimental API and may change without warning
|
||||
*
|
||||
* @deprecated 5.0 To be removed in SilverStripe 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
class ErrorDirector extends Director
|
||||
{
|
||||
@ -27,6 +28,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', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
}
|
||||
|
||||
public function handleRequestWithTokenChain(
|
||||
HTTPRequest $request,
|
||||
ConfirmationTokenChain $confirmationTokenChain,
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Core\Startup;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
@ -16,7 +17,7 @@ use SilverStripe\Security\RandomGenerator;
|
||||
*
|
||||
* @internal This class is designed specifically for use pre-startup and may change without warning
|
||||
*
|
||||
* @deprecated 5.0 To be removed in SilverStripe 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
class ParameterConfirmationToken extends AbstractConfirmationToken
|
||||
{
|
||||
@ -47,6 +48,7 @@ class ParameterConfirmationToken extends AbstractConfirmationToken
|
||||
*/
|
||||
public function __construct($parameterName, HTTPRequest $request)
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
// Store the parameter name
|
||||
$this->parameterName = $parameterName;
|
||||
$this->request = $request;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Core\Startup;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
@ -12,7 +13,7 @@ use SilverStripe\Control\HTTPRequest;
|
||||
*
|
||||
* @internal This class is designed specifically for use pre-startup and may change without warning
|
||||
*
|
||||
* @deprecated 5.0 To be removed in SilverStripe 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
class URLConfirmationToken extends AbstractConfirmationToken
|
||||
{
|
||||
@ -42,6 +43,7 @@ class URLConfirmationToken extends AbstractConfirmationToken
|
||||
*/
|
||||
public function __construct($urlToCheck, HTTPRequest $request)
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
$this->urlToCheck = $urlToCheck;
|
||||
$this->request = $request;
|
||||
$this->currentURL = $request->getURL(false);
|
||||
|
@ -166,10 +166,11 @@ class CsvBulkLoader extends BulkLoader
|
||||
* @param int $lines Number of lines per file
|
||||
*
|
||||
* @return array List of file paths
|
||||
* @deprecated 4.12.0 Process files using a stream instead
|
||||
*/
|
||||
protected function splitFile($path, $lines = null)
|
||||
{
|
||||
Deprecation::notice('5.0', 'splitFile is deprecated, please process files using a stream');
|
||||
Deprecation::notice('4.12.0', 'Process files using a stream instead');
|
||||
|
||||
if (!is_int($lines)) {
|
||||
$lines = $this->config()->get("lines");
|
||||
@ -222,10 +223,11 @@ class CsvBulkLoader extends BulkLoader
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @deprecated 4.12.0 Name files yourself instead
|
||||
*/
|
||||
protected function getNewSplitFileName()
|
||||
{
|
||||
Deprecation::notice('5.0', 'getNewSplitFileName is deprecated, please name your files yourself');
|
||||
Deprecation::notice('4.12.0', 'Name files yourself instead');
|
||||
return TEMP_PATH . DIRECTORY_SEPARATOR . uniqid(str_replace('\\', '_', static::class) ?? '', true) . '.csv';
|
||||
}
|
||||
|
||||
@ -234,10 +236,11 @@ class CsvBulkLoader extends BulkLoader
|
||||
* @param boolean $preview
|
||||
*
|
||||
* @return BulkLoader_Result
|
||||
* @deprecated 4.12.0 Process rows individually instead
|
||||
*/
|
||||
protected function processChunk($filepath, $preview = false)
|
||||
{
|
||||
Deprecation::notice('5.0', 'processChunk is deprecated, please process rows individually');
|
||||
Deprecation::notice('4.12.0', 'Process rows individually instead');
|
||||
$results = BulkLoader_Result::create();
|
||||
|
||||
$csv = new CSVParser(
|
||||
|
@ -143,65 +143,65 @@ class DebugView
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use renderHeader() instead
|
||||
* @deprecated 4.0.1 Use renderHeader() instead
|
||||
*/
|
||||
public function writeHeader()
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use renderHeader() instead');
|
||||
Deprecation::notice('4.0.1', 'Use renderHeader() instead');
|
||||
echo $this->renderHeader();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use renderInfo() instead
|
||||
* @deprecated 4.0.1 Use renderInfo() instead
|
||||
*/
|
||||
public function writeInfo($title, $subtitle, $description = false)
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use renderInfo() instead');
|
||||
Deprecation::notice('4.0.1', 'Use renderInfo() instead');
|
||||
echo $this->renderInfo($title, $subtitle, $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use renderFooter() instead
|
||||
* @deprecated 4.0.1 Use renderFooter() instead
|
||||
*/
|
||||
public function writeFooter()
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use renderFooter() instead');
|
||||
Deprecation::notice('4.0.1', 'Use renderFooter() instead');
|
||||
echo $this->renderFooter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use renderError() instead
|
||||
* @deprecated 4.0.1 Use renderError() instead
|
||||
*/
|
||||
public function writeError($httpRequest, $errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use renderError() instead');
|
||||
Deprecation::notice('4.0.1', 'Use renderError() instead');
|
||||
echo $this->renderError($httpRequest, $errno, $errstr, $errfile, $errline);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use renderSourceFragment() instead
|
||||
* @deprecated 4.0.1 Use renderSourceFragment() instead
|
||||
*/
|
||||
public function writeSourceFragment($lines, $errline)
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use renderSourceFragment() instead');
|
||||
Deprecation::notice('4.0.1', 'Use renderSourceFragment() instead');
|
||||
echo $this->renderSourceFragment($lines, $errline);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use renderTrace() instead
|
||||
* @deprecated 4.0.1 Use renderTrace() instead
|
||||
*/
|
||||
public function writeTrace($trace)
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use renderTrace() instead');
|
||||
Deprecation::notice('4.0.1', 'Use renderTrace() instead');
|
||||
echo $this->renderTrace($trace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use renderVariable() instead
|
||||
* @deprecated 4.0.1 Use renderVariable() instead
|
||||
*/
|
||||
public function writeVariable($val, $caller)
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use renderVariable() instead');
|
||||
Deprecation::notice('4.0.1', 'Use renderVariable() instead');
|
||||
echo $this->renderVariable($val, $caller);
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Exception;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Environment;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\Core\Injector\InjectorLoader;
|
||||
use SilverStripe\Core\Manifest\Module;
|
||||
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||
|
||||
/**
|
||||
* Handles raising an notice when accessing a deprecated method
|
||||
@ -37,14 +38,13 @@ use SilverStripe\Core\Manifest\ModuleLoader;
|
||||
*/
|
||||
class Deprecation
|
||||
{
|
||||
|
||||
const SCOPE_METHOD = 1;
|
||||
const SCOPE_CLASS = 2;
|
||||
const SCOPE_GLOBAL = 4;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||
*/
|
||||
protected static $version;
|
||||
|
||||
@ -58,24 +58,47 @@ class Deprecation
|
||||
* must be available before this to avoid infinite loops.
|
||||
*
|
||||
* @var boolean|null
|
||||
* @deprecated 4.12.0 Use $is_enabled instead
|
||||
*/
|
||||
protected static $enabled = null;
|
||||
|
||||
/**
|
||||
* Must be configured outside of the config API, as deprecation API
|
||||
* must be available before this to avoid infinite loops.
|
||||
*
|
||||
* This will be overriden by the SS_DEPRECATION_ENABLED environment if present
|
||||
*/
|
||||
protected static bool $is_enabled = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||
*/
|
||||
protected static $module_version_overrides = [];
|
||||
|
||||
/**
|
||||
* @var int - the notice level to raise on a deprecation notice. Defaults to E_USER_DEPRECATED if that exists,
|
||||
* E_USER_NOTICE if not
|
||||
*/
|
||||
public static $notice_level = null;
|
||||
protected static bool $inside_notice = false;
|
||||
|
||||
/**
|
||||
* Set the version that is used to check against the version passed to notice. If the ::notice version is
|
||||
* greater than or equal to this version, a message will be raised
|
||||
* Switched out by unit-testing to E_USER_NOTICE because E_USER_DEPRECATED is not
|
||||
* caught by $this->expectDeprecated() by default
|
||||
* https://github.com/laminas/laminas-di/pull/30#issuecomment-927585210
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public static $notice_level = E_USER_DEPRECATED;
|
||||
|
||||
public static function enable(): void
|
||||
{
|
||||
static::$is_enabled = true;
|
||||
}
|
||||
|
||||
public static function disable(): void
|
||||
{
|
||||
static::$is_enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is no longer used
|
||||
*
|
||||
* @static
|
||||
* @param $ver string -
|
||||
@ -84,32 +107,25 @@ class Deprecation
|
||||
* The name of a module. The passed version will be used as the check value for
|
||||
* calls directly from this module rather than the global value
|
||||
* @return void
|
||||
* @deprecated 4.12.0 Use enable() instead
|
||||
*/
|
||||
public static function notification_version($ver, $forModule = null)
|
||||
{
|
||||
if ($forModule) {
|
||||
self::$module_version_overrides[$forModule] = $ver;
|
||||
} else {
|
||||
self::$version = $ver;
|
||||
}
|
||||
static::notice('4.12.0', 'Use enable() instead');
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a backtrace, get the module name from the caller two removed (the caller of the method that called
|
||||
* #notice)
|
||||
* This method is no longer used
|
||||
*
|
||||
* @param array $backtrace A backtrace as returned from debug_backtrace
|
||||
* @return Module The module being called
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||
*/
|
||||
protected static function get_calling_module_from_trace($backtrace)
|
||||
{
|
||||
if (!isset($backtrace[1]['file'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$callingfile = realpath($backtrace[1]['file'] ?? '');
|
||||
|
||||
return ModuleLoader::inst()->getManifest()->getModuleByPath($callingfile);
|
||||
static::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,30 +151,38 @@ class Deprecation
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if deprecation notices should be displayed
|
||||
* This method is no longer used
|
||||
*
|
||||
* @return bool
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||
*/
|
||||
public static function get_enabled()
|
||||
{
|
||||
// Deprecation is only available on dev
|
||||
static::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||
// noop
|
||||
}
|
||||
|
||||
private static function get_is_enabled(): bool
|
||||
{
|
||||
if (!Director::isDev()) {
|
||||
return false;
|
||||
}
|
||||
if (isset(self::$enabled)) {
|
||||
return self::$enabled;
|
||||
if (Environment::getEnv('SS_DEPRECATION_ENABLED')) {
|
||||
return true;
|
||||
}
|
||||
return Environment::getEnv('SS_DEPRECATION_ENABLED') ?: true;
|
||||
return static::$is_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle on or off deprecation notices. Will be ignored in live.
|
||||
* This method is no longer used
|
||||
*
|
||||
* @param bool $enabled
|
||||
* @deprecated 4.12.0 Use enable() instead
|
||||
*/
|
||||
public static function set_enabled($enabled)
|
||||
{
|
||||
self::$enabled = $enabled;
|
||||
static::notice('4.12.0', 'Use enable() instead');
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
@ -171,100 +195,82 @@ class Deprecation
|
||||
*/
|
||||
public static function notice($atVersion, $string = '', $scope = Deprecation::SCOPE_METHOD)
|
||||
{
|
||||
if (!static::get_enabled()) {
|
||||
if (static::$inside_notice) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkVersion = self::$version;
|
||||
// Getting a backtrace is slow, so we only do it if we need it
|
||||
$backtrace = null;
|
||||
|
||||
// If you pass #.#, assume #.#.0
|
||||
if (preg_match('/^[0-9]+\.[0-9]+$/', $atVersion ?? '')) {
|
||||
$atVersion .= '.0';
|
||||
}
|
||||
if (preg_match('/^[0-9]+\.[0-9]+$/', $checkVersion ?? '')) {
|
||||
$checkVersion .= '.0';
|
||||
}
|
||||
|
||||
if (self::$module_version_overrides) {
|
||||
$module = self::get_calling_module_from_trace($backtrace = debug_backtrace(0));
|
||||
if ($module) {
|
||||
if (($name = $module->getComposerName())
|
||||
&& isset(self::$module_version_overrides[$name])
|
||||
) {
|
||||
$checkVersion = self::$module_version_overrides[$name];
|
||||
} elseif (($name = $module->getShortName())
|
||||
&& isset(self::$module_version_overrides[$name])
|
||||
) {
|
||||
$checkVersion = self::$module_version_overrides[$name];
|
||||
}
|
||||
static::$inside_notice = true;
|
||||
// try block needs to wrap all code in case anything inside the try block
|
||||
// calls something else that calls Deprecation::notice()
|
||||
try {
|
||||
if (!self::get_is_enabled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the version against the notice version
|
||||
if ($checkVersion && version_compare($checkVersion ?? '', $atVersion ?? '', '>=')) {
|
||||
// If you pass #.#, assume #.#.0
|
||||
if (preg_match('/^[0-9]+\.[0-9]+$/', $atVersion ?? '')) {
|
||||
$atVersion .= '.0';
|
||||
}
|
||||
|
||||
// Getting a backtrace is slow, so we only do it if we need it
|
||||
$backtrace = null;
|
||||
|
||||
// Get the calling scope
|
||||
if ($scope == Deprecation::SCOPE_METHOD) {
|
||||
if (!$backtrace) {
|
||||
$backtrace = debug_backtrace(0);
|
||||
}
|
||||
$backtrace = debug_backtrace(0);
|
||||
$caller = self::get_called_method_from_trace($backtrace);
|
||||
} elseif ($scope == Deprecation::SCOPE_CLASS) {
|
||||
if (!$backtrace) {
|
||||
$backtrace = debug_backtrace(0);
|
||||
}
|
||||
$backtrace = debug_backtrace(0);
|
||||
$caller = isset($backtrace[1]['class']) ? $backtrace[1]['class'] : '(unknown)';
|
||||
} else {
|
||||
$caller = false;
|
||||
}
|
||||
|
||||
// Get the level to raise the notice as
|
||||
$level = self::$notice_level;
|
||||
if (!$level) {
|
||||
$level = E_USER_DEPRECATED;
|
||||
}
|
||||
|
||||
// Then raise the notice
|
||||
if (substr($string ?? '', -1) != '.') {
|
||||
if (substr($string, -1) != '.') {
|
||||
$string .= ".";
|
||||
}
|
||||
|
||||
$string .= " Called from " . self::get_called_method_from_trace($backtrace, 2) . '.';
|
||||
|
||||
if ($caller) {
|
||||
user_error($caller . ' is deprecated.' . ($string ? ' ' . $string : ''), $level ?? 0);
|
||||
user_error($caller . ' is deprecated.' . ($string ? ' ' . $string : ''), self::$notice_level);
|
||||
} else {
|
||||
user_error($string ?? '', $level ?? 0);
|
||||
user_error($string, self::$notice_level);
|
||||
}
|
||||
} catch (BadMethodCallException $e) {
|
||||
if ($e->getMessage() === InjectorLoader::NO_MANIFESTS_AVAILABLE) {
|
||||
// noop
|
||||
// this can happen when calling Deprecation::notice() before manifests are available, i.e.
|
||||
// some of the code involved in creating the manifests calls Deprecation::notice()
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
} finally {
|
||||
static::$inside_notice = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for when testing. Dump all the current version settings to a variable for later passing to restore
|
||||
* This method is no longer used
|
||||
*
|
||||
* @return array Opaque array that should only be used to pass to {@see Deprecation::restore_settings()}
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||
*/
|
||||
public static function dump_settings()
|
||||
{
|
||||
return [
|
||||
'level' => self::$notice_level,
|
||||
'version' => self::$version,
|
||||
'moduleVersions' => self::$module_version_overrides,
|
||||
'enabled' => self::$enabled,
|
||||
];
|
||||
static::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for when testing. Restore all the current version settings from a variable
|
||||
* This method is no longer used
|
||||
*
|
||||
* @param $settings array An array as returned by {@see Deprecation::dump_settings()}
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||
*/
|
||||
public static function restore_settings($settings)
|
||||
{
|
||||
self::$notice_level = $settings['level'];
|
||||
self::$version = $settings['version'];
|
||||
self::$module_version_overrides = $settings['moduleVersions'];
|
||||
self::$enabled = $settings['enabled'];
|
||||
static::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ abstract class FunctionalTest extends SapphireTest implements TestOnly
|
||||
/**
|
||||
* Set this to true on your sub-class to use the draft site by default for every test in this class.
|
||||
*
|
||||
* @deprecated 4.2.0:5.0.0 Use ?stage=Stage in your ->get() querystring requests instead
|
||||
* @deprecated 4.2.0 Use ?stage=Stage in your request's querystring instead
|
||||
* @var bool
|
||||
*/
|
||||
protected static $use_draft_site = false;
|
||||
@ -404,12 +404,12 @@ abstract class FunctionalTest extends SapphireTest implements TestOnly
|
||||
* This is helpful if you're not testing publication functionality and don't want "stage management" cluttering
|
||||
* your test.
|
||||
*
|
||||
* @deprecated 4.2.0:5.0.0 Use ?stage=Stage querystring arguments instead of useDraftSite
|
||||
* @deprecated 4.2.0 Use ?stage=Stage in your request's querystring instead
|
||||
* @param bool $enabled toggle the use of the draft site
|
||||
*/
|
||||
public function useDraftSite($enabled = true)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use ?stage=Stage querystring arguments instead of useDraftSite');
|
||||
Deprecation::notice('4.2.0', 'Use ?stage=Stage in your request\'s querystring instead');
|
||||
if ($enabled) {
|
||||
$this->session()->set('readingMode', 'Stage.Stage');
|
||||
$this->session()->set('unsecuredDraftSite', true);
|
||||
@ -428,11 +428,12 @@ abstract class FunctionalTest extends SapphireTest implements TestOnly
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.2.0:5.0.0 Use ?stage=Stage in your querystring arguments instead
|
||||
* @deprecated 4.2.0 Use ?stage=Stage in your request's querystring instead
|
||||
* @return bool
|
||||
*/
|
||||
public static function get_use_draft_site()
|
||||
{
|
||||
Deprecation::notice('4.2.0', 'Use ?stage=Stage in your request\'s querystring instead');
|
||||
return static::$use_draft_site;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\Controller;
|
||||
|
||||
/**
|
||||
* Simple controller that the installer uses to test that URL rewriting is working.
|
||||
* @deprecated 4.4.7 This class will be removed in Silverstripe Framework 5.
|
||||
* @deprecated 4.4.7 Will be removed without equivalent functionality
|
||||
*/
|
||||
class InstallerTest extends Controller
|
||||
{
|
||||
@ -15,6 +16,11 @@ class InstallerTest extends Controller
|
||||
'testrewrite'
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
Deprecation::notice('4.4.7', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
}
|
||||
|
||||
public function testrewrite()
|
||||
{
|
||||
echo "OK";
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Security\Permission;
|
||||
@ -9,7 +10,7 @@ use SilverStripe\Security\Security;
|
||||
|
||||
/**
|
||||
* Returns information about the current site instance.
|
||||
* @deprecated 4.4.7 This class will be removed in Silverstripe Framework 5.
|
||||
* @deprecated 4.4.7 Will be removed without equivalent functionality
|
||||
*/
|
||||
class SapphireInfo extends Controller
|
||||
{
|
||||
@ -19,6 +20,11 @@ class SapphireInfo extends Controller
|
||||
'environmenttype',
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
Deprecation::notice('4.4.7', 'Will be removed without equivalent functionality', Deprecation::SCOPE_CLASS);
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
@ -64,7 +64,7 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
protected static $fixture_file = null;
|
||||
|
||||
/**
|
||||
* @deprecated 4.0..5.0 Use FixtureTestState instead
|
||||
* @deprecated 4.0.1 Use FixtureTestState instead
|
||||
* @var FixtureFactory
|
||||
*/
|
||||
protected $fixtureFactory;
|
||||
@ -430,11 +430,11 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
|
||||
/**
|
||||
* @return FixtureFactory|false
|
||||
* @deprecated 4.0.0:5.0.0
|
||||
* @deprecated 4.0.1 Use FixtureTestState instead
|
||||
*/
|
||||
public function getFixtureFactory()
|
||||
{
|
||||
Deprecation::notice('5.0', __FUNCTION__ . ' is deprecated, use ' . FixtureTestState::class . ' instead');
|
||||
Deprecation::notice('4.0.1', 'Use FixtureTestState instead');
|
||||
/** @var FixtureTestState $state */
|
||||
$state = static::$state->getStateByName('fixtures');
|
||||
return $state->getFixtureFactory(static::class);
|
||||
@ -444,11 +444,11 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
* Sets a new fixture factory
|
||||
* @param FixtureFactory $factory
|
||||
* @return $this
|
||||
* @deprecated 4.0.0:5.0.0
|
||||
* @deprecated 4.0.1 Use FixtureTestState instead
|
||||
*/
|
||||
public function setFixtureFactory(FixtureFactory $factory)
|
||||
{
|
||||
Deprecation::notice('5.0', __FUNCTION__ . ' is deprecated, use ' . FixtureTestState::class . ' instead');
|
||||
Deprecation::notice('4.0.1', 'Use FixtureTestState instead');
|
||||
/** @var FixtureTestState $state */
|
||||
$state = static::$state->getStateByName('fixtures');
|
||||
$state->setFixtureFactory($factory, static::class);
|
||||
@ -524,12 +524,12 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
* Once loaded, you can use idFromFixture() and objFromFixture() to get items from the fixture.
|
||||
* Doesn't clear existing fixtures.
|
||||
* @param string $fixtureFile The location of the .yml fixture file, relative to the site base dir
|
||||
* @deprecated 4.0.0:5.0.0
|
||||
* @deprecated 4.0.1 Use FixtureTestState instead
|
||||
*
|
||||
*/
|
||||
public function loadFixture($fixtureFile)
|
||||
{
|
||||
Deprecation::notice('5.0', __FUNCTION__ . ' is deprecated, use ' . FixtureTestState::class . ' instead');
|
||||
Deprecation::notice('4.0.1', 'Use FixtureTestState instead');
|
||||
$fixture = Injector::inst()->create(YamlFixture::class, $fixtureFile);
|
||||
$fixture->writeInto($this->getFixtureFactory());
|
||||
}
|
||||
@ -720,12 +720,12 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
/**
|
||||
* @param $matches
|
||||
* @param $dataObjectSet
|
||||
* @deprecated 4.0.0:5.0.0 Use assertListContains() instead
|
||||
* @deprecated 4.0.1 Use assertListContains() instead
|
||||
*
|
||||
*/
|
||||
public function assertDOSContains($matches, $dataObjectSet)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use assertListContains() instead');
|
||||
Deprecation::notice('4.0.1', 'Use assertListContains() instead');
|
||||
static::assertListContains($matches, $dataObjectSet);
|
||||
}
|
||||
|
||||
@ -774,12 +774,12 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
/**
|
||||
* @param $matches
|
||||
* @param $dataObjectSet
|
||||
* @deprecated 4.0.0:5.0.0 Use assertListNotContains() instead
|
||||
* @deprecated 4.0.1 Use assertListNotContains() instead
|
||||
*
|
||||
*/
|
||||
public static function assertNotDOSContains($matches, $dataObjectSet)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use assertListNotContains() instead');
|
||||
Deprecation::notice('4.0.1', 'Use assertListNotContains() instead');
|
||||
static::assertListNotContains($matches, $dataObjectSet);
|
||||
}
|
||||
|
||||
@ -822,12 +822,12 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
/**
|
||||
* @param $matches
|
||||
* @param SS_List $dataObjectSet
|
||||
* @deprecated 4.0.0:5.0.0 Use assertListEquals() instead
|
||||
* @deprecated 4.0.1 Use assertListEquals() instead
|
||||
*
|
||||
*/
|
||||
public function assertDOSEquals($matches, $dataObjectSet)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use assertListEquals() instead');
|
||||
Deprecation::notice('4.0.1', 'Use assertListEquals() instead');
|
||||
static::assertListEquals($matches, $dataObjectSet);
|
||||
}
|
||||
|
||||
@ -866,12 +866,12 @@ abstract class SapphireTest extends TestCase implements TestOnly
|
||||
/**
|
||||
* @param $match
|
||||
* @param SS_List $dataObjectSet
|
||||
* @deprecated 4.0.0:5.0.0 Use assertListAllMatch() instead
|
||||
* @deprecated 4.0.1 Use assertListAllMatch() instead
|
||||
*
|
||||
*/
|
||||
public function assertDOSAllMatch($match, SS_List $dataObjectSet)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use assertListAllMatch() instead');
|
||||
Deprecation::notice('4.0.1', 'Use assertListAllMatch() instead');
|
||||
static::assertListAllMatch($match, $dataObjectSet);
|
||||
}
|
||||
|
||||
|
@ -180,13 +180,13 @@ class FieldList extends ArrayList
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.1.0:5.0.0 Please use dataFields or saveableFields
|
||||
* @deprecated 4.1.0 Please use dataFields or saveableFields instead
|
||||
* @param $list
|
||||
* @param bool $saveableOnly
|
||||
*/
|
||||
protected function collateDataFields(&$list, $saveableOnly = false)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Please use dataFields or SaveableFields');
|
||||
Deprecation::notice('4.1.0', 'Please use dataFields or saveableFields instead');
|
||||
if (!isset($list)) {
|
||||
$list = [];
|
||||
}
|
||||
|
@ -1587,12 +1587,12 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
* and _form_enctype. These are the attributes of the form. These fields
|
||||
* can be used to send the form to Ajax.
|
||||
*
|
||||
* @deprecated 5.0
|
||||
* @deprecated 4.12.0 Will be removed without equivalent functionality
|
||||
* @return string
|
||||
*/
|
||||
public function formHtmlContent()
|
||||
{
|
||||
Deprecation::notice('5.0');
|
||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality');
|
||||
$this->IncludeFormTag = false;
|
||||
$content = $this->forTemplate();
|
||||
$this->IncludeFormTag = true;
|
||||
|
@ -435,13 +435,13 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi
|
||||
/**
|
||||
* Generate fields for the legacy filter header row
|
||||
*
|
||||
* @deprecated 5.0
|
||||
* @deprecated 4.12.0 Use search field instead
|
||||
* @param GridField $gridfield
|
||||
* @return ArrayList|null
|
||||
*/
|
||||
public function getLegacyFilterHeader(GridField $gridField)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Table row based filter header will be removed in favor of search field in 5.0');
|
||||
Deprecation::notice('4.12.0', 'Use search field instead');
|
||||
|
||||
$list = $gridField->getList();
|
||||
if (!$this->checkDataType($list)) {
|
||||
|
@ -11,13 +11,13 @@ if (!class_exists(VersionedGridFieldState::class)) {
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated 4.1.0:5.0.0
|
||||
* @deprecated 4.1.0 Use VersionedGridFieldState instead
|
||||
*/
|
||||
class GridFieldVersionedState extends VersionedGridFieldState
|
||||
{
|
||||
public function __construct(array $versionedLabelFields = ['Name', 'Title'])
|
||||
{
|
||||
Deprecation::notice('4.1.0', 'Use VersionedGridFieldState instead', Deprecation::SCOPE_CLASS);
|
||||
parent::__construct($versionedLabelFields);
|
||||
Deprecation::notice('5.0', 'Use ' . VersionedGridFieldState::class . ' instead');
|
||||
}
|
||||
}
|
||||
|
@ -925,21 +925,21 @@ class TinyMCEConfig extends HTMLEditorConfig implements i18nEntityProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0
|
||||
* @deprecated 4.0.1 Use getTinyMCEResourcePath() instead
|
||||
*/
|
||||
public function getTinyMCEPath()
|
||||
{
|
||||
Deprecation::notice('5.0', 'use getTinyMCEResourcePath instead');
|
||||
Deprecation::notice('4.0.1', 'Use getTinyMCEResourcePath() instead');
|
||||
return $this->getTinyMCEResourcePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Module
|
||||
* @deprecated 4.0.0:5.0.0
|
||||
* @deprecated 4.0.1 Set base_dir or editor_css config instead
|
||||
*/
|
||||
protected function getAdminModule()
|
||||
{
|
||||
Deprecation::notice('5.0', 'Set base_dir or editor_css config instead');
|
||||
Deprecation::notice('4.0.1', 'Set base_dir or editor_css config instead');
|
||||
return ModuleLoader::getModule('silverstripe/admin');
|
||||
}
|
||||
|
||||
|
@ -121,10 +121,11 @@ class TextField extends FormField implements TippableFieldInterface
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @deprecated 4.0.1 Use setValue() instead
|
||||
*/
|
||||
public function InternallyLabelledField()
|
||||
{
|
||||
Deprecation::notice('4.0', 'Please use ->setValue() instead');
|
||||
Deprecation::notice('4.0.1', 'Use setValue() instead');
|
||||
|
||||
if (!$this->value) {
|
||||
$this->value = $this->Title();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Assets\Folder;
|
||||
@ -621,12 +622,13 @@ class TreeDropdownField extends FormField
|
||||
/**
|
||||
* HTML-encoded label for this node, including css classes and other markup.
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use setTitleField()
|
||||
* @deprecated 4.0.1 Use setTitleField() instead
|
||||
* @param string $field
|
||||
* @return $this
|
||||
*/
|
||||
public function setLabelField($field)
|
||||
{
|
||||
Deprecation::notice('4.0.1', 'Use setTitleField() instead');
|
||||
$this->labelField = $field;
|
||||
return $this;
|
||||
}
|
||||
@ -634,11 +636,12 @@ class TreeDropdownField extends FormField
|
||||
/**
|
||||
* HTML-encoded label for this node, including css classes and other markup.
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use getTitleField()
|
||||
* @deprecated 4.0.1 Use getTitleField() instead
|
||||
* @return string
|
||||
*/
|
||||
public function getLabelField()
|
||||
{
|
||||
Deprecation::notice('4.0.1', 'Use getTitleField() instead');
|
||||
return $this->labelField;
|
||||
}
|
||||
|
||||
|
@ -18,13 +18,13 @@ class MonologErrorHandler implements ErrorHandler
|
||||
* Set the PSR-3 logger to send errors & exceptions to. Will overwrite any previously configured
|
||||
* loggers
|
||||
*
|
||||
* @deprecated 4.4.0:5.0.0 Use pushLogger() instead
|
||||
* @deprecated 4.4.0 Use pushLogger() instead
|
||||
* @param LoggerInterface $logger
|
||||
* @return $this
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger)
|
||||
{
|
||||
Deprecation::notice('4.4.0', 'Please use pushLogger() instead');
|
||||
Deprecation::notice('4.4.0', 'Use pushLogger() instead');
|
||||
|
||||
$this->loggers = [$logger];
|
||||
return $this;
|
||||
@ -33,12 +33,12 @@ class MonologErrorHandler implements ErrorHandler
|
||||
/**
|
||||
* Get the first registered PSR-3 logger to send errors & exceptions to
|
||||
*
|
||||
* @deprecated 4.4.0:5.0.0 Use getLoggers() instead
|
||||
* @deprecated 4.4.0 Use getLoggers() instead
|
||||
* @return LoggerInterface
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
Deprecation::notice('4.4.0', 'Please use getLoggers() instead');
|
||||
Deprecation::notice('4.4.0', 'Use getLoggers() instead');
|
||||
|
||||
return reset($this->loggers);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM\Connect;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use Exception;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
@ -59,9 +60,12 @@ abstract class DBSchemaManager
|
||||
/**
|
||||
* @param string $table
|
||||
* @param string $class
|
||||
*
|
||||
* @deprecated 4.0.1 Will be removed without equivalent functionality
|
||||
*/
|
||||
public static function showTableNameWarning($table, $class)
|
||||
{
|
||||
Deprecation::notice('4.0.1', 'Will be removed without equivalent functionality');
|
||||
static::$table_name_warnings[$table] = $class;
|
||||
}
|
||||
|
||||
|
@ -112,12 +112,12 @@ class DB
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since version 4.0 Use DB::get_conn instead
|
||||
* @deprecated 4.0.1 Use DB::get_conn() instead
|
||||
* @todo PSR-2 standardisation will probably un-deprecate this
|
||||
*/
|
||||
public static function getConn($name = 'default')
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use DB::get_conn instead');
|
||||
Deprecation::notice('4.0.1', 'Use DB::get_conn() instead');
|
||||
return self::get_conn($name);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
@ -19,10 +20,11 @@ abstract class DataExtension extends Extension
|
||||
{
|
||||
|
||||
/**
|
||||
* @deprecated 4.7.0 No longer used by internal code
|
||||
* @deprecated 4.7.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
public static function unload_extra_statics($class, $extension)
|
||||
{
|
||||
Deprecation::notice('4.7.0', 'Will be removed without equivalent functionality');
|
||||
throw new Exception('unload_extra_statics gone');
|
||||
}
|
||||
|
||||
|
@ -600,14 +600,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
/**
|
||||
* Copies the many_many and belongs_many_many relations from one object to another instance of the name of object.
|
||||
*
|
||||
* @deprecated 4.1.0:5.0.0 Use duplicateRelations() instead
|
||||
* @deprecated 4.1.0 Use duplicateRelations() instead
|
||||
* @param DataObject $sourceObject the source object to duplicate from
|
||||
* @param DataObject $destinationObject the destination object to populate with the duplicated relations
|
||||
* @param bool|string $filter
|
||||
*/
|
||||
protected function duplicateManyManyRelations($sourceObject, $destinationObject, $filter)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use duplicateRelations() instead');
|
||||
Deprecation::notice('4.1.0', 'Use duplicateRelations() instead');
|
||||
|
||||
// Get list of relations to duplicate
|
||||
if ($filter === 'many_many' || $filter === 'belongs_many_many') {
|
||||
@ -1266,10 +1266,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* Public accessor for {@see DataObject::validate()}
|
||||
*
|
||||
* @return ValidationResult
|
||||
* @deprecated 4.12.0 Use validate() instead
|
||||
*/
|
||||
public function doValidate()
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use validate');
|
||||
Deprecation::notice('4.12.0', 'Use validate() instead');
|
||||
return $this->validate();
|
||||
}
|
||||
|
||||
|
@ -376,11 +376,11 @@ class DatabaseAdmin extends Controller
|
||||
* @param string $fieldName The field name to look in for obsolete class names
|
||||
* @param string $oldClassName The old class name
|
||||
* @param string $newClassName The new class name
|
||||
* @deprecated 5.0 use updateLegacyClassNameField instead
|
||||
* @deprecated 4.12.0 Use updateLegacyClassNameField() instead
|
||||
*/
|
||||
protected function updateLegacyClassNames($dataClass, $fieldName, $oldClassName, $newClassName)
|
||||
{
|
||||
Deprecation::notice('5.0', 'use updateLegacyClassNameField instead');
|
||||
Deprecation::notice('4.12.0', 'Use updateLegacyClassNameField() instead');
|
||||
$this->updateLegacyClassNameField($dataClass, $fieldName, [$oldClassName => $newClassName]);
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,11 @@ class DBClassName extends DBEnum
|
||||
/**
|
||||
* Clear all cached classname specs. It's necessary to clear all cached subclassed names
|
||||
* for any classes if a new class manifest is generated.
|
||||
* @deprecated 4.3.0 Use DBEnum::flushCache() instead
|
||||
*/
|
||||
public static function clear_classname_cache()
|
||||
{
|
||||
Deprecation::notice('4.3', 'Call DBEnum::flushCache() instead');
|
||||
Deprecation::notice('4.3.0', 'Use DBEnum::flushCache() instead');
|
||||
DBEnum::flushCache();
|
||||
}
|
||||
|
||||
|
@ -232,10 +232,11 @@ class ValidationResult implements Serializable
|
||||
* The __serialize() magic method will be automatically used instead of this
|
||||
*
|
||||
* @return string
|
||||
* @deprecated will be removed in 5.0
|
||||
* @deprecated 4.12.0 Use __serialize() instead
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Use __serialize() instead');
|
||||
return json_encode([$this->messages, $this->isValid]);
|
||||
}
|
||||
|
||||
@ -245,10 +246,11 @@ class ValidationResult implements Serializable
|
||||
* and the PHP version used in less than PHP 9.0
|
||||
*
|
||||
* @param string $serialized
|
||||
* @deprecated will be removed in 5.0
|
||||
* @deprecated 4.12.0 Use __unserialize() instead
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Use __unserialize() instead');
|
||||
list($this->messages, $this->isValid) = json_decode($serialized ?? '', true);
|
||||
}
|
||||
}
|
||||
|
@ -720,8 +720,6 @@ class Group extends DataObject
|
||||
/**
|
||||
* Code needs to be unique as it is used to identify a specific group. Ensure no duplicate
|
||||
* codes are created.
|
||||
*
|
||||
* @deprecated 5.0 Remove deduping in favour of throwing a validation error for duplicates.
|
||||
*/
|
||||
private function dedupeCode(): void
|
||||
{
|
||||
|
@ -282,26 +282,26 @@ class Member extends DataObject
|
||||
/**
|
||||
* Get the default admin record if it exists, or creates it otherwise if enabled
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use DefaultAdminService::findOrCreateDefaultAdmin() instead
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::findOrCreateDefaultAdmin() instead
|
||||
* @return Member
|
||||
*/
|
||||
public static function default_admin()
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use DefaultAdminService::findOrCreateDefaultAdmin() instead');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::findOrCreateDefaultAdmin() instead');
|
||||
return DefaultAdminService::singleton()->findOrCreateDefaultAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the passed password matches the stored one (if the member is not locked out).
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use Authenticator::checkPassword() instead
|
||||
* @deprecated 4.0.1 Use Authenticator::checkPassword() instead
|
||||
*
|
||||
* @param string $password
|
||||
* @return ValidationResult
|
||||
*/
|
||||
public function checkPassword($password)
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use Authenticator::checkPassword() instead');
|
||||
Deprecation::notice('4.0.1', 'Use Authenticator::checkPassword() instead');
|
||||
|
||||
// With a valid user and password, check the password is correct
|
||||
$result = ValidationResult::create();
|
||||
@ -448,15 +448,12 @@ class Member extends DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 5.0.0 Use Security::setCurrentUser() or IdentityStore::logIn()
|
||||
* @deprecated 4.12.0 Use Security::setCurrentUser() or IdentityStore::logIn() instead
|
||||
*
|
||||
*/
|
||||
public function logIn()
|
||||
{
|
||||
Deprecation::notice(
|
||||
'5.0.0',
|
||||
'This method is deprecated and only logs in for the current request. Please use Security::setCurrentUser($user) or an IdentityStore'
|
||||
);
|
||||
Deprecation::notice('4.12.0', 'Use Security::setCurrentUser() or IdentityStore::logIn() instead');
|
||||
Security::setCurrentUser($this);
|
||||
}
|
||||
|
||||
@ -509,16 +506,13 @@ class Member extends DataObject
|
||||
* has a database record of the same ID. If there is
|
||||
* no logged in user, FALSE is returned anyway.
|
||||
*
|
||||
* @deprecated Not needed anymore, as it returns Security::getCurrentUser();
|
||||
* @deprecated 4.12.0 Use Security::getCurrentUser() instead
|
||||
*
|
||||
* @return boolean TRUE record found FALSE no record found
|
||||
*/
|
||||
public static function logged_in_session_exists()
|
||||
{
|
||||
Deprecation::notice(
|
||||
'5.0.0',
|
||||
'This method is deprecated and now does not add value. Please use Security::getCurrentUser()'
|
||||
);
|
||||
Deprecation::notice('4.12.0', 'Use Security::getCurrentUser() instead');
|
||||
|
||||
$member = Security::getCurrentUser();
|
||||
if ($member && $member->exists()) {
|
||||
@ -529,15 +523,13 @@ class Member extends DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use Security::setCurrentUser(null) or an IdentityStore
|
||||
* Logs this member out.
|
||||
*
|
||||
* @deprecated 4.12.0 Use Security::setCurrentUser(null) or an IdentityStore instead
|
||||
*/
|
||||
public function logOut()
|
||||
{
|
||||
Deprecation::notice(
|
||||
'5.0.0',
|
||||
'This method is deprecated and now does not persist. Please use Security::setCurrentUser(null) or an IdentityStore'
|
||||
);
|
||||
Deprecation::notice('4.12.0', 'Use Security::setCurrentUser(null) or an IdentityStore instead');
|
||||
|
||||
Injector::inst()->get(IdentityStore::class)->logOut(Controller::curr()->getRequest());
|
||||
}
|
||||
@ -769,16 +761,13 @@ class Member extends DataObject
|
||||
/**
|
||||
* Returns the current logged in user
|
||||
*
|
||||
* @deprecated 5.0.0 use Security::getCurrentUser()
|
||||
* @deprecated 4.12.0 Use Security::getCurrentUser() instead
|
||||
*
|
||||
* @return Member
|
||||
*/
|
||||
public static function currentUser()
|
||||
{
|
||||
Deprecation::notice(
|
||||
'5.0.0',
|
||||
'This method is deprecated. Please use Security::getCurrentUser() or an IdentityStore'
|
||||
);
|
||||
Deprecation::notice('4.12.0', 'Use Security::getCurrentUser() instead');
|
||||
|
||||
return Security::getCurrentUser();
|
||||
}
|
||||
@ -819,16 +808,13 @@ class Member extends DataObject
|
||||
/**
|
||||
* Get the ID of the current logged in user
|
||||
*
|
||||
* @deprecated 5.0.0 use Security::getCurrentUser()
|
||||
* @deprecated 4.12.0 Use Security::getCurrentUser() instead
|
||||
*
|
||||
* @return int Returns the ID of the current logged in user or 0.
|
||||
*/
|
||||
public static function currentUserID()
|
||||
{
|
||||
Deprecation::notice(
|
||||
'5.0.0',
|
||||
'This method is deprecated. Please use Security::getCurrentUser() or an IdentityStore'
|
||||
);
|
||||
Deprecation::notice('4.12.0', 'Use Security::getCurrentUser() instead');
|
||||
|
||||
$member = Security::getCurrentUser();
|
||||
if ($member) {
|
||||
@ -1117,10 +1103,11 @@ class Member extends DataObject
|
||||
/**
|
||||
* @param array $columns Column names on the Member record to show in {@link getTitle()}.
|
||||
* @param string $sep Separator
|
||||
* @deprecated 4.12.0 Use Member.title_format config instead
|
||||
*/
|
||||
public static function set_title_columns($columns, $sep = ' ')
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use Member.title_format config instead');
|
||||
Deprecation::notice('4.12.0', 'Use Member.title_format config instead');
|
||||
if (!is_array($columns)) {
|
||||
$columns = [$columns];
|
||||
}
|
||||
|
@ -76,20 +76,19 @@ class PasswordValidator
|
||||
protected $historicalPasswordCount = null;
|
||||
|
||||
/**
|
||||
* @deprecated 4.5.0
|
||||
* Minimum password length
|
||||
*
|
||||
* @param int $minLength
|
||||
* @return $this
|
||||
* @deprecated 4.5.0 Use setMinLength() instead
|
||||
*/
|
||||
public function minLength($minLength)
|
||||
{
|
||||
Deprecation::notice('4.5.0', 'Use ->setMinLength($value) instead.');
|
||||
Deprecation::notice('4.5.0', 'Use setMinLength() instead');
|
||||
return $this->setMinLength($minLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.5.0
|
||||
* Check the character strength of the password.
|
||||
*
|
||||
* Eg: $this->characterStrength(3, array("lowercase", "uppercase", "digits", "punctuation"))
|
||||
@ -97,13 +96,11 @@ class PasswordValidator
|
||||
* @param int $minScore The minimum number of character tests that must pass
|
||||
* @param string[] $testNames The names of the tests to perform
|
||||
* @return $this
|
||||
* @deprecated 4.5.0 Use setMinTestScore($score) and setTestNames($names) instead
|
||||
*/
|
||||
public function characterStrength($minScore, $testNames = null)
|
||||
{
|
||||
Deprecation::notice(
|
||||
'4.5.0',
|
||||
'Use ->setMinTestScore($score) and ->setTestNames($names) instead.'
|
||||
);
|
||||
Deprecation::notice('4.5.0', 'Use setMinTestScore($score) and setTestNames($names) instead');
|
||||
$this->setMinTestScore($minScore);
|
||||
if ($testNames) {
|
||||
$this->setTestNames($testNames);
|
||||
@ -112,15 +109,15 @@ class PasswordValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.5.0
|
||||
* Check a number of previous passwords that the user has used, and don't let them change to that.
|
||||
*
|
||||
* @param int $count
|
||||
* @return $this
|
||||
* @deprecated 4.5.0 Use setHistoricCount($value) instead
|
||||
*/
|
||||
public function checkHistoricalPasswords($count)
|
||||
{
|
||||
Deprecation::notice('4.5.0', 'Use ->setHistoricCount($value) instead.');
|
||||
Deprecation::notice('4.5.0', 'Use setHistoricCount($value) instead');
|
||||
return $this->setHistoricCount($count);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Resettable;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
@ -660,10 +661,11 @@ class Permission extends DataObject implements TemplateGlobalProvider, Resettabl
|
||||
* Get a linear list of the permissions in the system.
|
||||
*
|
||||
* @return array Linear list of declared permissions in the system.
|
||||
* @deprecated 4.4.0
|
||||
* @deprecated 4.4.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
public static function get_declared_permissions_list()
|
||||
{
|
||||
Deprecation::notice('4.4.0', 'Will be removed without equivalent functionality');
|
||||
if (!self::$declared_permissions) {
|
||||
return null;
|
||||
}
|
||||
@ -684,10 +686,11 @@ class Permission extends DataObject implements TemplateGlobalProvider, Resettabl
|
||||
*
|
||||
* @param string $perm Permission code
|
||||
* @return string Label for the given permission, or the permission itself if the label doesn't exist
|
||||
* @deprecated 4.4.0
|
||||
* @deprecated 4.4.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
public static function get_label_for_permission($perm)
|
||||
{
|
||||
Deprecation::notice('4.4.0', 'Will be removed without equivalent functionality');
|
||||
$list = self::get_declared_permissions_list();
|
||||
if (array_key_exists($perm, $list ?? [])) {
|
||||
return $list[$perm];
|
||||
@ -702,10 +705,11 @@ class Permission extends DataObject implements TemplateGlobalProvider, Resettabl
|
||||
* @param array $declared Nested structure of permissions.
|
||||
* @param array $list List of permissions in the structure. The result will be
|
||||
* written to this array.
|
||||
* @deprecated 4.4.0
|
||||
* @deprecated 4.4.0 Will be removed without equivalent functionality
|
||||
*/
|
||||
protected static function traverse_declared_permissions($declared, &$list)
|
||||
{
|
||||
Deprecation::notice('4.4.0', 'Will be removed without equivalent functionality');
|
||||
if (!is_array($declared)) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ class RandomGenerator
|
||||
/**
|
||||
* @return string A 128-character, randomly generated ASCII string
|
||||
* @throws Exception If no suitable CSPRNG is installed
|
||||
* @deprecated 4.4.0:5.0.0
|
||||
* @deprecated 4.4.0 Use native php function random_bytes() instead
|
||||
*/
|
||||
public function generateEntropy()
|
||||
{
|
||||
Deprecation::notice('4.4', __METHOD__ . ' has been deprecated. Use random_bytes instead');
|
||||
Deprecation::notice('4.4.0', 'Use native php function random_bytes() instead');
|
||||
|
||||
try {
|
||||
return bin2hex(random_bytes(64));
|
||||
|
@ -463,7 +463,7 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
/**
|
||||
* Get the login forms for all available authentication methods
|
||||
*
|
||||
* @deprecated 5.0.0 Now handled by {@link static::delegateToMultipleHandlers}
|
||||
* @deprecated 4.12.0 Use delegateToMultipleHandlers() instead
|
||||
*
|
||||
* @return array Returns an array of available login forms (array of Form
|
||||
* objects).
|
||||
@ -471,7 +471,7 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
*/
|
||||
public function getLoginForms()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Now handled by delegateToMultipleHandlers');
|
||||
Deprecation::notice('4.12.0', 'Use delegateToMultipleHandlers() instead');
|
||||
|
||||
return array_map(
|
||||
function (Authenticator $authenticator) {
|
||||
@ -1072,11 +1072,11 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
*
|
||||
* @return Member
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Please use DefaultAdminService::findOrCreateDefaultAdmin()
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::findOrCreateDefaultAdmin()
|
||||
*/
|
||||
public static function findAnAdministrator()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Please use DefaultAdminService::findOrCreateDefaultAdmin()');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::findOrCreateDefaultAdmin()');
|
||||
|
||||
$service = DefaultAdminService::singleton();
|
||||
return $service->findOrCreateDefaultAdmin();
|
||||
@ -1085,11 +1085,11 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
/**
|
||||
* Flush the default admin credentials
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Please use DefaultAdminService::clearDefaultAdmin()
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::clearDefaultAdmin()
|
||||
*/
|
||||
public static function clear_default_admin()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Please use DefaultAdminService::clearDefaultAdmin()');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::clearDefaultAdmin()');
|
||||
|
||||
DefaultAdminService::clearDefaultAdmin();
|
||||
}
|
||||
@ -1106,11 +1106,11 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
* @param string $password The password (in cleartext)
|
||||
* @return bool True if successfully set
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Please use DefaultAdminService::setDefaultAdmin($username, $password)
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::setDefaultAdmin($username, $password)
|
||||
*/
|
||||
public static function setDefaultAdmin($username, $password)
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Please use DefaultAdminService::setDefaultAdmin($username, $password)');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::setDefaultAdmin($username, $password)');
|
||||
|
||||
DefaultAdminService::setDefaultAdmin($username, $password);
|
||||
return true;
|
||||
@ -1124,11 +1124,11 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
* @param string $password
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use DefaultAdminService::isDefaultAdminCredentials() instead
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::isDefaultAdminCredentials() instead
|
||||
*/
|
||||
public static function check_default_admin($username, $password)
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Please use DefaultAdminService::isDefaultAdminCredentials($username, $password)');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::isDefaultAdminCredentials() instead');
|
||||
|
||||
/** @var DefaultAdminService $service */
|
||||
return DefaultAdminService::isDefaultAdminCredentials($username, $password);
|
||||
@ -1137,11 +1137,11 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
/**
|
||||
* Check that the default admin account has been set.
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use DefaultAdminService::hasDefaultAdmin() instead
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::hasDefaultAdmin() instead
|
||||
*/
|
||||
public static function has_default_admin()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Please use DefaultAdminService::hasDefaultAdmin()');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::hasDefaultAdmin() instead');
|
||||
|
||||
return DefaultAdminService::hasDefaultAdmin();
|
||||
}
|
||||
@ -1149,12 +1149,12 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
/**
|
||||
* Get default admin username
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use DefaultAdminService::getDefaultAdminUsername()
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::getDefaultAdminUsername() instead
|
||||
* @return string
|
||||
*/
|
||||
public static function default_admin_username()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Please use DefaultAdminService::getDefaultAdminUsername()');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::getDefaultAdminUsername() instead');
|
||||
|
||||
return DefaultAdminService::getDefaultAdminUsername();
|
||||
}
|
||||
@ -1162,12 +1162,12 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
/**
|
||||
* Get default admin password
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0 Use DefaultAdminService::getDefaultAdminPassword()
|
||||
* @deprecated 4.0.1 Use DefaultAdminService::getDefaultAdminPassword() instead
|
||||
* @return string
|
||||
*/
|
||||
public static function default_admin_password()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Please use DefaultAdminService::getDefaultAdminPassword()');
|
||||
Deprecation::notice('4.0.1', 'Use DefaultAdminService::getDefaultAdminPassword() instead');
|
||||
|
||||
return DefaultAdminService::getDefaultAdminPassword();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use SilverStripe\Dev\Deprecation;
|
||||
* Encapsulation of an embed tag, linking to an external media source.
|
||||
*
|
||||
* @see Embed
|
||||
* @deprecated 4.11..5.0 Use EmbedContainer instead
|
||||
* @deprecated 4.11.0 Use EmbedContainer instead
|
||||
*/
|
||||
class EmbedResource implements Embeddable
|
||||
{
|
||||
@ -46,7 +46,7 @@ class EmbedResource implements Embeddable
|
||||
*/
|
||||
public function __construct($url)
|
||||
{
|
||||
Deprecation::notice('4.11', 'Use EmbedContainer instead');
|
||||
Deprecation::notice('4.11.0', 'Use EmbedContainer instead', Deprecation::SCOPE_CLASS);
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
|
@ -238,11 +238,12 @@ class Requirements_Backend
|
||||
/**
|
||||
* Gets the minification service for this backend
|
||||
*
|
||||
* @deprecated 4.0.0:5.0.0
|
||||
* @return Requirements_Minifier
|
||||
* @deprecated 4.0.1 Will be removed without equivalent functionality
|
||||
*/
|
||||
public function getMinifier()
|
||||
{
|
||||
Deprecation::notice('4.0.1', 'Will be removed without equivalent functionality');
|
||||
return $this->minifier;
|
||||
}
|
||||
|
||||
|
@ -296,12 +296,12 @@ class SSViewer implements Flushable
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 4.0.0:5.0.0 Use the "SSViewer#set_themes" instead
|
||||
* @param string $theme The "base theme" name (without underscores).
|
||||
* @deprecated 4.0.1 Use SSViewer::set_themes() instead
|
||||
*/
|
||||
public static function set_theme($theme)
|
||||
{
|
||||
Deprecation::notice('4.0', 'Use the "SSViewer#set_themes" instead');
|
||||
Deprecation::notice('4.0.1', 'Use SSViewer::set_themes() instead');
|
||||
self::set_themes([$theme, self::DEFAULT_THEME]);
|
||||
}
|
||||
|
||||
|
@ -67,12 +67,12 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 5.0.0 Use IsFirst() to avoid clashes with SS_Lists
|
||||
* @deprecated 4.12.0 Use IsFirst() instead
|
||||
* @return bool
|
||||
*/
|
||||
public function First()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Use IsFirst() to avoid clashes with SS_Lists');
|
||||
Deprecation::notice('4.12.0', 'Use IsFirst() instead');
|
||||
return $this->IsFirst();
|
||||
}
|
||||
|
||||
@ -87,12 +87,12 @@ class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 5.0.0 Use IsLast() to avoid clashes with SS_Lists
|
||||
* @deprecated 4.12.0 Use IsLast() instead
|
||||
* @return bool
|
||||
*/
|
||||
public function Last()
|
||||
{
|
||||
Deprecation::notice('5.0.0', 'Use IsLast() to avoid clashes with SS_Lists');
|
||||
Deprecation::notice('4.12.0', 'Use IsLast() instead');
|
||||
return $this->IsLast();
|
||||
}
|
||||
|
||||
|
@ -160,11 +160,11 @@ class EmbedShortcodeProvider implements ShortcodeHandler
|
||||
* @param Adapter $embed
|
||||
* @param array $arguments Additional shortcode params
|
||||
* @return string
|
||||
* @deprecated 4.11..5.0 Use embeddableToHtml instead
|
||||
* @deprecated 4.11.0 Use embeddableToHtml() instead
|
||||
*/
|
||||
public static function embedForTemplate($embed, $arguments)
|
||||
{
|
||||
Deprecation::notice('4.11', 'Use embeddableToHtml() instead');
|
||||
Deprecation::notice('4.11.0', 'Use embeddableToHtml() instead');
|
||||
switch ($embed->getType()) {
|
||||
case 'video':
|
||||
case 'rich':
|
||||
@ -257,7 +257,6 @@ class EmbedShortcodeProvider implements ShortcodeHandler
|
||||
/**
|
||||
* Build a list of HTML attributes from embed arguments - used to preserve backward compatibility
|
||||
*
|
||||
* @deprecated 4.5.0 Use {$Arguments.name} directly in shortcode templates to access argument values
|
||||
* @param array $arguments List of embed arguments
|
||||
* @param array $exclude List of attribute names to exclude from the resulting list
|
||||
* @return ArrayList
|
||||
|
@ -619,11 +619,11 @@ class ViewableData implements IteratorAggregate
|
||||
* project directory.
|
||||
*
|
||||
* @return string URL to the current theme
|
||||
* @deprecated 4.0.0:5.0.0 Use $resourcePath or $resourceURL template helpers instead
|
||||
* @deprecated 4.0.1 Use ModuleResourceLoader::resourcePath() or ModuleResourceLoader::resourceURL() instead
|
||||
*/
|
||||
public function ThemeDir()
|
||||
{
|
||||
Deprecation::notice('5.0', 'Use $resourcePath or $resourceURL template helpers instead');
|
||||
Deprecation::notice('4.0.1', 'Use ModuleResourceLoader::resourcePath() or ModuleResourceLoader::resourceURL() instead');
|
||||
$themes = SSViewer::get_themes();
|
||||
foreach ($themes as $theme) {
|
||||
// Skip theme sets
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\i18n\Messages\Symfony;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
use Symfony\Component\Config\Resource\SelfCheckingResourceInterface;
|
||||
@ -54,10 +55,11 @@ class FlushInvalidatedResource implements SelfCheckingResourceInterface, \Serial
|
||||
* The __serialize() magic method will be automatically used instead of this
|
||||
*
|
||||
* @return string
|
||||
* @deprecated will be removed in 5.0
|
||||
* @deprecated 4.12.0 Use __serialize() instead
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Use __serialize() instead');
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -67,10 +69,11 @@ class FlushInvalidatedResource implements SelfCheckingResourceInterface, \Serial
|
||||
* and the PHP version used in less than PHP 9.0
|
||||
*
|
||||
* @param string $serialized
|
||||
* @deprecated will be removed in 5.0
|
||||
* @deprecated 4.12.0 Use __unserialize() instead
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
Deprecation::notice('4.12.0', 'Use __unserialize() instead');
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
@ -1155,4 +1155,27 @@ class InjectorTest extends SapphireTest
|
||||
Injector::unnest();
|
||||
$this->nestingLevel--;
|
||||
}
|
||||
|
||||
public function testAnonymousClass()
|
||||
{
|
||||
Injector::inst()->load([
|
||||
'Some\\Project\\Class' => [
|
||||
// the php anonymous class syntax will instantiate a new anonymous class object, with ('abc')
|
||||
// passed to the constructor
|
||||
'class' => new class ('abc') {
|
||||
private string $property;
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$this->property = $value;
|
||||
}
|
||||
public function foo(): string
|
||||
{
|
||||
return $this->property;
|
||||
}
|
||||
}
|
||||
],
|
||||
]);
|
||||
// assert that Injector creates a new instance of the anonymous class, with ('def') passed to the constructor
|
||||
$this->assertSame('def', Injector::inst()->create('Some\\Project\\Class', 'def')->foo());
|
||||
}
|
||||
}
|
||||
|
@ -8,103 +8,34 @@ use SilverStripe\Dev\Tests\DeprecationTest\TestDeprecation;
|
||||
|
||||
class DeprecationTest extends SapphireTest
|
||||
{
|
||||
|
||||
static $originalVersionInfo;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
self::$originalVersionInfo = Deprecation::dump_settings();
|
||||
Deprecation::$notice_level = E_USER_NOTICE;
|
||||
Deprecation::set_enabled(true);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Deprecation::restore_settings(self::$originalVersionInfo);
|
||||
Deprecation::$notice_level = E_USER_DEPRECATED;
|
||||
Deprecation::disable();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testLesserVersionTriggersNoNotice()
|
||||
{
|
||||
Deprecation::notification_version('1.0.0');
|
||||
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test failed'));
|
||||
}
|
||||
|
||||
public function testEqualVersionTriggersNotice()
|
||||
public function testNotice()
|
||||
{
|
||||
$message = implode(' ', [
|
||||
'SilverStripe\Dev\Tests\DeprecationTest->testNotice is deprecated.',
|
||||
'My message.',
|
||||
'Called from PHPUnit\Framework\TestCase->runTest.'
|
||||
]);
|
||||
$this->expectError();
|
||||
Deprecation::notification_version('2.0.0');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
||||
$this->expectErrorMessage($message);
|
||||
Deprecation::$notice_level = E_USER_NOTICE;
|
||||
Deprecation::enable();
|
||||
Deprecation::notice('1.2.3', 'My message');
|
||||
}
|
||||
|
||||
public function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenum()
|
||||
/**
|
||||
* @doesNotPerformAssertions
|
||||
*/
|
||||
public function testDisabled()
|
||||
{
|
||||
Deprecation::notification_version('2.0.0-beta1');
|
||||
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test failed'));
|
||||
$this->assertNull(Deprecation::notice('2.0.0', 'Deprecation test failed'));
|
||||
}
|
||||
|
||||
public function testGreaterVersionTriggersNotice()
|
||||
{
|
||||
$this->expectError();
|
||||
Deprecation::notification_version('3.0.0');
|
||||
Deprecation::notice('2.0', 'Deprecation test passed');
|
||||
}
|
||||
|
||||
public function testNonMatchingModuleNotifcationVersionDoesntAffectNotice()
|
||||
{
|
||||
Deprecation::notification_version('1.0.0');
|
||||
Deprecation::notification_version('3.0.0', 'my-unrelated-module');
|
||||
$this->callThatOriginatesFromFramework();
|
||||
}
|
||||
|
||||
public function testMatchingModuleNotifcationVersionAffectsNotice()
|
||||
{
|
||||
$this->expectError();
|
||||
Deprecation::notification_version('1.0.0');
|
||||
Deprecation::notification_version('3.0.0', 'silverstripe/framework');
|
||||
$this->callThatOriginatesFromFramework();
|
||||
}
|
||||
|
||||
public function testMethodNameCalculation()
|
||||
{
|
||||
$this->assertEquals(
|
||||
TestDeprecation::get_method(),
|
||||
static::class . '->testMethodNameCalculation'
|
||||
);
|
||||
}
|
||||
|
||||
public function testScopeMethod()
|
||||
{
|
||||
$this->expectError();
|
||||
$this->expectErrorMessage('DeprecationTest->testScopeMethod is deprecated. Method scope');
|
||||
Deprecation::notification_version('2.0.0');
|
||||
Deprecation::notice('2.0.0', 'Method scope', Deprecation::SCOPE_METHOD);
|
||||
}
|
||||
|
||||
public function testScopeClass()
|
||||
{
|
||||
$this->expectError();
|
||||
$this->expectErrorMessage('DeprecationTest is deprecated. Class scope');
|
||||
Deprecation::notification_version('2.0.0');
|
||||
Deprecation::notice('2.0.0', 'Class scope', Deprecation::SCOPE_CLASS);
|
||||
}
|
||||
|
||||
public function testScopeGlobal()
|
||||
{
|
||||
$this->expectError();
|
||||
$this->expectErrorMessage('Global scope');
|
||||
Deprecation::notification_version('2.0.0');
|
||||
Deprecation::notice('2.0.0', 'Global scope', Deprecation::SCOPE_GLOBAL);
|
||||
}
|
||||
|
||||
protected function callThatOriginatesFromFramework()
|
||||
{
|
||||
$module = TestDeprecation::get_module();
|
||||
$this->assertNotNull($module);
|
||||
$this->assertEquals('silverstripe/framework', $module->getName());
|
||||
$this->assertNull(Deprecation::notice('2.0', 'Deprecation test passed'));
|
||||
Deprecation::$notice_level = E_USER_NOTICE;
|
||||
// test that no error error is raised because by default Deprecation is disabled
|
||||
Deprecation::notice('4.5.6', 'My message');
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Dev\Tests\DeprecationTest;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
class TestDeprecation extends Deprecation
|
||||
{
|
||||
public static function get_module()
|
||||
{
|
||||
return self::get_calling_module_from_trace(debug_backtrace(0));
|
||||
}
|
||||
|
||||
public static function get_method()
|
||||
{
|
||||
return self::get_called_method_from_trace(debug_backtrace(0));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user