mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '5' into 6
This commit is contained in:
commit
c523022cb9
@ -16,7 +16,7 @@ class CliBypass implements Bypass
|
|||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be removed without equivalent functionality to replace it',
|
'Will be removed without equivalent functionality to replace it',
|
||||||
|
@ -96,7 +96,7 @@ abstract class BuildTask
|
|||||||
*/
|
*/
|
||||||
public function getDescription()
|
public function getDescription()
|
||||||
{
|
{
|
||||||
Deprecation::withNoReplacement(
|
Deprecation::withSuppressedNotice(
|
||||||
fn() => Deprecation::notice('5.4.0', 'Will be replaced with a static method with the same name')
|
fn() => Deprecation::notice('5.4.0', 'Will be replaced with a static method with the same name')
|
||||||
);
|
);
|
||||||
return $this->description;
|
return $this->description;
|
||||||
|
@ -53,7 +53,7 @@ class Deprecation
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
private static bool $insideWithNoReplacement = false;
|
private static bool $insideNoticeSuppression = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
@ -103,22 +103,32 @@ class Deprecation
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to wrap deprecated methods and deprecated config get()/set() that will be removed
|
* Used to wrap deprecated methods and deprecated config get()/set() called from the vendor
|
||||||
* in the next major version with no replacement. This is done to surpress deprecation notices
|
* dir that projects have no ability to change.
|
||||||
* by for calls from the vendor dir to deprecated code that projects have no ability to change
|
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @deprecated 5.4.0 Use withSuppressedNotice() instead
|
||||||
*/
|
*/
|
||||||
public static function withNoReplacement(callable $func)
|
public static function withNoReplacement(callable $func)
|
||||||
{
|
{
|
||||||
if (Deprecation::$insideWithNoReplacement) {
|
Deprecation::notice('5.4.0', 'Use withSuppressedNotice() instead');
|
||||||
|
return Deprecation::withSuppressedNotice($func);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to wrap deprecated methods and deprecated config get()/set() called from the vendor
|
||||||
|
* dir that projects have no ability to change.
|
||||||
|
*/
|
||||||
|
public static function withSuppressedNotice(callable $func): mixed
|
||||||
|
{
|
||||||
|
if (Deprecation::$insideNoticeSuppression) {
|
||||||
return $func();
|
return $func();
|
||||||
}
|
}
|
||||||
Deprecation::$insideWithNoReplacement = true;
|
Deprecation::$insideNoticeSuppression = true;
|
||||||
try {
|
try {
|
||||||
return $func();
|
return $func();
|
||||||
} finally {
|
} finally {
|
||||||
Deprecation::$insideWithNoReplacement = false;
|
Deprecation::$insideNoticeSuppression = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,8 +147,8 @@ class Deprecation
|
|||||||
$level = 1;
|
$level = 1;
|
||||||
}
|
}
|
||||||
$newLevel = $level;
|
$newLevel = $level;
|
||||||
// handle closures inside withNoReplacement()
|
// handle closures inside withSuppressedNotice()
|
||||||
if (Deprecation::$insideWithNoReplacement
|
if (Deprecation::$insideNoticeSuppression
|
||||||
&& substr($backtrace[$newLevel]['function'], -strlen('{closure}')) === '{closure}'
|
&& substr($backtrace[$newLevel]['function'], -strlen('{closure}')) === '{closure}'
|
||||||
) {
|
) {
|
||||||
$newLevel = $newLevel + 2;
|
$newLevel = $newLevel + 2;
|
||||||
@ -247,8 +257,8 @@ class Deprecation
|
|||||||
$count++;
|
$count++;
|
||||||
$arr = array_shift(Deprecation::$userErrorMessageBuffer);
|
$arr = array_shift(Deprecation::$userErrorMessageBuffer);
|
||||||
$message = $arr['message'];
|
$message = $arr['message'];
|
||||||
$calledInsideWithNoReplacement = $arr['calledInsideWithNoReplacement'];
|
$calledWithNoticeSuppression = $arr['calledWithNoticeSuppression'];
|
||||||
if ($calledInsideWithNoReplacement && !Deprecation::$showNoReplacementNotices) {
|
if ($calledWithNoticeSuppression && !Deprecation::$showNoReplacementNotices) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Deprecation::$isTriggeringError = true;
|
Deprecation::$isTriggeringError = true;
|
||||||
@ -284,7 +294,7 @@ class Deprecation
|
|||||||
$data = [
|
$data = [
|
||||||
'key' => sha1($string),
|
'key' => sha1($string),
|
||||||
'message' => $string,
|
'message' => $string,
|
||||||
'calledInsideWithNoReplacement' => Deprecation::$insideWithNoReplacement
|
'calledWithNoticeSuppression' => Deprecation::$insideNoticeSuppression
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
if (!Deprecation::isEnabled()) {
|
if (!Deprecation::isEnabled()) {
|
||||||
@ -310,7 +320,7 @@ class Deprecation
|
|||||||
$string .= ".";
|
$string .= ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
$level = Deprecation::$insideWithNoReplacement ? 4 : 2;
|
$level = Deprecation::$insideNoticeSuppression ? 4 : 2;
|
||||||
$string .= " Called from " . Deprecation::get_called_method_from_trace($backtrace, $level) . '.';
|
$string .= " Called from " . Deprecation::get_called_method_from_trace($backtrace, $level) . '.';
|
||||||
|
|
||||||
if ($caller) {
|
if ($caller) {
|
||||||
@ -319,7 +329,7 @@ class Deprecation
|
|||||||
$data = [
|
$data = [
|
||||||
'key' => sha1($string),
|
'key' => sha1($string),
|
||||||
'message' => $string,
|
'message' => $string,
|
||||||
'calledInsideWithNoReplacement' => Deprecation::$insideWithNoReplacement
|
'calledWithNoticeSuppression' => Deprecation::$insideNoticeSuppression
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if ($data && !array_key_exists($data['key'], Deprecation::$userErrorMessageBuffer)) {
|
if ($data && !array_key_exists($data['key'], Deprecation::$userErrorMessageBuffer)) {
|
||||||
|
@ -34,7 +34,7 @@ class DevBuildController extends Controller implements PermissionProvider
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be replaced with SilverStripe\Dev\Command\DbBuild',
|
'Will be replaced with SilverStripe\Dev\Command\DbBuild',
|
||||||
|
@ -47,7 +47,7 @@ class DevConfigController extends Controller implements PermissionProvider
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be replaced with SilverStripe\Dev\Command\ConfigDump',
|
'Will be replaced with SilverStripe\Dev\Command\ConfigDump',
|
||||||
|
@ -233,7 +233,7 @@ class DevelopmentAdmin extends Controller implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
public function buildDefaults()
|
public function buildDefaults()
|
||||||
{
|
{
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be replaced with SilverStripe\Dev\Command\DbDefaults'
|
'Will be replaced with SilverStripe\Dev\Command\DbDefaults'
|
||||||
@ -266,7 +266,7 @@ class DevelopmentAdmin extends Controller implements PermissionProvider
|
|||||||
*/
|
*/
|
||||||
public function generatesecuretoken()
|
public function generatesecuretoken()
|
||||||
{
|
{
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be replaced with SilverStripe\Dev\Command\GenerateSecureToken'
|
'Will be replaced with SilverStripe\Dev\Command\GenerateSecureToken'
|
||||||
|
@ -36,7 +36,7 @@ class CleanupTestDatabasesTask extends BuildTask
|
|||||||
|
|
||||||
public function canView(): bool
|
public function canView(): bool
|
||||||
{
|
{
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be replaced with canRunInBrowser()'
|
'Will be replaced with canRunInBrowser()'
|
||||||
|
@ -25,7 +25,7 @@ class GridFieldConfig_Base extends GridFieldConfig
|
|||||||
$this->addComponent(GridFieldPageCount::create('toolbar-header-right'));
|
$this->addComponent(GridFieldPageCount::create('toolbar-header-right'));
|
||||||
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
|
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
|
||||||
|
|
||||||
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
|
Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) {
|
||||||
$sort->setThrowExceptionOnBadDataType(false);
|
$sort->setThrowExceptionOnBadDataType(false);
|
||||||
$filter->setThrowExceptionOnBadDataType(false);
|
$filter->setThrowExceptionOnBadDataType(false);
|
||||||
$pagination->setThrowExceptionOnBadDataType(false);
|
$pagination->setThrowExceptionOnBadDataType(false);
|
||||||
|
@ -32,7 +32,7 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig
|
|||||||
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
|
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
|
||||||
$this->addComponent(GridFieldDetailForm::create(null, $showPagination, $showAdd));
|
$this->addComponent(GridFieldDetailForm::create(null, $showPagination, $showAdd));
|
||||||
|
|
||||||
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
|
Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) {
|
||||||
$sort->setThrowExceptionOnBadDataType(false);
|
$sort->setThrowExceptionOnBadDataType(false);
|
||||||
$filter->setThrowExceptionOnBadDataType(false);
|
$filter->setThrowExceptionOnBadDataType(false);
|
||||||
$pagination->setThrowExceptionOnBadDataType(false);
|
$pagination->setThrowExceptionOnBadDataType(false);
|
||||||
|
@ -45,7 +45,7 @@ class GridFieldConfig_RelationEditor extends GridFieldConfig
|
|||||||
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
|
$this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage));
|
||||||
$this->addComponent(GridFieldDetailForm::create());
|
$this->addComponent(GridFieldDetailForm::create());
|
||||||
|
|
||||||
Deprecation::withNoReplacement(function () use ($sort, $filter, $pagination) {
|
Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) {
|
||||||
$sort->setThrowExceptionOnBadDataType(false);
|
$sort->setThrowExceptionOnBadDataType(false);
|
||||||
$filter->setThrowExceptionOnBadDataType(false);
|
$filter->setThrowExceptionOnBadDataType(false);
|
||||||
$pagination->setThrowExceptionOnBadDataType(false);
|
$pagination->setThrowExceptionOnBadDataType(false);
|
||||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\Logging;
|
|||||||
|
|
||||||
use Monolog\Formatter\FormatterInterface;
|
use Monolog\Formatter\FormatterInterface;
|
||||||
use Monolog\Handler\AbstractProcessingHandler;
|
use Monolog\Handler\AbstractProcessingHandler;
|
||||||
|
use Monolog\Level;
|
||||||
use Monolog\LogRecord;
|
use Monolog\LogRecord;
|
||||||
use SilverStripe\Control\Controller;
|
use SilverStripe\Control\Controller;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
@ -34,10 +35,10 @@ class HTTPOutputHandler extends AbstractProcessingHandler
|
|||||||
*/
|
*/
|
||||||
private $cliFormatter = null;
|
private $cliFormatter = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct($level, $bubble);
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be renamed to ErrorOutputHandler',
|
'Will be renamed to ErrorOutputHandler',
|
||||||
|
@ -720,7 +720,7 @@ class ArrayList extends ModelData implements SS_List, Filterable, Sortable, Limi
|
|||||||
|
|
||||||
// Apply default case sensitivity for backwards compatability
|
// Apply default case sensitivity for backwards compatability
|
||||||
if (!str_contains($filterKey, ':case') && !str_contains($filterKey, ':nocase')) {
|
if (!str_contains($filterKey, ':case') && !str_contains($filterKey, ':nocase')) {
|
||||||
$caseSensitive = Deprecation::withNoReplacement(fn() => static::config()->get('default_case_sensitive'));
|
$caseSensitive = Deprecation::withSuppressedNotice(fn() => static::config()->get('default_case_sensitive'));
|
||||||
if ($caseSensitive && in_array('case', $searchFilter->getSupportedModifiers())) {
|
if ($caseSensitive && in_array('case', $searchFilter->getSupportedModifiers())) {
|
||||||
$searchFilter->setModifiers($searchFilter->getModifiers() + ['case']);
|
$searchFilter->setModifiers($searchFilter->getModifiers() + ['case']);
|
||||||
} elseif (!$caseSensitive && in_array('nocase', $searchFilter->getSupportedModifiers())) {
|
} elseif (!$caseSensitive && in_array('nocase', $searchFilter->getSupportedModifiers())) {
|
||||||
|
@ -6,6 +6,7 @@ use mysqli;
|
|||||||
use mysqli_sql_exception;
|
use mysqli_sql_exception;
|
||||||
use mysqli_stmt;
|
use mysqli_stmt;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
|
use SilverStripe\Core\Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connector for MySQL using the MySQLi method
|
* Connector for MySQL using the MySQLi method
|
||||||
@ -81,15 +82,21 @@ class MySQLiConnector extends DBConnector
|
|||||||
// Connection charset and collation
|
// Connection charset and collation
|
||||||
$connCharset = Config::inst()->get(MySQLDatabase::class, 'connection_charset');
|
$connCharset = Config::inst()->get(MySQLDatabase::class, 'connection_charset');
|
||||||
$connCollation = Config::inst()->get(MySQLDatabase::class, 'connection_collation');
|
$connCollation = Config::inst()->get(MySQLDatabase::class, 'connection_collation');
|
||||||
|
$socket = Environment::getEnv('SS_DATABASE_SOCKET');
|
||||||
|
$flags = Environment::getEnv('SS_DATABASE_FLAGS');
|
||||||
|
|
||||||
|
$flags = $flags ? array_reduce(explode(',', $flags), function ($carry, $item) {
|
||||||
|
$item = trim($item);
|
||||||
|
return $carry | constant($item);
|
||||||
|
}, 0) : $flags;
|
||||||
|
|
||||||
$this->dbConn = mysqli_init();
|
$this->dbConn = mysqli_init();
|
||||||
|
|
||||||
// Use native types (MysqlND only)
|
// Use native types (MysqlND only)
|
||||||
if (defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
|
if (defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
|
||||||
$this->dbConn->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true);
|
$this->dbConn->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, true);
|
||||||
|
|
||||||
// The alternative is not ideal, throw a notice-level error
|
|
||||||
} else {
|
} else {
|
||||||
|
// The alternative is not ideal, throw a notice-level error
|
||||||
user_error(
|
user_error(
|
||||||
'mysqlnd PHP library is not available, numeric values will be fetched from the DB as strings',
|
'mysqlnd PHP library is not available, numeric values will be fetched from the DB as strings',
|
||||||
E_USER_NOTICE
|
E_USER_NOTICE
|
||||||
@ -117,7 +124,9 @@ class MySQLiConnector extends DBConnector
|
|||||||
$parameters['username'],
|
$parameters['username'],
|
||||||
$parameters['password'],
|
$parameters['password'],
|
||||||
$selectedDB,
|
$selectedDB,
|
||||||
!empty($parameters['port']) ? $parameters['port'] : ini_get("mysqli.default_port")
|
!empty($parameters['port']) ? $parameters['port'] : ini_get("mysqli.default_port"),
|
||||||
|
$socket ?? null,
|
||||||
|
$flags ?? 0
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->dbConn->connect_error) {
|
if ($this->dbConn->connect_error) {
|
||||||
@ -126,8 +135,8 @@ class MySQLiConnector extends DBConnector
|
|||||||
|
|
||||||
// Set charset and collation if given and not null. Can explicitly set to empty string to omit
|
// Set charset and collation if given and not null. Can explicitly set to empty string to omit
|
||||||
$charset = isset($parameters['charset'])
|
$charset = isset($parameters['charset'])
|
||||||
? $parameters['charset']
|
? $parameters['charset']
|
||||||
: $connCharset;
|
: $connCharset;
|
||||||
|
|
||||||
if (!empty($charset)) {
|
if (!empty($charset)) {
|
||||||
$this->dbConn->set_charset($charset);
|
$this->dbConn->set_charset($charset);
|
||||||
|
@ -1982,7 +1982,7 @@ class DataObject extends ModelData implements DataObjectInterface, i18nEntityPro
|
|||||||
if ($details['polymorphic']) {
|
if ($details['polymorphic']) {
|
||||||
$result = PolymorphicHasManyList::create($componentClass, $details['joinField'], static::class);
|
$result = PolymorphicHasManyList::create($componentClass, $details['joinField'], static::class);
|
||||||
if ($details['needsRelation']) {
|
if ($details['needsRelation']) {
|
||||||
Deprecation::withNoReplacement(fn () => $result->setForeignRelation($componentName));
|
Deprecation::withSuppressedNotice(fn () => $result->setForeignRelation($componentName));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = HasManyList::create($componentClass, $details['joinField']);
|
$result = HasManyList::create($componentClass, $details['joinField']);
|
||||||
|
@ -67,7 +67,7 @@ class DatabaseAdmin extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be replaced with SilverStripe\Dev\Command\DbBuild',
|
'Will be replaced with SilverStripe\Dev\Command\DbBuild',
|
||||||
@ -213,7 +213,7 @@ class DatabaseAdmin extends Controller
|
|||||||
*/
|
*/
|
||||||
public static function lastBuilt()
|
public static function lastBuilt()
|
||||||
{
|
{
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'5.4.0',
|
'5.4.0',
|
||||||
'Will be replaced with SilverStripe\Dev\Command\DbBuild::lastBuilt()'
|
'Will be replaced with SilverStripe\Dev\Command\DbBuild::lastBuilt()'
|
||||||
|
@ -176,7 +176,7 @@ class CookieAuthenticationHandler implements AuthenticationHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Renew the token
|
// Renew the token
|
||||||
Deprecation::withNoReplacement(fn() => $rememberLoginHash->renew());
|
Deprecation::withSuppressedNotice(fn() => $rememberLoginHash->renew());
|
||||||
|
|
||||||
// Send the new token to the client if it was changed
|
// Send the new token to the client if it was changed
|
||||||
if ($rememberLoginHash->getToken()) {
|
if ($rememberLoginHash->getToken()) {
|
||||||
|
@ -116,72 +116,72 @@ class DeprecationTest extends SapphireTest
|
|||||||
Deprecation::outputNotices();
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithNoReplacementDefault()
|
public function testwithSuppressedNoticeDefault()
|
||||||
{
|
{
|
||||||
Deprecation::enable();
|
Deprecation::enable();
|
||||||
$ret = Deprecation::withNoReplacement(function () {
|
$ret = Deprecation::withSuppressedNotice(function () {
|
||||||
return $this->myDeprecatedMethod();
|
return $this->myDeprecatedMethod();
|
||||||
});
|
});
|
||||||
$this->assertSame('abc', $ret);
|
$this->assertSame('abc', $ret);
|
||||||
Deprecation::outputNotices();
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithNoReplacementTrue()
|
public function testwithSuppressedNoticeTrue()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
||||||
'My message.',
|
'My message.',
|
||||||
'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrue.'
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testwithSuppressedNoticeTrue.'
|
||||||
]);
|
]);
|
||||||
$this->expectException(DeprecationTestException::class);
|
$this->expectException(DeprecationTestException::class);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
Deprecation::enable(true);
|
Deprecation::enable(true);
|
||||||
$ret = Deprecation::withNoReplacement(function () {
|
$ret = Deprecation::withSuppressedNotice(function () {
|
||||||
return $this->myDeprecatedMethod();
|
return $this->myDeprecatedMethod();
|
||||||
});
|
});
|
||||||
$this->assertSame('abc', $ret);
|
$this->assertSame('abc', $ret);
|
||||||
Deprecation::outputNotices();
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWithNoReplacementTrueCallUserFunc()
|
public function testwithSuppressedNoticeTrueCallUserFunc()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
||||||
'My message.',
|
'My message.',
|
||||||
'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrueCallUserFunc.'
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testwithSuppressedNoticeTrueCallUserFunc.'
|
||||||
]);
|
]);
|
||||||
$this->expectException(DeprecationTestException::class);
|
$this->expectException(DeprecationTestException::class);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
Deprecation::enable(true);
|
Deprecation::enable(true);
|
||||||
$ret = Deprecation::withNoReplacement(function () {
|
$ret = Deprecation::withSuppressedNotice(function () {
|
||||||
return call_user_func([$this, 'myDeprecatedMethod']);
|
return call_user_func([$this, 'myDeprecatedMethod']);
|
||||||
});
|
});
|
||||||
$this->assertSame('abc', $ret);
|
$this->assertSame('abc', $ret);
|
||||||
Deprecation::outputNotices();
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNoticeWithNoReplacementTrue()
|
public function testNoticewithSuppressedNoticeTrue()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
'SilverStripe\Dev\Tests\DeprecationTest->testNoticeWithNoReplacementTrue is deprecated.',
|
'SilverStripe\Dev\Tests\DeprecationTest->testNoticewithSuppressedNoticeTrue is deprecated.',
|
||||||
'My message.',
|
'My message.',
|
||||||
'Called from PHPUnit\Framework\TestCase->runTest.'
|
'Called from PHPUnit\Framework\TestCase->runTest.'
|
||||||
]);
|
]);
|
||||||
$this->expectException(DeprecationTestException::class);
|
$this->expectException(DeprecationTestException::class);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
Deprecation::enable(true);
|
Deprecation::enable(true);
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice('123', 'My message.');
|
Deprecation::notice('123', 'My message.');
|
||||||
});
|
});
|
||||||
Deprecation::outputNotices();
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClassWithNoReplacement()
|
public function testClasswithSuppressedNotice()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.',
|
'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.',
|
||||||
'Some class message.',
|
'Some class message.',
|
||||||
'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithNoReplacement.'
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testClasswithSuppressedNotice.'
|
||||||
]);
|
]);
|
||||||
$this->expectException(DeprecationTestException::class);
|
$this->expectException(DeprecationTestException::class);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
@ -193,12 +193,12 @@ class DeprecationTest extends SapphireTest
|
|||||||
Deprecation::outputNotices();
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClassWithInjectorWithNoReplacement()
|
public function testClassWithInjectorwithSuppressedNotice()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.',
|
'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.',
|
||||||
'Some class message.',
|
'Some class message.',
|
||||||
'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithInjectorWithNoReplacement.'
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithInjectorwithSuppressedNotice.'
|
||||||
]);
|
]);
|
||||||
$this->expectException(DeprecationTestException::class);
|
$this->expectException(DeprecationTestException::class);
|
||||||
$this->expectExceptionMessage($message);
|
$this->expectExceptionMessage($message);
|
||||||
|
@ -11,7 +11,7 @@ class DeprecationTestObject extends DataObject implements TestOnly
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
Deprecation::withNoReplacement(function () {
|
Deprecation::withSuppressedNotice(function () {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'1.2.3',
|
'1.2.3',
|
||||||
'Some class message',
|
'Some class message',
|
||||||
|
@ -156,7 +156,7 @@ class PasswordEncryptorTest extends SapphireTest
|
|||||||
'encryptors',
|
'encryptors',
|
||||||
['test_sha1legacy' => [PasswordEncryptor_LegacyPHPHash::class => 'sha1']]
|
['test_sha1legacy' => [PasswordEncryptor_LegacyPHPHash::class => 'sha1']]
|
||||||
);
|
);
|
||||||
$e = Deprecation::withNoReplacement(fn() => PasswordEncryptor::create_for_algorithm('test_sha1legacy'));
|
$e = Deprecation::withSuppressedNotice(fn() => PasswordEncryptor::create_for_algorithm('test_sha1legacy'));
|
||||||
// precomputed hashes for 'mypassword' from different architectures
|
// precomputed hashes for 'mypassword' from different architectures
|
||||||
$amdHash = 'h1fj0a6m4o6k0sosks88oo08ko4gc4s';
|
$amdHash = 'h1fj0a6m4o6k0sosks88oo08ko4gc4s';
|
||||||
$intelHash = 'h1fj0a6m4o0g04ocg00o4kwoc4wowws';
|
$intelHash = 'h1fj0a6m4o0g04ocg00o4kwoc4wowws';
|
||||||
|
@ -111,7 +111,7 @@ class RememberLoginHashTest extends SapphireTest
|
|||||||
|
|
||||||
$member = $this->objFromFixture(Member::class, 'main');
|
$member = $this->objFromFixture(Member::class, 'main');
|
||||||
|
|
||||||
Deprecation::withNoReplacement(
|
Deprecation::withSuppressedNotice(
|
||||||
fn() => RememberLoginHash::config()->set('replace_token_during_session_renewal', $replaceToken)
|
fn() => RememberLoginHash::config()->set('replace_token_during_session_renewal', $replaceToken)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ class RememberLoginHashTest extends SapphireTest
|
|||||||
// Fetch the token from the DB - otherwise we still have the token from when this was originally created
|
// Fetch the token from the DB - otherwise we still have the token from when this was originally created
|
||||||
$storedHash = RememberLoginHash::get()->find('ID', $hash->ID);
|
$storedHash = RememberLoginHash::get()->find('ID', $hash->ID);
|
||||||
|
|
||||||
Deprecation::withNoReplacement(fn() => $storedHash->renew());
|
Deprecation::withSuppressedNotice(fn() => $storedHash->renew());
|
||||||
|
|
||||||
if ($replaceToken) {
|
if ($replaceToken) {
|
||||||
$this->assertNotEquals($oldToken, $storedHash->getToken());
|
$this->assertNotEquals($oldToken, $storedHash->getToken());
|
||||||
|
Loading…
Reference in New Issue
Block a user