mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10565 from creative-commoners/pulls/4/stop-depr
API Stop using deprecated API
This commit is contained in:
commit
ad116c63e6
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Dev\Deprecation;
|
|
||||||
use SilverStripe\View\Shortcodes\EmbedShortcodeProvider;
|
use SilverStripe\View\Shortcodes\EmbedShortcodeProvider;
|
||||||
use SilverStripe\View\Parsers\ShortcodeParser;
|
use SilverStripe\View\Parsers\ShortcodeParser;
|
||||||
|
|
||||||
@ -14,6 +13,3 @@ use SilverStripe\View\Parsers\ShortcodeParser;
|
|||||||
|
|
||||||
ShortcodeParser::get('default')
|
ShortcodeParser::get('default')
|
||||||
->register('embed', [EmbedShortcodeProvider::class, 'handle_shortcode']);
|
->register('embed', [EmbedShortcodeProvider::class, 'handle_shortcode']);
|
||||||
|
|
||||||
// Set to 5.0.0 to show APIs marked for removal at that version
|
|
||||||
Deprecation::notification_version('4.0.0');
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
Name: basei18n
|
Name: basei18n
|
||||||
Before: '#defaulti18n'
|
Before: '#defaulti18n'
|
||||||
---
|
---
|
||||||
SilverStripe\i18n\Data\Sources:
|
SilverStripe\Core\Manifest\ModuleManifest:
|
||||||
module_priority:
|
module_priority:
|
||||||
- silverstripe\admin
|
- silverstripe\admin
|
||||||
- silverstripe\framework
|
- silverstripe\framework
|
||||||
---
|
---
|
||||||
Name: defaulti18n
|
Name: defaulti18n
|
||||||
---
|
---
|
||||||
SilverStripe\i18n\Data\Sources:
|
SilverStripe\Core\Manifest\ModuleManifest:
|
||||||
module_priority:
|
module_priority:
|
||||||
- other_modules
|
- other_modules
|
||||||
---
|
---
|
||||||
|
@ -200,12 +200,9 @@ class CookieJar implements Cookie_Backend
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the correct samesite value - Session cookies use a different configuration variable.
|
* Get the correct samesite value - Session cookies use a different configuration variable.
|
||||||
*
|
|
||||||
* @deprecated 4.12.0 The relevant methods will include a `$sameSite` parameter instead.
|
|
||||||
*/
|
*/
|
||||||
private function getSameSite(string $name): string
|
private function getSameSite(string $name): string
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'The relevant methods will include a `$sameSite` parameter instead.');
|
|
||||||
if ($name === session_name()) {
|
if ($name === session_name()) {
|
||||||
return Session::config()->get('cookie_samesite');
|
return Session::config()->get('cookie_samesite');
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ class Director implements TemplateGlobalProvider
|
|||||||
? $cookies
|
? $cookies
|
||||||
: Injector::inst()->createWithArgs(Cookie_Backend::class, [$cookies ?: []]);
|
: Injector::inst()->createWithArgs(Cookie_Backend::class, [$cookies ?: []]);
|
||||||
$newVars['_COOKIE'] = $cookieJar->getAll(false);
|
$newVars['_COOKIE'] = $cookieJar->getAll(false);
|
||||||
Cookie::config()->update('report_errors', false);
|
Cookie::config()->set('report_errors', false);
|
||||||
Injector::inst()->registerService($cookieJar, Cookie_Backend::class);
|
Injector::inst()->registerService($cookieJar, Cookie_Backend::class);
|
||||||
|
|
||||||
// Backup requirements
|
// Backup requirements
|
||||||
|
@ -268,7 +268,9 @@ class Email extends ViewableData
|
|||||||
$message = new Swift_Message(null, null, 'text/html', 'utf-8');
|
$message = new Swift_Message(null, null, 'text/html', 'utf-8');
|
||||||
// Set priority to fix PHP 8.1 SimpleMessage::getPriority() sscanf() null parameter
|
// Set priority to fix PHP 8.1 SimpleMessage::getPriority() sscanf() null parameter
|
||||||
$message->setPriority(Swift_Mime_SimpleMessage::PRIORITY_NORMAL);
|
$message->setPriority(Swift_Mime_SimpleMessage::PRIORITY_NORMAL);
|
||||||
|
Deprecation::withNoReplacement(function () use ($message) {
|
||||||
$this->setSwiftMessage($message);
|
$this->setSwiftMessage($message);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->swiftMessage;
|
return $this->swiftMessage;
|
||||||
@ -328,7 +330,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getFrom()
|
public function getFrom()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getFrom();
|
return $this->getSwiftMessage()->getFrom();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,8 +355,9 @@ class Email extends ViewableData
|
|||||||
public function setFrom($address, $name = null)
|
public function setFrom($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->setFrom($address, $name);
|
$this->getSwiftMessage()->setFrom($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,8 +369,9 @@ class Email extends ViewableData
|
|||||||
public function addFrom($address, $name = null)
|
public function addFrom($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->addFrom($address, $name);
|
$this->getSwiftMessage()->addFrom($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +380,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getSender()
|
public function getSender()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getSender();
|
return $this->getSwiftMessage()->getSender();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -385,8 +393,9 @@ class Email extends ViewableData
|
|||||||
public function setSender($address, $name = null)
|
public function setSender($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->setSender($address, $name);
|
$this->getSwiftMessage()->setSender($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +404,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getReturnPath()
|
public function getReturnPath()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getReturnPath();
|
return $this->getSwiftMessage()->getReturnPath();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -407,7 +418,9 @@ class Email extends ViewableData
|
|||||||
public function setReturnPath($address)
|
public function setReturnPath($address)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address) {
|
||||||
$this->getSwiftMessage()->setReturnPath($address);
|
$this->getSwiftMessage()->setReturnPath($address);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +429,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getTo()
|
public function getTo()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getTo();
|
return $this->getSwiftMessage()->getTo();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -432,8 +447,9 @@ class Email extends ViewableData
|
|||||||
public function setTo($address, $name = null)
|
public function setTo($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->setTo($address, $name);
|
$this->getSwiftMessage()->setTo($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,8 +461,9 @@ class Email extends ViewableData
|
|||||||
public function addTo($address, $name = null)
|
public function addTo($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->addTo($address, $name);
|
$this->getSwiftMessage()->addTo($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +472,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getCC()
|
public function getCC()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getCc();
|
return $this->getSwiftMessage()->getCc();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,8 +485,9 @@ class Email extends ViewableData
|
|||||||
public function setCC($address, $name = null)
|
public function setCC($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->setCc($address, $name);
|
$this->getSwiftMessage()->setCc($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,8 +499,9 @@ class Email extends ViewableData
|
|||||||
public function addCC($address, $name = null)
|
public function addCC($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->addCc($address, $name);
|
$this->getSwiftMessage()->addCc($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,7 +510,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getBCC()
|
public function getBCC()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getBcc();
|
return $this->getSwiftMessage()->getBcc();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -500,8 +523,9 @@ class Email extends ViewableData
|
|||||||
public function setBCC($address, $name = null)
|
public function setBCC($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->setBcc($address, $name);
|
$this->getSwiftMessage()->setBcc($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,8 +537,9 @@ class Email extends ViewableData
|
|||||||
public function addBCC($address, $name = null)
|
public function addBCC($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->addBcc($address, $name);
|
$this->getSwiftMessage()->addBcc($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +548,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getReplyTo()
|
public function getReplyTo()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getReplyTo();
|
return $this->getSwiftMessage()->getReplyTo();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -534,8 +561,9 @@ class Email extends ViewableData
|
|||||||
public function setReplyTo($address, $name = null)
|
public function setReplyTo($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->setReplyTo($address, $name);
|
$this->getSwiftMessage()->setReplyTo($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,8 +575,9 @@ class Email extends ViewableData
|
|||||||
public function addReplyTo($address, $name = null)
|
public function addReplyTo($address, $name = null)
|
||||||
{
|
{
|
||||||
$address = $this->sanitiseAddress($address);
|
$address = $this->sanitiseAddress($address);
|
||||||
|
Deprecation::withNoReplacement(function () use ($address, $name) {
|
||||||
$this->getSwiftMessage()->addReplyTo($address, $name);
|
$this->getSwiftMessage()->addReplyTo($address, $name);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,7 +586,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getSubject()
|
public function getSubject()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getSubject();
|
return $this->getSwiftMessage()->getSubject();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -566,8 +597,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function setSubject($subject)
|
public function setSubject($subject)
|
||||||
{
|
{
|
||||||
|
Deprecation::withNoReplacement(function () use ($subject) {
|
||||||
$this->getSwiftMessage()->setSubject($subject);
|
$this->getSwiftMessage()->setSubject($subject);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +608,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getPriority()
|
public function getPriority()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getPriority();
|
return $this->getSwiftMessage()->getPriority();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -585,8 +619,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function setPriority($priority)
|
public function setPriority($priority)
|
||||||
{
|
{
|
||||||
|
Deprecation::withNoReplacement(function () use ($priority) {
|
||||||
$this->getSwiftMessage()->setPriority($priority);
|
$this->getSwiftMessage()->setPriority($priority);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,8 +657,9 @@ class Email extends ViewableData
|
|||||||
if ($mime) {
|
if ($mime) {
|
||||||
$attachment->setContentType($mime);
|
$attachment->setContentType($mime);
|
||||||
}
|
}
|
||||||
|
Deprecation::withNoReplacement(function () use ($attachment) {
|
||||||
$this->getSwiftMessage()->attach($attachment);
|
$this->getSwiftMessage()->attach($attachment);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,8 +678,9 @@ class Email extends ViewableData
|
|||||||
public function setData($data)
|
public function setData($data)
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
$this->invalidateBody();
|
$this->invalidateBody();
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,9 +698,9 @@ class Email extends ViewableData
|
|||||||
} else {
|
} else {
|
||||||
$this->data->$name = $value;
|
$this->data->$name = $value;
|
||||||
}
|
}
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
$this->invalidateBody();
|
$this->invalidateBody();
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,9 +717,9 @@ class Email extends ViewableData
|
|||||||
} else {
|
} else {
|
||||||
$this->data->$name = null;
|
$this->data->$name = null;
|
||||||
}
|
}
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
$this->invalidateBody();
|
$this->invalidateBody();
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +728,9 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function getBody()
|
public function getBody()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
return $this->getSwiftMessage()->getBody();
|
return $this->getSwiftMessage()->getBody();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -700,6 +739,7 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function setBody($body)
|
public function setBody($body)
|
||||||
{
|
{
|
||||||
|
Deprecation::withNoReplacement(function () use ($body) {
|
||||||
$plainPart = $this->findPlainPart();
|
$plainPart = $this->findPlainPart();
|
||||||
if ($plainPart) {
|
if ($plainPart) {
|
||||||
$this->getSwiftMessage()->detach($plainPart);
|
$this->getSwiftMessage()->detach($plainPart);
|
||||||
@ -708,7 +748,7 @@ class Email extends ViewableData
|
|||||||
|
|
||||||
$body = HTTP::absoluteURLs($body);
|
$body = HTTP::absoluteURLs($body);
|
||||||
$this->getSwiftMessage()->setBody($body);
|
$this->getSwiftMessage()->setBody($body);
|
||||||
|
});
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,10 +786,11 @@ class Email extends ViewableData
|
|||||||
public function debug()
|
public function debug()
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
$this->render();
|
$this->render();
|
||||||
|
|
||||||
$class = static::class;
|
$class = static::class;
|
||||||
return "<h2>Email template {$class}:</h2>\n" . '<pre>' . $this->getSwiftMessage()->toString() . '</pre>';
|
return "<h2>Email template {$class}:</h2>\n" . '<pre>' . $this->getSwiftMessage()->toString() . '</pre>';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -854,6 +895,7 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function send()
|
public function send()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
if (!$this->getBody()) {
|
if (!$this->getBody()) {
|
||||||
$this->render();
|
$this->render();
|
||||||
}
|
}
|
||||||
@ -861,6 +903,7 @@ class Email extends ViewableData
|
|||||||
$this->generatePlainPartFromBody();
|
$this->generatePlainPartFromBody();
|
||||||
}
|
}
|
||||||
return Injector::inst()->get(Mailer::class)->send($this);
|
return Injector::inst()->get(Mailer::class)->send($this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -868,10 +911,12 @@ class Email extends ViewableData
|
|||||||
*/
|
*/
|
||||||
public function sendPlain()
|
public function sendPlain()
|
||||||
{
|
{
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
if (!$this->hasPlainPart()) {
|
if (!$this->hasPlainPart()) {
|
||||||
$this->render(true);
|
$this->render(true);
|
||||||
}
|
}
|
||||||
return Injector::inst()->get(Mailer::class)->send($this);
|
return Injector::inst()->get(Mailer::class)->send($this);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -884,8 +929,11 @@ class Email extends ViewableData
|
|||||||
public function render($plainOnly = false)
|
public function render($plainOnly = false)
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||||
|
return Deprecation::withNoReplacement(function () use ($plainOnly) {
|
||||||
if ($existingPlainPart = $this->findPlainPart()) {
|
$existingPlainPart = Deprecation::withNoReplacement(function () {
|
||||||
|
return $this->findPlainPart();
|
||||||
|
});
|
||||||
|
if ($existingPlainPart) {
|
||||||
$this->getSwiftMessage()->detach($existingPlainPart);
|
$this->getSwiftMessage()->detach($existingPlainPart);
|
||||||
}
|
}
|
||||||
unset($existingPlainPart);
|
unset($existingPlainPart);
|
||||||
@ -944,8 +992,8 @@ class Email extends ViewableData
|
|||||||
$this->getSwiftMessage()->setContentType('text/plain');
|
$this->getSwiftMessage()->setContentType('text/plain');
|
||||||
$this->getSwiftMessage()->setCharset('utf-8');
|
$this->getSwiftMessage()->setCharset('utf-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -956,12 +1004,14 @@ class Email extends ViewableData
|
|||||||
public function findPlainPart()
|
public function findPlainPart()
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
foreach ($this->getSwiftMessage()->getChildren() as $child) {
|
foreach ($this->getSwiftMessage()->getChildren() as $child) {
|
||||||
if ($child instanceof Swift_MimePart && $child->getContentType() == 'text/plain') {
|
if ($child instanceof Swift_MimePart && $child->getContentType() == 'text/plain') {
|
||||||
return $child;
|
return $child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -972,10 +1022,12 @@ class Email extends ViewableData
|
|||||||
public function hasPlainPart()
|
public function hasPlainPart()
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
if ($this->getSwiftMessage()->getContentType() === 'text/plain') {
|
if ($this->getSwiftMessage()->getContentType() === 'text/plain') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (bool) $this->findPlainPart();
|
return (bool) $this->findPlainPart();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -988,6 +1040,7 @@ class Email extends ViewableData
|
|||||||
public function generatePlainPartFromBody()
|
public function generatePlainPartFromBody()
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it');
|
||||||
|
return Deprecation::withNoReplacement(function () {
|
||||||
$plainPart = $this->findPlainPart();
|
$plainPart = $this->findPlainPart();
|
||||||
if ($plainPart) {
|
if ($plainPart) {
|
||||||
$this->getSwiftMessage()->detach($plainPart);
|
$this->getSwiftMessage()->detach($plainPart);
|
||||||
@ -999,7 +1052,7 @@ class Email extends ViewableData
|
|||||||
'text/plain',
|
'text/plain',
|
||||||
'utf-8'
|
'utf-8'
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,9 @@ class SwiftMailer implements Mailer
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
|
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function send($message)
|
public function send($message)
|
||||||
|
@ -11,7 +11,9 @@ class SwiftPlugin implements \Swift_Events_SendListener
|
|||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
|
Deprecation::notice('4.12.0', 'Will be replaced with symfony/mailer', Deprecation::SCOPE_CLASS);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +126,7 @@ class HTTP
|
|||||||
if (preg_match('/^\w+:/', $url ?? '')) {
|
if (preg_match('/^\w+:/', $url ?? '')) {
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
return Director::absoluteURL($url, true);
|
return Director::absoluteURL($url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,6 +474,8 @@ class HTTP
|
|||||||
* Ensure that all deprecated HTTP cache settings are respected
|
* Ensure that all deprecated HTTP cache settings are respected
|
||||||
*
|
*
|
||||||
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware instead
|
* @deprecated 4.2.0 Use HTTPCacheControlMiddleware instead
|
||||||
|
* Simply delete this method in CMS 5 and the calls to it from HTTPCacheControlMiddleware
|
||||||
|
*
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
* @param HTTPRequest $request
|
* @param HTTPRequest $request
|
||||||
* @param HTTPResponse $response
|
* @param HTTPResponse $response
|
||||||
@ -491,32 +493,32 @@ class HTTP
|
|||||||
|
|
||||||
// if http caching is disabled by config, disable it - used on dev environments due to frequently changing
|
// if http caching is disabled by config, disable it - used on dev environments due to frequently changing
|
||||||
// templates and other data. will be overridden by forced publicCache(true) or privateCache(true) calls
|
// templates and other data. will be overridden by forced publicCache(true) or privateCache(true) calls
|
||||||
|
Deprecation::withNoReplacement(function () use ($config, $cacheControlMiddleware) {
|
||||||
if ($config->get('disable_http_cache')) {
|
if ($config->get('disable_http_cache')) {
|
||||||
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware.defaultState/.defaultForcingLevel instead');
|
|
||||||
$cacheControlMiddleware->disableCache();
|
$cacheControlMiddleware->disableCache();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// if no caching ajax requests, disable ajax if is ajax request
|
// if no caching ajax requests, disable ajax if is ajax request
|
||||||
|
Deprecation::withNoReplacement(function () use ($config, $cacheControlMiddleware) {
|
||||||
if (!$config->get('cache_ajax_requests') && Director::is_ajax()) {
|
if (!$config->get('cache_ajax_requests') && Director::is_ajax()) {
|
||||||
Deprecation::notice(
|
|
||||||
'5.0',
|
|
||||||
'HTTP.cache_ajax_requests config is deprecated. Use HTTPCacheControlMiddleware::disableCache() instead'
|
|
||||||
);
|
|
||||||
$cacheControlMiddleware->disableCache();
|
$cacheControlMiddleware->disableCache();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Pass vary to middleware
|
// Pass vary to middleware
|
||||||
$configVary = $config->get('vary');
|
$configVary = Deprecation::withNoReplacement(function () use ($config) {
|
||||||
|
return $config->get('vary');
|
||||||
|
});
|
||||||
if ($configVary) {
|
if ($configVary) {
|
||||||
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware.defaultVary instead');
|
|
||||||
$cacheControlMiddleware->addVary($configVary);
|
$cacheControlMiddleware->addVary($configVary);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass cache_control to middleware
|
// Pass cache_control to middleware
|
||||||
$configCacheControl = $config->get('cache_control');
|
$configCacheControl = Deprecation::withNoReplacement(function () use ($config) {
|
||||||
|
return $config->get('cache_control');
|
||||||
|
});
|
||||||
if ($configCacheControl) {
|
if ($configCacheControl) {
|
||||||
Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware API instead');
|
|
||||||
|
|
||||||
$supportedDirectives = ['max-age', 'no-cache', 'no-store', 'must-revalidate'];
|
$supportedDirectives = ['max-age', 'no-cache', 'no-store', 'must-revalidate'];
|
||||||
if ($foundUnsupported = array_diff(array_keys($configCacheControl ?? []), $supportedDirectives)) {
|
if ($foundUnsupported = array_diff(array_keys($configCacheControl ?? []), $supportedDirectives)) {
|
||||||
throw new \LogicException(
|
throw new \LogicException(
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Control\Middleware;
|
namespace SilverStripe\Control\Middleware;
|
||||||
|
|
||||||
use SilverStripe\Control\Director;
|
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
|
use SilverStripe\Core\BaseKernel;
|
||||||
use SilverStripe\Core\ClassInfo;
|
use SilverStripe\Core\ClassInfo;
|
||||||
use SilverStripe\Core\Flushable;
|
use SilverStripe\Core\Flushable;
|
||||||
|
use SilverStripe\Core\Injector\Injector;
|
||||||
|
use SilverStripe\Core\Kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers a call to flush() on all implementors of Flushable.
|
* Triggers a call to flush() on all implementors of Flushable.
|
||||||
@ -14,7 +16,9 @@ class FlushMiddleware implements HTTPMiddleware
|
|||||||
{
|
{
|
||||||
public function process(HTTPRequest $request, callable $delegate)
|
public function process(HTTPRequest $request, callable $delegate)
|
||||||
{
|
{
|
||||||
if (Director::isManifestFlushed()) {
|
/** @var BaseKernel $kernel */
|
||||||
|
$kernel = Injector::inst()->get(Kernel::class);
|
||||||
|
if ((method_exists($kernel, 'isFlushed') && $kernel->isFlushed())) {
|
||||||
// Disable cache when flushing
|
// Disable cache when flushing
|
||||||
HTTPCacheControlMiddleware::singleton()->disableCache(true);
|
HTTPCacheControlMiddleware::singleton()->disableCache(true);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ use SilverStripe\Core\Injector\Injectable;
|
|||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Core\Resettable;
|
use SilverStripe\Core\Resettable;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
||||||
{
|
{
|
||||||
@ -51,7 +52,9 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable
|
|||||||
$this->augmentState($request, $response);
|
$this->augmentState($request, $response);
|
||||||
|
|
||||||
// Update state based on deprecated HTTP settings
|
// Update state based on deprecated HTTP settings
|
||||||
|
Deprecation::withNoReplacement(function () use ($request, $response) {
|
||||||
HTTP::augmentState($request, $response);
|
HTTP::augmentState($request, $response);
|
||||||
|
});
|
||||||
|
|
||||||
// Add all headers to this response object
|
// Add all headers to this response object
|
||||||
$this->applyToResponse($response);
|
$this->applyToResponse($response);
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Control\Middleware\URLSpecialsMiddleware;
|
namespace SilverStripe\Control\Middleware\URLSpecialsMiddleware;
|
||||||
|
|
||||||
|
use SilverStripe\Core\BaseKernel;
|
||||||
use SilverStripe\Core\Kernel;
|
use SilverStripe\Core\Kernel;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Core\Startup\ScheduledFlushDiscoverer;
|
use SilverStripe\Core\Startup\ScheduledFlushDiscoverer;
|
||||||
use SilverStripe\Control\Director;
|
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,11 +30,12 @@ trait FlushScheduler
|
|||||||
{
|
{
|
||||||
$flush = array_key_exists('flush', $request->getVars() ?? []) || ($request->getURL() === 'dev/build');
|
$flush = array_key_exists('flush', $request->getVars() ?? []) || ($request->getURL() === 'dev/build');
|
||||||
|
|
||||||
if (!$flush || Director::isManifestFlushed()) {
|
/** @var BaseKernel $kernel */
|
||||||
|
$kernel = Injector::inst()->get(Kernel::class);
|
||||||
|
if (!$flush || (method_exists($kernel, 'isFlushed') && $kernel->isFlushed())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel = Injector::inst()->get(Kernel::class);
|
|
||||||
ScheduledFlushDiscoverer::scheduleFlush($kernel);
|
ScheduledFlushDiscoverer::scheduleFlush($kernel);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -222,7 +222,7 @@ class RSSFeed extends ViewableData
|
|||||||
public function outputToBrowser()
|
public function outputToBrowser()
|
||||||
{
|
{
|
||||||
$prevState = SSViewer::config()->uninherited('source_file_comments');
|
$prevState = SSViewer::config()->uninherited('source_file_comments');
|
||||||
SSViewer::config()->update('source_file_comments', false);
|
SSViewer::config()->set('source_file_comments', false);
|
||||||
|
|
||||||
$response = Controller::curr()->getResponse();
|
$response = Controller::curr()->getResponse();
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ class RSSFeed extends ViewableData
|
|||||||
|
|
||||||
$response->addHeader("Content-Type", "application/rss+xml; charset=utf-8");
|
$response->addHeader("Content-Type", "application/rss+xml; charset=utf-8");
|
||||||
|
|
||||||
SSViewer::config()->update('source_file_comments', $prevState);
|
SSViewer::config()->set('source_file_comments', $prevState);
|
||||||
return $this->renderWith($this->getTemplates());
|
return $this->renderWith($this->getTemplates());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,9 @@ class RequestProcessor implements HTTPMiddleware
|
|||||||
*/
|
*/
|
||||||
public function __construct($filters = [])
|
public function __construct($filters = [])
|
||||||
{
|
{
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
Deprecation::notice('4.0.1', 'Use HTTPMiddleware directly instead.', Deprecation::SCOPE_CLASS);
|
Deprecation::notice('4.0.1', 'Use HTTPMiddleware directly instead.', Deprecation::SCOPE_CLASS);
|
||||||
|
});
|
||||||
$this->filters = $filters;
|
$this->filters = $filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,13 +586,11 @@ class Session
|
|||||||
* Recursively apply the changes represented in $data to $dest.
|
* Recursively apply the changes represented in $data to $dest.
|
||||||
* Used to update $_SESSION
|
* Used to update $_SESSION
|
||||||
*
|
*
|
||||||
* @deprecated 4.1.0 Use recursivelyApplyChanges() instead
|
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @param array $dest
|
* @param array $dest
|
||||||
*/
|
*/
|
||||||
protected function recursivelyApply($data, &$dest)
|
protected function recursivelyApply($data, &$dest)
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.1.0', 'Use recursivelyApplyChanges() instead');
|
|
||||||
foreach ($data as $k => $v) {
|
foreach ($data as $k => $v) {
|
||||||
if (is_array($v)) {
|
if (is_array($v)) {
|
||||||
if (!isset($dest[$k]) || !is_array($dest[$k])) {
|
if (!isset($dest[$k]) || !is_array($dest[$k])) {
|
||||||
|
@ -82,7 +82,10 @@ class SimpleResourceURLGenerator implements ResourceURLGenerator
|
|||||||
// Determine lookup mechanism based on existence of public/ folder.
|
// Determine lookup mechanism based on existence of public/ folder.
|
||||||
// From 5.0 onwards only resolvePublicResource() will be used.
|
// From 5.0 onwards only resolvePublicResource() will be used.
|
||||||
if (!Director::publicDir()) {
|
if (!Director::publicDir()) {
|
||||||
list($exists, $absolutePath, $relativePath) = $this->resolveUnsecuredResource($relativePath);
|
$ret = Deprecation::withNoReplacement(function () use ($relativePath) {
|
||||||
|
return $this->resolveUnsecuredResource($relativePath);
|
||||||
|
});
|
||||||
|
list($exists, $absolutePath, $relativePath) = $ret;
|
||||||
} else {
|
} else {
|
||||||
list($exists, $absolutePath, $relativePath) = $this->resolvePublicResource($relativePath);
|
list($exists, $absolutePath, $relativePath) = $this->resolvePublicResource($relativePath);
|
||||||
}
|
}
|
||||||
|
@ -180,18 +180,24 @@ abstract class BaseKernel implements Kernel
|
|||||||
protected function bootManifests($flush)
|
protected function bootManifests($flush)
|
||||||
{
|
{
|
||||||
// Setup autoloader
|
// Setup autoloader
|
||||||
|
$ignoredCIConfigs = Deprecation::withNoReplacement(function () {
|
||||||
|
return $this->getIgnoredCIConfigs();
|
||||||
|
});
|
||||||
|
|
||||||
|
Deprecation::withNoReplacement(function () use ($flush, $ignoredCIConfigs) {
|
||||||
$this->getClassLoader()->init(
|
$this->getClassLoader()->init(
|
||||||
$this->getIncludeTests(),
|
$this->getIncludeTests(),
|
||||||
$flush,
|
$flush,
|
||||||
$this->getIgnoredCIConfigs()
|
$ignoredCIConfigs
|
||||||
);
|
);
|
||||||
|
|
||||||
// Find modules
|
// Find modules
|
||||||
$this->getModuleLoader()->init(
|
$this->getModuleLoader()->init(
|
||||||
$this->getIncludeTests(),
|
$this->getIncludeTests(),
|
||||||
$flush,
|
$flush,
|
||||||
$this->getIgnoredCIConfigs()
|
$ignoredCIConfigs
|
||||||
);
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// Flush config
|
// Flush config
|
||||||
if ($flush) {
|
if ($flush) {
|
||||||
@ -209,11 +215,13 @@ abstract class BaseKernel implements Kernel
|
|||||||
$defaultSet->setProject(
|
$defaultSet->setProject(
|
||||||
ModuleManifest::config()->get('project')
|
ModuleManifest::config()->get('project')
|
||||||
);
|
);
|
||||||
|
Deprecation::withNoReplacement(function () use ($defaultSet, $flush, $ignoredCIConfigs) {
|
||||||
$defaultSet->init(
|
$defaultSet->init(
|
||||||
$this->getIncludeTests(),
|
$this->getIncludeTests(),
|
||||||
$flush,
|
$flush,
|
||||||
$this->getIgnoredCIConfigs()
|
$ignoredCIConfigs
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,12 +267,9 @@ abstract class BaseKernel implements Kernel
|
|||||||
* Get the environment type
|
* Get the environment type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
|
||||||
* @deprecated 4.12.0 Use Director::get_environment_type() instead
|
|
||||||
*/
|
*/
|
||||||
public function getEnvironment()
|
public function getEnvironment()
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'Use Director::get_environment_type() instead');
|
|
||||||
// Check set
|
// Check set
|
||||||
if ($this->enviroment) {
|
if ($this->enviroment) {
|
||||||
return $this->enviroment;
|
return $this->enviroment;
|
||||||
@ -288,12 +293,9 @@ abstract class BaseKernel implements Kernel
|
|||||||
* Check or update any temporary environment specified in the session.
|
* Check or update any temporary environment specified in the session.
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*
|
|
||||||
* @deprecated 4.12.0 Use Director::get_session_environment_type() instead
|
|
||||||
*/
|
*/
|
||||||
protected function sessionEnvironment()
|
protected function sessionEnvironment()
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.12.0', 'Use Director::get_session_environment_type() instead');
|
|
||||||
if (!$this->booted) {
|
if (!$this->booted) {
|
||||||
// session is not initialyzed yet, neither is manifest
|
// session is not initialyzed yet, neither is manifest
|
||||||
return null;
|
return null;
|
||||||
|
@ -275,7 +275,7 @@ class Convert
|
|||||||
/**
|
/**
|
||||||
* Convert a JSON string into an array.
|
* Convert a JSON string into an array.
|
||||||
*
|
*
|
||||||
* @deprecated 4.4.0 Use json_decode() instead
|
* @deprecated 4.4.0 Use json_decode($val, true) instead
|
||||||
* @param string $val JSON string to convert
|
* @param string $val JSON string to convert
|
||||||
* @return array|boolean
|
* @return array|boolean
|
||||||
*/
|
*/
|
||||||
|
@ -131,7 +131,9 @@ class ClassLoader
|
|||||||
foreach ($this->manifests as $manifest) {
|
foreach ($this->manifests as $manifest) {
|
||||||
/** @var ClassManifest $instance */
|
/** @var ClassManifest $instance */
|
||||||
$instance = $manifest['instance'];
|
$instance = $manifest['instance'];
|
||||||
|
Deprecation::withNoReplacement(function () use ($instance, $includeTests, $forceRegen, $ignoredCIConfigs) {
|
||||||
$instance->init($includeTests, $forceRegen, $ignoredCIConfigs);
|
$instance->init($includeTests, $forceRegen, $ignoredCIConfigs);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerAutoloader();
|
$this->registerAutoloader();
|
||||||
|
@ -297,7 +297,9 @@ class ClassManifest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build
|
// Build
|
||||||
|
Deprecation::withNoReplacement(function () use ($includeTests, $ignoredCIConfigs) {
|
||||||
$this->regenerate($includeTests, $ignoredCIConfigs);
|
$this->regenerate($includeTests, $ignoredCIConfigs);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\Core\Manifest;
|
|||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use SilverStripe\Assets\FileFinder;
|
use SilverStripe\Assets\FileFinder;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extension to the default file finder with some extra filters to facilitate
|
* An extension to the default file finder with some extra filters to facilitate
|
||||||
@ -285,7 +286,9 @@ class ManifestFileFinder extends FileFinder
|
|||||||
if ($this->isDirectoryModule($newBasename, $newPathname, $newDepth)) {
|
if ($this->isDirectoryModule($newBasename, $newPathname, $newDepth)) {
|
||||||
// We've reached the root of the module folder, we can read the PHP CI config now
|
// We've reached the root of the module folder, we can read the PHP CI config now
|
||||||
$module = new Module($newPathname, $this->upLevels($newPathname, $newDepth));
|
$module = new Module($newPathname, $this->upLevels($newPathname, $newDepth));
|
||||||
$config = $module->getCIConfig();
|
$config = Deprecation::withNoReplacement(function () use ($module) {
|
||||||
|
return $module->getCIConfig();
|
||||||
|
});
|
||||||
|
|
||||||
if (empty($config['PHP'])) {
|
if (empty($config['PHP'])) {
|
||||||
// This should never happen
|
// This should never happen
|
||||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\Dev;
|
|||||||
use BadMethodCallException;
|
use BadMethodCallException;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Core\Environment;
|
use SilverStripe\Core\Environment;
|
||||||
|
use SilverStripe\Core\Injector\InjectionCreator;
|
||||||
use SilverStripe\Core\Injector\InjectorLoader;
|
use SilverStripe\Core\Injector\InjectorLoader;
|
||||||
use SilverStripe\Core\Manifest\Module;
|
use SilverStripe\Core\Manifest\Module;
|
||||||
|
|
||||||
@ -21,19 +22,7 @@ use SilverStripe\Core\Manifest\Module;
|
|||||||
*
|
*
|
||||||
* This class abstracts the above pattern and adds a way to do that.
|
* This class abstracts the above pattern and adds a way to do that.
|
||||||
*
|
*
|
||||||
* Each call to notice passes a version that the notice will be valid from. Additionally this class has a notion of the
|
* Each call to notice passes a version that the notice will be valid from.
|
||||||
* version it should use when deciding whether to raise the notice. If that version is equal to or greater than the
|
|
||||||
* notices version (and SilverStripe is in dev mode) a deprecation message will be raised.
|
|
||||||
*
|
|
||||||
* Normally the checking version will be the release version of SilverStripe, but a developer can choose to set it to a
|
|
||||||
* future version, to see how their code will behave in future versions.
|
|
||||||
*
|
|
||||||
* Modules can also set the version for calls they make - either setting it to a future version in order to ensure
|
|
||||||
* forwards compatibility or setting it backwards if a module has not yet removed references to deprecated methods.
|
|
||||||
*
|
|
||||||
* When set per-module, only direct calls to deprecated methods from those modules are considered - if the module
|
|
||||||
* calls a non-module method which then calls a deprecated method, that call will use the global check version, not
|
|
||||||
* the module specific check version.
|
|
||||||
*/
|
*/
|
||||||
class Deprecation
|
class Deprecation
|
||||||
{
|
{
|
||||||
@ -58,10 +47,22 @@ class Deprecation
|
|||||||
* must be available before this to avoid infinite loops.
|
* must be available before this to avoid infinite loops.
|
||||||
*
|
*
|
||||||
* @var boolean|null
|
* @var boolean|null
|
||||||
* @deprecated 4.12.0 Use $is_enabled instead
|
* @deprecated 4.12.0 Use $currentlyEnabled instead
|
||||||
*/
|
*/
|
||||||
protected static $enabled = null;
|
protected static $enabled = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||||
|
*/
|
||||||
|
protected static $module_version_overrides = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
||||||
|
*/
|
||||||
|
public static $notice_level = E_USER_DEPRECATED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must be configured outside of the config API, as deprecation API
|
* Must be configured outside of the config API, as deprecation API
|
||||||
* must be available before this to avoid infinite loops.
|
* must be available before this to avoid infinite loops.
|
||||||
@ -70,48 +71,64 @@ class Deprecation
|
|||||||
*
|
*
|
||||||
* @internal - Marked as internal so this and other private static's are not treated as config
|
* @internal - Marked as internal so this and other private static's are not treated as config
|
||||||
*/
|
*/
|
||||||
private static bool $is_enabled = false;
|
private static bool $currentlyEnabled = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
|
||||||
*/
|
|
||||||
protected static $module_version_overrides = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
private static bool $inside_notice = false;
|
private static bool $insideNotice = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @internal
|
||||||
* @deprecated 4.12.0 Will be removed without equivalent functionality to replace it
|
|
||||||
*/
|
*/
|
||||||
public static $notice_level = E_USER_DEPRECATED;
|
private static bool $insideWithNoReplacement = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Buffer of user_errors to be raised when enabled() is called
|
* Buffer of user_errors to be raised
|
||||||
*
|
|
||||||
* This is used when setting deprecated config via yaml, before Deprecation::enable() has been called in _config.php
|
|
||||||
* Deprecated config set via yaml will only be shown in the browser when using ?flush=1
|
|
||||||
* It will not show in CLI when running dev/build flush=1
|
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
private static array $user_error_message_buffer = [];
|
private static array $userErrorMessageBuffer = [];
|
||||||
|
|
||||||
public static function enable(): void
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
private static bool $haveSetShutdownFunction = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
private static bool $showNoReplacementNotices = false;
|
||||||
|
|
||||||
|
public static function enable(bool $showNoReplacementNotices = false): void
|
||||||
{
|
{
|
||||||
static::$is_enabled = true;
|
static::$currentlyEnabled = true;
|
||||||
foreach (self::$user_error_message_buffer as $message) {
|
static::$showNoReplacementNotices = $showNoReplacementNotices;
|
||||||
user_error($message, E_USER_DEPRECATED);
|
|
||||||
}
|
|
||||||
self::$user_error_message_buffer = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function disable(): void
|
public static function disable(): void
|
||||||
{
|
{
|
||||||
static::$is_enabled = false;
|
static::$currentlyEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to wrap deprecated methods and deprecated config get()/set() that will be removed
|
||||||
|
* in the next major version with no replacement. This is done to surpress deprecation notices
|
||||||
|
* by for calls from the vendor dir to deprecated code that projects have no ability to change
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function withNoReplacement(callable $func)
|
||||||
|
{
|
||||||
|
if (self::$insideWithNoReplacement) {
|
||||||
|
return $func();
|
||||||
|
}
|
||||||
|
self::$insideWithNoReplacement = true;
|
||||||
|
try {
|
||||||
|
return $func();
|
||||||
|
} finally {
|
||||||
|
self::$insideWithNoReplacement = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,12 +176,19 @@ class Deprecation
|
|||||||
if (!$level) {
|
if (!$level) {
|
||||||
$level = 1;
|
$level = 1;
|
||||||
}
|
}
|
||||||
$called = $backtrace ? $backtrace[$level] : [];
|
$newLevel = $level;
|
||||||
|
// handle call_user_func
|
||||||
if (isset($called['class'])) {
|
if ($level === 4 && strpos($backtrace[2]['function'] ?? '', 'call_user_func') !== false) {
|
||||||
return $called['class'] . $called['type'] . $called['function'];
|
$newLevel = 5;
|
||||||
|
} elseif (strpos($backtrace[$level]['function'] ?? '', 'call_user_func') !== false) {
|
||||||
|
$newLevel = $level + 1;
|
||||||
}
|
}
|
||||||
return $called['function'] ?? '';
|
// handle InjectionCreator
|
||||||
|
if ($level == 4 && ($backtrace[$newLevel]['class'] ?? '') === InjectionCreator::class) {
|
||||||
|
$newLevel = $newLevel + 4;
|
||||||
|
}
|
||||||
|
$called = $backtrace[$newLevel] ?? [];
|
||||||
|
return ($called['class'] ?? '') . ($called['type'] ?? '') . ($called['function'] ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -179,12 +203,12 @@ class Deprecation
|
|||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function get_is_enabled(): bool
|
public static function isEnabled(): bool
|
||||||
{
|
{
|
||||||
if (!Director::isDev()) {
|
if (!Director::isDev()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return static::$is_enabled || Environment::getEnv('SS_DEPRECATION_ENABLED');
|
return static::$currentlyEnabled || Environment::getEnv('SS_DEPRECATION_ENABLED');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,6 +223,24 @@ class Deprecation
|
|||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function outputNotices(): void
|
||||||
|
{
|
||||||
|
if (!self::isEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// using a while loop with array_shift() to ensure that self::$userErrorMessageBuffer will have
|
||||||
|
// have values removed from it before calling user_error()
|
||||||
|
while (count(self::$userErrorMessageBuffer)) {
|
||||||
|
$arr = array_shift(self::$userErrorMessageBuffer);
|
||||||
|
$message = $arr['message'];
|
||||||
|
$calledInsideWithNoReplacement = $arr['calledInsideWithNoReplacement'];
|
||||||
|
if ($calledInsideWithNoReplacement && !self::$showNoReplacementNotices) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
user_error($message, E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Raise a notice indicating the method is deprecated if the version passed as the second argument is greater
|
* Raise a notice indicating the method is deprecated if the version passed as the second argument is greater
|
||||||
* than or equal to the check version set via ::notification_version
|
* than or equal to the check version set via ::notification_version
|
||||||
@ -209,22 +251,23 @@ class Deprecation
|
|||||||
*/
|
*/
|
||||||
public static function notice($atVersion, $string = '', $scope = Deprecation::SCOPE_METHOD)
|
public static function notice($atVersion, $string = '', $scope = Deprecation::SCOPE_METHOD)
|
||||||
{
|
{
|
||||||
if (static::$inside_notice) {
|
if (static::$insideNotice) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static::$inside_notice = true;
|
static::$insideNotice = true;
|
||||||
// try block needs to wrap all code in case anything inside the try block
|
// try block needs to wrap all code in case anything inside the try block
|
||||||
// calls something else that calls Deprecation::notice()
|
// calls something else that calls Deprecation::notice()
|
||||||
try {
|
try {
|
||||||
if ($scope === self::SCOPE_CONFIG) {
|
if ($scope === self::SCOPE_CONFIG) {
|
||||||
if (self::get_is_enabled()) {
|
// Deprecated config set via yaml will only be shown in the browser when using ?flush=1
|
||||||
user_error($string, E_USER_DEPRECATED);
|
// It will not show in CLI when running dev/build flush=1
|
||||||
|
self::$userErrorMessageBuffer[] = [
|
||||||
|
'message' => $string,
|
||||||
|
'calledInsideWithNoReplacement' => self::$insideWithNoReplacement
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
self::$user_error_message_buffer[] = $string;
|
if (!self::isEnabled()) {
|
||||||
}
|
// Do not add to self::$userErrorMessageBuffer, as the backtrace is too expensive
|
||||||
} else {
|
|
||||||
if (!self::get_is_enabled()) {
|
|
||||||
// Do not add to self::$user_error_message_buffer, as the backtrace is too expensive
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +277,7 @@ class Deprecation
|
|||||||
// Get the calling scope
|
// Get the calling scope
|
||||||
if ($scope == Deprecation::SCOPE_METHOD) {
|
if ($scope == Deprecation::SCOPE_METHOD) {
|
||||||
$backtrace = debug_backtrace(0);
|
$backtrace = debug_backtrace(0);
|
||||||
$caller = self::get_called_method_from_trace($backtrace);
|
$caller = self::get_called_method_from_trace($backtrace, 1);
|
||||||
} elseif ($scope == Deprecation::SCOPE_CLASS) {
|
} elseif ($scope == Deprecation::SCOPE_CLASS) {
|
||||||
$backtrace = debug_backtrace(0);
|
$backtrace = debug_backtrace(0);
|
||||||
$caller = isset($backtrace[1]['class']) ? $backtrace[1]['class'] : '(unknown)';
|
$caller = isset($backtrace[1]['class']) ? $backtrace[1]['class'] : '(unknown)';
|
||||||
@ -242,18 +285,30 @@ class Deprecation
|
|||||||
$caller = false;
|
$caller = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then raise the notice
|
|
||||||
if (substr($string, -1) != '.') {
|
if (substr($string, -1) != '.') {
|
||||||
$string .= ".";
|
$string .= ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
$string .= " Called from " . self::get_called_method_from_trace($backtrace, 2) . '.';
|
$level = self::$insideWithNoReplacement ? 4 : 2;
|
||||||
|
$string .= " Called from " . self::get_called_method_from_trace($backtrace, $level) . '.';
|
||||||
|
|
||||||
if ($caller) {
|
if ($caller) {
|
||||||
user_error($caller . ' is deprecated.' . ($string ? ' ' . $string : ''), E_USER_DEPRECATED);
|
$string = $caller . ' is deprecated.' . ($string ? ' ' . $string : '');
|
||||||
} else {
|
|
||||||
user_error($string, E_USER_DEPRECATED);
|
|
||||||
}
|
}
|
||||||
|
self::$userErrorMessageBuffer[] = [
|
||||||
|
'message' => $string,
|
||||||
|
'calledInsideWithNoReplacement' => self::$insideWithNoReplacement
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (!self::$haveSetShutdownFunction && self::isEnabled()) {
|
||||||
|
// Use a shutdown function rather than immediately calling user_error() so that notices
|
||||||
|
// do not interfere with setting session varibles i.e. headers already sent error
|
||||||
|
// it also means the deprecation notices appear below all phpunit output in CI
|
||||||
|
// which is far nicer than having it spliced between phpunit output
|
||||||
|
register_shutdown_function(function () {
|
||||||
|
self::outputNotices();
|
||||||
|
});
|
||||||
|
self::$haveSetShutdownFunction = true;
|
||||||
}
|
}
|
||||||
} catch (BadMethodCallException $e) {
|
} catch (BadMethodCallException $e) {
|
||||||
if ($e->getMessage() === InjectorLoader::NO_MANIFESTS_AVAILABLE) {
|
if ($e->getMessage() === InjectorLoader::NO_MANIFESTS_AVAILABLE) {
|
||||||
@ -264,7 +319,7 @@ class Deprecation
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
static::$inside_notice = false;
|
static::$insideNotice = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ use SilverStripe\Security\BasicAuth;
|
|||||||
use SilverStripe\Security\SecurityToken;
|
use SilverStripe\Security\SecurityToken;
|
||||||
use SilverStripe\View\SSViewer;
|
use SilverStripe\View\SSViewer;
|
||||||
use SimpleXMLElement;
|
use SimpleXMLElement;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/* -------------------------------------------------
|
/* -------------------------------------------------
|
||||||
*
|
*
|
||||||
@ -115,7 +116,7 @@ if (class_exists(IsEqualCanonicalizing::class)) {
|
|||||||
|
|
||||||
// Disable theme, if necessary
|
// Disable theme, if necessary
|
||||||
if (static::get_disable_themes()) {
|
if (static::get_disable_themes()) {
|
||||||
SSViewer::config()->update('theme_enabled', false);
|
SSViewer::config()->set('theme_enabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush user
|
// Flush user
|
||||||
@ -123,9 +124,11 @@ if (class_exists(IsEqualCanonicalizing::class)) {
|
|||||||
|
|
||||||
// Switch to draft site, if necessary
|
// Switch to draft site, if necessary
|
||||||
// If you rely on this you should be crafting stage-specific urls instead though.
|
// If you rely on this you should be crafting stage-specific urls instead though.
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
if (static::get_use_draft_site()) {
|
if (static::get_use_draft_site()) {
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Unprotect the site, tests are running with the assumption it's off. They will enable it on a case-by-case
|
// Unprotect the site, tests are running with the assumption it's off. They will enable it on a case-by-case
|
||||||
// basis.
|
// basis.
|
||||||
@ -560,7 +563,7 @@ class FunctionalTest extends SapphireTest implements TestOnly
|
|||||||
|
|
||||||
// Disable theme, if necessary
|
// Disable theme, if necessary
|
||||||
if (static::get_disable_themes()) {
|
if (static::get_disable_themes()) {
|
||||||
SSViewer::config()->update('theme_enabled', false);
|
SSViewer::config()->set('theme_enabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush user
|
// Flush user
|
||||||
@ -568,9 +571,11 @@ class FunctionalTest extends SapphireTest implements TestOnly
|
|||||||
|
|
||||||
// Switch to draft site, if necessary
|
// Switch to draft site, if necessary
|
||||||
// If you rely on this you should be crafting stage-specific urls instead though.
|
// If you rely on this you should be crafting stage-specific urls instead though.
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
if (static::get_use_draft_site()) {
|
if (static::get_use_draft_site()) {
|
||||||
$this->useDraftSite();
|
$this->useDraftSite();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Unprotect the site, tests are running with the assumption it's off. They will enable it on a case-by-case
|
// Unprotect the site, tests are running with the assumption it's off. They will enable it on a case-by-case
|
||||||
// basis.
|
// basis.
|
||||||
|
@ -329,7 +329,7 @@ if (class_exists(IsEqualCanonicalizing::class)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists(Cookie::class)) {
|
if (class_exists(Cookie::class)) {
|
||||||
Cookie::config()->update('report_errors', false);
|
Cookie::config()->set('report_errors', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists(RootURLController::class)) {
|
if (class_exists(RootURLController::class)) {
|
||||||
@ -347,16 +347,12 @@ if (class_exists(IsEqualCanonicalizing::class)) {
|
|||||||
|
|
||||||
if ($this->shouldSetupDatabaseForCurrentTest($fixtureFiles)) {
|
if ($this->shouldSetupDatabaseForCurrentTest($fixtureFiles)) {
|
||||||
// Assign fixture factory to deprecated prop in case old tests use it over the getter
|
// Assign fixture factory to deprecated prop in case old tests use it over the getter
|
||||||
/** @var FixtureTestState $fixtureState */
|
|
||||||
$fixtureState = static::$state->getStateByName('fixtures');
|
|
||||||
$this->fixtureFactory = $fixtureState->getFixtureFactory(static::class);
|
|
||||||
|
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn off template debugging
|
// turn off template debugging
|
||||||
if (class_exists(SSViewer::class)) {
|
if (class_exists(SSViewer::class)) {
|
||||||
SSViewer::config()->update('source_file_comments', false);
|
SSViewer::config()->set('source_file_comments', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the test mailer
|
// Set up the test mailer
|
||||||
@ -1206,7 +1202,7 @@ if (class_exists(IsEqualCanonicalizing::class)) {
|
|||||||
if (strpos($themeBaseDir ?? '', BASE_PATH) === 0) {
|
if (strpos($themeBaseDir ?? '', BASE_PATH) === 0) {
|
||||||
$themeBaseDir = substr($themeBaseDir ?? '', strlen(BASE_PATH));
|
$themeBaseDir = substr($themeBaseDir ?? '', strlen(BASE_PATH));
|
||||||
}
|
}
|
||||||
SSViewer::config()->update('theme_enabled', true);
|
SSViewer::config()->set('theme_enabled', true);
|
||||||
SSViewer::set_themes([$themeBaseDir . '/themes/' . $theme, '$default']);
|
SSViewer::set_themes([$themeBaseDir . '/themes/' . $theme, '$default']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1649,7 +1645,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase implements TestOnly
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists(Cookie::class)) {
|
if (class_exists(Cookie::class)) {
|
||||||
Cookie::config()->update('report_errors', false);
|
Cookie::config()->set('report_errors', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists(RootURLController::class)) {
|
if (class_exists(RootURLController::class)) {
|
||||||
@ -1676,7 +1672,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase implements TestOnly
|
|||||||
|
|
||||||
// turn off template debugging
|
// turn off template debugging
|
||||||
if (class_exists(SSViewer::class)) {
|
if (class_exists(SSViewer::class)) {
|
||||||
SSViewer::config()->update('source_file_comments', false);
|
SSViewer::config()->set('source_file_comments', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the test mailer
|
// Set up the test mailer
|
||||||
@ -2556,7 +2552,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase implements TestOnly
|
|||||||
if (strpos($themeBaseDir ?? '', BASE_PATH) === 0) {
|
if (strpos($themeBaseDir ?? '', BASE_PATH) === 0) {
|
||||||
$themeBaseDir = substr($themeBaseDir ?? '', strlen(BASE_PATH));
|
$themeBaseDir = substr($themeBaseDir ?? '', strlen(BASE_PATH));
|
||||||
}
|
}
|
||||||
SSViewer::config()->update('theme_enabled', true);
|
SSViewer::config()->set('theme_enabled', true);
|
||||||
SSViewer::set_themes([$themeBaseDir . '/themes/' . $theme, '$default']);
|
SSViewer::set_themes([$themeBaseDir . '/themes/' . $theme, '$default']);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -21,9 +21,12 @@ use SilverStripe\Dev\BuildTask;
|
|||||||
use SilverStripe\Assets\Dev\Tasks\SecureAssetsMigrationHelper;
|
use SilverStripe\Assets\Dev\Tasks\SecureAssetsMigrationHelper;
|
||||||
use SilverStripe\UserForms\Task\RecoverUploadLocationsHelper;
|
use SilverStripe\UserForms\Task\RecoverUploadLocationsHelper;
|
||||||
use \Bramus\Monolog\Formatter\ColoredLineFormatter;
|
use \Bramus\Monolog\Formatter\ColoredLineFormatter;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrates all 3.x file dataobjects to use the new DBFile field.
|
* Migrates all 3.x file dataobjects to use the new DBFile field.
|
||||||
|
*
|
||||||
|
* @deprected 4.12.0 Will be removed without equivalent functionality to replace it
|
||||||
*/
|
*/
|
||||||
class MigrateFileTask extends BuildTask
|
class MigrateFileTask extends BuildTask
|
||||||
{
|
{
|
||||||
@ -52,6 +55,12 @@ class MigrateFileTask extends BuildTask
|
|||||||
/** @var Logger */
|
/** @var Logger */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
public function run($request)
|
public function run($request)
|
||||||
{
|
{
|
||||||
$this->addLogHandlers();
|
$this->addLogHandlers();
|
||||||
|
@ -262,7 +262,7 @@ class GridFieldAddExistingAutocompleter extends AbstractGridFieldComponent imple
|
|||||||
|
|
||||||
$json = [];
|
$json = [];
|
||||||
Config::nest();
|
Config::nest();
|
||||||
SSViewer::config()->update('source_file_comments', false);
|
SSViewer::config()->set('source_file_comments', false);
|
||||||
$viewer = SSViewer::fromString($this->resultsFormat);
|
$viewer = SSViewer::fromString($this->resultsFormat);
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$title = Convert::html2raw($viewer->process($result));
|
$title = Convert::html2raw($viewer->process($result));
|
||||||
|
@ -8,6 +8,7 @@ use SilverStripe\Control\HTTPResponse;
|
|||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\ORM\DataList;
|
use SilverStripe\ORM\DataList;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an "Export list" button to the bottom of a {@link GridField}.
|
* Adds an "Export list" button to the bottom of a {@link GridField}.
|
||||||
@ -221,6 +222,7 @@ class GridFieldExportButton extends AbstractGridFieldComponent implements GridFi
|
|||||||
? $gridFieldColumnsComponent->getColumnsHandled($gridField)
|
? $gridFieldColumnsComponent->getColumnsHandled($gridField)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
|
/** @var ArrayList|DataList $items */
|
||||||
// Remove limit as the list may be paginated, we want the full list for the export
|
// Remove limit as the list may be paginated, we want the full list for the export
|
||||||
$items = $items->limit(null);
|
$items = $items->limit(null);
|
||||||
// Use Generator in applicable cases to reduce memory consumption
|
// Use Generator in applicable cases to reduce memory consumption
|
||||||
|
@ -102,7 +102,10 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi
|
|||||||
callable $updateSearchContext = null,
|
callable $updateSearchContext = null,
|
||||||
callable $updateSearchForm = null
|
callable $updateSearchForm = null
|
||||||
) {
|
) {
|
||||||
$this->useLegacyFilterHeader = Config::inst()->get(self::class, 'force_legacy') || $useLegacy;
|
$forceLegacy = Deprecation::withNoReplacement(function () {
|
||||||
|
return Config::inst()->get(self::class, 'force_legacy');
|
||||||
|
});
|
||||||
|
$this->useLegacyFilterHeader = $forceLegacy || $useLegacy;
|
||||||
$this->updateSearchContextCallback = $updateSearchContext;
|
$this->updateSearchContextCallback = $updateSearchContext;
|
||||||
$this->updateSearchFormCallback = $updateSearchForm;
|
$this->updateSearchFormCallback = $updateSearchForm;
|
||||||
}
|
}
|
||||||
@ -523,7 +526,9 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->useLegacyFilterHeader) {
|
if ($this->useLegacyFilterHeader) {
|
||||||
$fieldsList = $this->getLegacyFilterHeader($gridField);
|
$fieldsList = Deprecation::withNoReplacement(function () use ($gridField) {
|
||||||
|
return $this->getLegacyFilterHeader($gridField);
|
||||||
|
});
|
||||||
$forTemplate->Fields = $fieldsList;
|
$forTemplate->Fields = $fieldsList;
|
||||||
$filterTemplates = SSViewer::get_templates_by_class($this, '_Row', __CLASS__);
|
$filterTemplates = SSViewer::get_templates_by_class($this, '_Row', __CLASS__);
|
||||||
return ['header' => $forTemplate->renderWith($filterTemplates)];
|
return ['header' => $forTemplate->renderWith($filterTemplates)];
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Forms;
|
namespace SilverStripe\Forms;
|
||||||
|
|
||||||
use SilverStripe\Dev\Deprecation;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use SilverStripe\Assets\Folder;
|
use SilverStripe\Assets\Folder;
|
||||||
@ -622,13 +621,11 @@ class TreeDropdownField extends FormField
|
|||||||
/**
|
/**
|
||||||
* HTML-encoded label for this node, including css classes and other markup.
|
* HTML-encoded label for this node, including css classes and other markup.
|
||||||
*
|
*
|
||||||
* @deprecated 4.0.1 Use setTitleField() instead
|
|
||||||
* @param string $field
|
* @param string $field
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setLabelField($field)
|
public function setLabelField($field)
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.0.1', 'Use setTitleField() instead');
|
|
||||||
$this->labelField = $field;
|
$this->labelField = $field;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -636,12 +633,10 @@ class TreeDropdownField extends FormField
|
|||||||
/**
|
/**
|
||||||
* HTML-encoded label for this node, including css classes and other markup.
|
* HTML-encoded label for this node, including css classes and other markup.
|
||||||
*
|
*
|
||||||
* @deprecated 4.0.1 Use getTitleField() instead
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLabelField()
|
public function getLabelField()
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.0.1', 'Use getTitleField() instead');
|
|
||||||
return $this->labelField;
|
return $this->labelField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ namespace SilverStripe\Forms;
|
|||||||
use SilverStripe\Assets\File;
|
use SilverStripe\Assets\File;
|
||||||
use SilverStripe\Assets\Upload;
|
use SilverStripe\Assets\Upload;
|
||||||
use SilverStripe\Assets\Upload_Validator;
|
use SilverStripe\Assets\Upload_Validator;
|
||||||
|
use SilverStripe\Core\Convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a form field which has an Upload() instance and can upload to a folder
|
* Represents a form field which has an Upload() instance and can upload to a folder
|
||||||
@ -47,8 +48,8 @@ trait UploadReceiver
|
|||||||
);
|
);
|
||||||
|
|
||||||
// get the lower max size
|
// get the lower max size
|
||||||
$maxUpload = File::ini2bytes(ini_get('upload_max_filesize'));
|
$maxUpload = Convert::memstring2bytes(ini_get('upload_max_filesize'));
|
||||||
$maxPost = File::ini2bytes(ini_get('post_max_size'));
|
$maxPost = Convert::memstring2bytes(ini_get('post_max_size'));
|
||||||
$this->getValidator()->setAllowedMaxFileSize(min($maxUpload, $maxPost));
|
$this->getValidator()->setAllowedMaxFileSize(min($maxUpload, $maxPost));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,18 +178,20 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a sub-range of this dataobjectset as an array
|
* Get a sub-range of this dataobjectset as an array
|
||||||
|
* Pass null to "remove the limit" - this is for consistency with DataList::limit(null) which itself will
|
||||||
|
* call SQLSelect::setLimit(null)
|
||||||
*
|
*
|
||||||
* @param int $length
|
* @param int|null $length
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
public function limit($length, $offset = 0)
|
public function limit($length, $offset = 0)
|
||||||
{
|
{
|
||||||
// Type checking: designed for consistency with DataList::limit()
|
// Type checking: designed for consistency with DataList::limit()
|
||||||
if (!is_numeric($length) || !is_numeric($offset)) {
|
if ((!is_numeric($length) || !is_numeric($offset)) && !is_null($length)) {
|
||||||
Deprecation::notice(
|
Deprecation::notice(
|
||||||
'4.3',
|
'4.3',
|
||||||
'Arguments to ArrayList::limit() should be numeric'
|
'Arguments to ArrayList::limit() should be numeric or null'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace SilverStripe\ORM\Connect;
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
use SilverStripe\Dev\Deprecation;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
@ -60,12 +59,9 @@ abstract class DBSchemaManager
|
|||||||
/**
|
/**
|
||||||
* @param string $table
|
* @param string $table
|
||||||
* @param string $class
|
* @param string $class
|
||||||
*
|
|
||||||
* @deprecated 4.0.1 Will be removed without equivalent functionality
|
|
||||||
*/
|
*/
|
||||||
public static function showTableNameWarning($table, $class)
|
public static function showTableNameWarning($table, $class)
|
||||||
{
|
{
|
||||||
Deprecation::notice('4.0.1', 'Will be removed without equivalent functionality');
|
|
||||||
static::$table_name_warnings[$table] = $class;
|
static::$table_name_warnings[$table] = $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,6 @@ class MySQLTransactionManager implements TransactionManager
|
|||||||
|
|
||||||
public function transactionStart($transactionMode = false, $sessionCharacteristics = false)
|
public function transactionStart($transactionMode = false, $sessionCharacteristics = false)
|
||||||
{
|
{
|
||||||
if ($transactionMode || $sessionCharacteristics) {
|
|
||||||
Deprecation::notice(
|
|
||||||
'4.4',
|
|
||||||
'$transactionMode and $sessionCharacteristics are deprecated and will be removed in SS5'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->inTransaction) {
|
if ($this->inTransaction) {
|
||||||
throw new DatabaseException(
|
throw new DatabaseException(
|
||||||
"Already in transaction, can't start another. Consider decorating with NestedTransactionManager."
|
"Already in transaction, can't start another. Consider decorating with NestedTransactionManager."
|
||||||
|
@ -2604,11 +2604,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
|
|
||||||
// Support for the old method during the deprecation period
|
// Support for the old method during the deprecation period
|
||||||
if ($this->hasMethod('getCMSValidator')) {
|
if ($this->hasMethod('getCMSValidator')) {
|
||||||
Deprecation::notice(
|
|
||||||
'4.6',
|
|
||||||
'getCMSValidator() is removed in 5.0 in favour of getCMSCompositeValidator()'
|
|
||||||
);
|
|
||||||
|
|
||||||
$compositeValidator->addValidator($this->getCMSValidator());
|
$compositeValidator->addValidator($this->getCMSValidator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ PHP
|
|||||||
$backURLs = [
|
$backURLs = [
|
||||||
$this->getRequest()->requestVar('BackURL'),
|
$this->getRequest()->requestVar('BackURL'),
|
||||||
$this->getRequest()->getSession()->get('BackURL'),
|
$this->getRequest()->getSession()->get('BackURL'),
|
||||||
Director::absoluteURL(AdminRootController::config()->get('url_base'), true),
|
Director::absoluteURL(AdminRootController::config()->get('url_base')),
|
||||||
];
|
];
|
||||||
$backURL = null;
|
$backURL = null;
|
||||||
foreach ($backURLs as $backURL) {
|
foreach ($backURLs as $backURL) {
|
||||||
|
@ -287,8 +287,11 @@ class SSViewer implements Flushable
|
|||||||
return $themes;
|
return $themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support legacy behaviour
|
// Support @deprecated legacy behaviour
|
||||||
if ($theme = SSViewer::config()->uninherited('theme')) {
|
$theme = Deprecation::withNoReplacement(function () {
|
||||||
|
return SSViewer::config()->uninherited('theme');
|
||||||
|
});
|
||||||
|
if ($theme) {
|
||||||
return [self::PUBLIC_THEME, $theme, self::DEFAULT_THEME];
|
return [self::PUBLIC_THEME, $theme, self::DEFAULT_THEME];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,6 @@ class i18n implements TemplateGlobalProvider
|
|||||||
// inject the variables from injectionArray (if present)
|
// inject the variables from injectionArray (if present)
|
||||||
$sprintfArgs = [];
|
$sprintfArgs = [];
|
||||||
if ($default && !preg_match('/\{[\w\d]*\}/i', $default ?? '') && preg_match('/%[s,d]/', $default ?? '')) {
|
if ($default && !preg_match('/\{[\w\d]*\}/i', $default ?? '') && preg_match('/%[s,d]/', $default ?? '')) {
|
||||||
Deprecation::notice('5.0', 'sprintf style localisation variables are deprecated');
|
|
||||||
$sprintfArgs = array_values($injection ?? []);
|
$sprintfArgs = array_values($injection ?? []);
|
||||||
$injection = [];
|
$injection = [];
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<td colspan="$GridField.ExtraColumnsCount" class="ss-gridfield-last"></td>
|
<td colspan="$GridField.ExtraColumnsCount" class="ss-gridfield-last"></td>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% loop $Fields %>
|
<% loop $Fields %>
|
||||||
<td <% if FirstLast %>class="ss-gridfield-{$FirstLast}"<% end_if %>>$Value</td>
|
<td <% if $FirstLast %>class="ss-gridfield-{$FirstLast}"<% end_if %>>$Value</td>
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -45,7 +45,7 @@ class ControllerTest extends FunctionalTest
|
|||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
Director::config()->update('alternate_base_url', '/');
|
Director::config()->set('alternate_base_url', '/');
|
||||||
|
|
||||||
// Add test theme
|
// Add test theme
|
||||||
$themeDir = substr(__DIR__, strlen(FRAMEWORK_DIR)) . '/ControllerTest/';
|
$themeDir = substr(__DIR__, strlen(FRAMEWORK_DIR)) . '/ControllerTest/';
|
||||||
|
@ -16,6 +16,7 @@ use SilverStripe\Core\Config\Config;
|
|||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Core\Environment;
|
use SilverStripe\Core\Environment;
|
||||||
use SilverStripe\Core\Kernel;
|
use SilverStripe\Core\Kernel;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -856,6 +857,9 @@ class DirectorTest extends SapphireTest
|
|||||||
|
|
||||||
public function testRequestFilterInDirectorTest()
|
public function testRequestFilterInDirectorTest()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$filter = new DirectorTest\TestRequestFilter;
|
$filter = new DirectorTest\TestRequestFilter;
|
||||||
|
|
||||||
$processor = new RequestProcessor([$filter]);
|
$processor = new RequestProcessor([$filter]);
|
||||||
|
@ -271,7 +271,7 @@ class EmailTest extends SapphireTest
|
|||||||
|
|
||||||
public function testSetSwiftMessage()
|
public function testSetSwiftMessage()
|
||||||
{
|
{
|
||||||
Email::config()->update('admin_email', 'admin@example.com');
|
Email::config()->set('admin_email', 'admin@example.com');
|
||||||
DBDatetime::set_mock_now('2017-01-01 07:00:00');
|
DBDatetime::set_mock_now('2017-01-01 07:00:00');
|
||||||
$email = new Email();
|
$email = new Email();
|
||||||
$swiftMessage = new Swift_Message();
|
$swiftMessage = new Swift_Message();
|
||||||
@ -294,7 +294,7 @@ class EmailTest extends SapphireTest
|
|||||||
|
|
||||||
public function testAdminEmailApplied()
|
public function testAdminEmailApplied()
|
||||||
{
|
{
|
||||||
Email::config()->update('admin_email', 'admin@example.com');
|
Email::config()->set('admin_email', 'admin@example.com');
|
||||||
$email = new Email();
|
$email = new Email();
|
||||||
|
|
||||||
$this->assertCount(1, $email->getFrom());
|
$this->assertCount(1, $email->getFrom());
|
||||||
|
@ -21,7 +21,7 @@ class SwiftMailerTest extends SapphireTest
|
|||||||
$this->assertEquals($swift, $mailer->getSwiftMailer());
|
$this->assertEquals($swift, $mailer->getSwiftMailer());
|
||||||
|
|
||||||
SwiftMailer::config()->remove('swift_plugins');
|
SwiftMailer::config()->remove('swift_plugins');
|
||||||
SwiftMailer::config()->update('swift_plugins', [Swift_Plugins_AntiFloodPlugin::class]);
|
SwiftMailer::config()->merge('swift_plugins', [Swift_Plugins_AntiFloodPlugin::class]);
|
||||||
|
|
||||||
/** @var Swift_MailTransport $transport */
|
/** @var Swift_MailTransport $transport */
|
||||||
$transport = $this->getMockBuilder(Swift_MailTransport::class)->getMock();
|
$transport = $this->getMockBuilder(Swift_MailTransport::class)->getMock();
|
||||||
|
@ -39,7 +39,7 @@ class SwiftPluginTest extends SapphireTest
|
|||||||
|
|
||||||
public function testSendAllEmailsTo()
|
public function testSendAllEmailsTo()
|
||||||
{
|
{
|
||||||
Email::config()->update('send_all_emails_to', 'to@example.com');
|
Email::config()->set('send_all_emails_to', 'to@example.com');
|
||||||
$email = $this->getEmail();
|
$email = $this->getEmail();
|
||||||
$this->getMailer()->send($email->getSwiftMessage());
|
$this->getMailer()->send($email->getSwiftMessage());
|
||||||
$headers = $email->getSwiftMessage()->getHeaders();
|
$headers = $email->getSwiftMessage()->getHeaders();
|
||||||
@ -68,7 +68,7 @@ class SwiftPluginTest extends SapphireTest
|
|||||||
|
|
||||||
public function testSendAllEmailsFrom()
|
public function testSendAllEmailsFrom()
|
||||||
{
|
{
|
||||||
Email::config()->update('send_all_emails_from', 'from@example.com');
|
Email::config()->set('send_all_emails_from', 'from@example.com');
|
||||||
$email = $this->getEmail();
|
$email = $this->getEmail();
|
||||||
$this->getMailer()->send($email->getSwiftMessage());
|
$this->getMailer()->send($email->getSwiftMessage());
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ class SwiftPluginTest extends SapphireTest
|
|||||||
|
|
||||||
public function testCCAllEmailsTo()
|
public function testCCAllEmailsTo()
|
||||||
{
|
{
|
||||||
Email::config()->update('cc_all_emails_to', 'cc@example.com');
|
Email::config()->set('cc_all_emails_to', 'cc@example.com');
|
||||||
$email = $this->getEmail();
|
$email = $this->getEmail();
|
||||||
$this->getMailer()->send($email->getSwiftMessage());
|
$this->getMailer()->send($email->getSwiftMessage());
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class SwiftPluginTest extends SapphireTest
|
|||||||
|
|
||||||
public function testBCCAllEmailsTo()
|
public function testBCCAllEmailsTo()
|
||||||
{
|
{
|
||||||
Email::config()->update('bcc_all_emails_to', 'bcc@example.com');
|
Email::config()->set('bcc_all_emails_to', 'bcc@example.com');
|
||||||
$email = $this->getEmail();
|
$email = $this->getEmail();
|
||||||
$this->getMailer()->send($email->getSwiftMessage());
|
$this->getMailer()->send($email->getSwiftMessage());
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ use ReflectionMethod;
|
|||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
use SilverStripe\Control\Middleware\TrustedProxyMiddleware;
|
use SilverStripe\Control\Middleware\TrustedProxyMiddleware;
|
||||||
use SilverStripe\Control\Session;
|
use SilverStripe\Control\Session;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
class HTTPRequestTest extends SapphireTest
|
class HTTPRequestTest extends SapphireTest
|
||||||
@ -155,12 +156,18 @@ class HTTPRequestTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testDetectMethod($realMethod, $post, $expected)
|
public function testDetectMethod($realMethod, $post, $expected)
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$actual = HTTPRequest::detect_method($realMethod, $post);
|
$actual = HTTPRequest::detect_method($realMethod, $post);
|
||||||
$this->assertEquals($expected, $actual);
|
$this->assertEquals($expected, $actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBadDetectMethod()
|
public function testBadDetectMethod()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
HTTPRequest::detect_method('POST', ['_method' => 'Boom']);
|
HTTPRequest::detect_method('POST', ['_method' => 'Boom']);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware;
|
|||||||
use SilverStripe\Control\Session;
|
use SilverStripe\Control\Session;
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Dev\FunctionalTest;
|
use SilverStripe\Dev\FunctionalTest;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the {@link HTTP} class
|
* Tests the {@link HTTP} class
|
||||||
@ -115,6 +116,9 @@ class HTTPTest extends FunctionalTest
|
|||||||
|
|
||||||
public function testDeprecatedVaryHandling()
|
public function testDeprecatedVaryHandling()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
Config::modify()->set(
|
Config::modify()->set(
|
||||||
HTTP::class,
|
HTTP::class,
|
||||||
@ -129,6 +133,9 @@ class HTTPTest extends FunctionalTest
|
|||||||
|
|
||||||
public function testDeprecatedCacheControlHandling()
|
public function testDeprecatedCacheControlHandling()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
HTTPCacheControlMiddleware::singleton()->publicCache();
|
HTTPCacheControlMiddleware::singleton()->publicCache();
|
||||||
|
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
@ -149,6 +156,9 @@ class HTTPTest extends FunctionalTest
|
|||||||
|
|
||||||
public function testDeprecatedCacheControlHandlingOnMaxAge()
|
public function testDeprecatedCacheControlHandlingOnMaxAge()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
HTTPCacheControlMiddleware::singleton()->publicCache();
|
HTTPCacheControlMiddleware::singleton()->publicCache();
|
||||||
|
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
@ -169,6 +179,9 @@ class HTTPTest extends FunctionalTest
|
|||||||
|
|
||||||
public function testDeprecatedCacheControlHandlingThrowsWithUnknownDirectives()
|
public function testDeprecatedCacheControlHandlingThrowsWithUnknownDirectives()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$this->expectException(\LogicException::class);
|
$this->expectException(\LogicException::class);
|
||||||
$this->expectExceptionMessageMatches('/Found unsupported legacy directives in HTTP\.cache_control: unknown/');
|
$this->expectExceptionMessageMatches('/Found unsupported legacy directives in HTTP\.cache_control: unknown/');
|
||||||
/** @var Config */
|
/** @var Config */
|
||||||
|
@ -107,7 +107,7 @@ class SessionTest extends SapphireTest
|
|||||||
->setScheme('https');
|
->setScheme('https');
|
||||||
Cookie::set(session_name(), '1234');
|
Cookie::set(session_name(), '1234');
|
||||||
$session = new Session(null); // unstarted session
|
$session = new Session(null); // unstarted session
|
||||||
$session->config()->update('cookie_secure', true);
|
$session->config()->set('cookie_secure', true);
|
||||||
$session->start($req);
|
$session->start($req);
|
||||||
$this->assertEquals(session_name(), $session->config()->get('cookie_name_secure'));
|
$this->assertEquals(session_name(), $session->config()->get('cookie_name_secure'));
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ class SessionTest extends SapphireTest
|
|||||||
->setScheme('https');
|
->setScheme('https');
|
||||||
$session = new Session(null); // unstarted session
|
$session = new Session(null); // unstarted session
|
||||||
Cookie::set($session->config()->get('cookie_name_secure'), '1234');
|
Cookie::set($session->config()->get('cookie_name_secure'), '1234');
|
||||||
$session->config()->update('cookie_secure', true);
|
$session->config()->set('cookie_secure', true);
|
||||||
$this->assertTrue($session->requestContainsSessionId($req));
|
$this->assertTrue($session->requestContainsSessionId($req));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\Core\Tests;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use SilverStripe\Core\Convert;
|
use SilverStripe\Core\Convert;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\View\Parsers\URLSegmentFilter;
|
use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
@ -217,6 +218,9 @@ PHP
|
|||||||
*/
|
*/
|
||||||
public function testArray2JSON()
|
public function testArray2JSON()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$val = [
|
$val = [
|
||||||
'Joe' => 'Bloggs',
|
'Joe' => 'Bloggs',
|
||||||
'Tom' => 'Jones',
|
'Tom' => 'Jones',
|
||||||
@ -237,6 +241,9 @@ PHP
|
|||||||
*/
|
*/
|
||||||
public function testJSON2Array()
|
public function testJSON2Array()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$val = '{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}';
|
$val = '{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}';
|
||||||
$decoded = Convert::json2array($val);
|
$decoded = Convert::json2array($val);
|
||||||
$this->assertEquals(3, count($decoded ?? []), '3 items in the decoded array');
|
$this->assertEquals(3, count($decoded ?? []), '3 items in the decoded array');
|
||||||
@ -250,6 +257,9 @@ PHP
|
|||||||
*/
|
*/
|
||||||
public function testJSON2Obj()
|
public function testJSON2Obj()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$val = '{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}';
|
$val = '{"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}}';
|
||||||
$obj = Convert::json2obj($val);
|
$obj = Convert::json2obj($val);
|
||||||
$this->assertEquals('Bloggs', $obj->Joe);
|
$this->assertEquals('Bloggs', $obj->Joe);
|
||||||
@ -264,7 +274,7 @@ PHP
|
|||||||
*/
|
*/
|
||||||
public function testRaw2URL()
|
public function testRaw2URL()
|
||||||
{
|
{
|
||||||
URLSegmentFilter::config()->update('default_allow_multibyte', false);
|
URLSegmentFilter::config()->set('default_allow_multibyte', false);
|
||||||
$this->assertEquals('foo', Convert::raw2url('foo'));
|
$this->assertEquals('foo', Convert::raw2url('foo'));
|
||||||
$this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar'));
|
$this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar'));
|
||||||
$this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar!'));
|
$this->assertEquals('foo-and-bar', Convert::raw2url('foo & bar!'));
|
||||||
@ -359,6 +369,9 @@ PHP
|
|||||||
*/
|
*/
|
||||||
public function testRaw2JSON()
|
public function testRaw2JSON()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
|
|
||||||
// Test object
|
// Test object
|
||||||
$input = new stdClass();
|
$input = new stdClass();
|
||||||
@ -390,6 +403,9 @@ PHP
|
|||||||
*/
|
*/
|
||||||
public function testRaw2JsonWithContext()
|
public function testRaw2JsonWithContext()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$data = ['foo' => 'b"ar'];
|
$data = ['foo' => 'b"ar'];
|
||||||
$expected = '{"foo":"b\u0022ar"}';
|
$expected = '{"foo":"b\u0022ar"}';
|
||||||
$result = Convert::raw2json($data, JSON_HEX_QUOT);
|
$result = Convert::raw2json($data, JSON_HEX_QUOT);
|
||||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\Core\Tests\Manifest;
|
|||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
use SilverStripe\Core\Manifest\Module;
|
use SilverStripe\Core\Manifest\Module;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
class ModuleTest extends SapphireTest
|
class ModuleTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -29,6 +30,9 @@ class ModuleTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testGetCIConfig($fixture, $expectedPhpConfig)
|
public function testGetCIConfig($fixture, $expectedPhpConfig)
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$path = __DIR__ . '/fixtures/phpunit-detection/' . $fixture;
|
$path = __DIR__ . '/fixtures/phpunit-detection/' . $fixture;
|
||||||
$module = new Module($path, $path);
|
$module = new Module($path, $path);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -19,6 +19,7 @@ use SilverStripe\Core\Tests\ObjectTest\ExtensionTest3;
|
|||||||
use SilverStripe\Core\Tests\ObjectTest\MyObject;
|
use SilverStripe\Core\Tests\ObjectTest\MyObject;
|
||||||
use SilverStripe\Core\Tests\ObjectTest\MySubObject;
|
use SilverStripe\Core\Tests\ObjectTest\MySubObject;
|
||||||
use SilverStripe\Core\Tests\ObjectTest\TestExtension;
|
use SilverStripe\Core\Tests\ObjectTest\TestExtension;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Versioned\Versioned;
|
use SilverStripe\Versioned\Versioned;
|
||||||
|
|
||||||
@ -110,6 +111,9 @@ class ObjectTest extends SapphireTest
|
|||||||
|
|
||||||
public function testStaticGetterMethod()
|
public function testStaticGetterMethod()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$obj = singleton(MyObject::class);
|
$obj = singleton(MyObject::class);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'MyObject',
|
'MyObject',
|
||||||
@ -120,6 +124,9 @@ class ObjectTest extends SapphireTest
|
|||||||
|
|
||||||
public function testStaticInheritanceGetters()
|
public function testStaticInheritanceGetters()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$subObj = singleton(MyObject::class);
|
$subObj = singleton(MyObject::class);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$subObj->stat('mystaticProperty'),
|
$subObj->stat('mystaticProperty'),
|
||||||
@ -130,6 +137,9 @@ class ObjectTest extends SapphireTest
|
|||||||
|
|
||||||
public function testStaticSettingOnSingletons()
|
public function testStaticSettingOnSingletons()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$singleton1 = singleton(MyObject::class);
|
$singleton1 = singleton(MyObject::class);
|
||||||
$singleton2 = singleton(MyObject::class);
|
$singleton2 = singleton(MyObject::class);
|
||||||
$singleton1->set_stat('mystaticProperty', 'changed');
|
$singleton1->set_stat('mystaticProperty', 'changed');
|
||||||
@ -142,6 +152,9 @@ class ObjectTest extends SapphireTest
|
|||||||
|
|
||||||
public function testStaticSettingOnInstances()
|
public function testStaticSettingOnInstances()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$instance1 = new ObjectTest\MyObject();
|
$instance1 = new ObjectTest\MyObject();
|
||||||
$instance2 = new ObjectTest\MyObject();
|
$instance2 = new ObjectTest\MyObject();
|
||||||
$instance1->set_stat('mystaticProperty', 'changed');
|
$instance1->set_stat('mystaticProperty', 'changed');
|
||||||
|
@ -59,7 +59,7 @@ class BacktraceTest extends SapphireTest
|
|||||||
'args' => ['myarg' => 'myval']
|
'args' => ['myarg' => 'myval']
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
Backtrace::config()->update(
|
Backtrace::config()->merge(
|
||||||
'ignore_function_args',
|
'ignore_function_args',
|
||||||
[
|
[
|
||||||
['MyClass', 'myIgnoredClassFunction'],
|
['MyClass', 'myIgnoredClassFunction'],
|
||||||
@ -101,7 +101,7 @@ class BacktraceTest extends SapphireTest
|
|||||||
'args' => ['myarg' => 'myval']
|
'args' => ['myarg' => 'myval']
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
Backtrace::config()->update(
|
Backtrace::config()->merge(
|
||||||
'ignore_function_args',
|
'ignore_function_args',
|
||||||
[
|
[
|
||||||
['*', 'myIgnoredClassFunction'],
|
['*', 'myIgnoredClassFunction'],
|
||||||
|
@ -7,6 +7,7 @@ use SilverStripe\Core\Config\Config;
|
|||||||
use SilverStripe\Dev\Deprecation;
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject;
|
use SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject;
|
||||||
|
use SilverStripe\Core\Injector\Injector;
|
||||||
|
|
||||||
class DeprecationTest extends SapphireTest
|
class DeprecationTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -16,6 +17,8 @@ class DeprecationTest extends SapphireTest
|
|||||||
|
|
||||||
private $oldHandler = null;
|
private $oldHandler = null;
|
||||||
|
|
||||||
|
private bool $noticesWereEnabled = false;
|
||||||
|
|
||||||
protected function setup(): void
|
protected function setup(): void
|
||||||
{
|
{
|
||||||
// Use custom error handler for two reasons:
|
// Use custom error handler for two reasons:
|
||||||
@ -23,6 +26,7 @@ class DeprecationTest extends SapphireTest
|
|||||||
// - Allow the use of expectDeprecation(), which doesn't work with E_USER_DEPRECATION by default
|
// - Allow the use of expectDeprecation(), which doesn't work with E_USER_DEPRECATION by default
|
||||||
// https://github.com/laminas/laminas-di/pull/30#issuecomment-927585210
|
// https://github.com/laminas/laminas-di/pull/30#issuecomment-927585210
|
||||||
parent::setup();
|
parent::setup();
|
||||||
|
$this->noticesWereEnabled = Deprecation::isEnabled();
|
||||||
$this->oldHandler = set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
|
$this->oldHandler = set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
|
||||||
if ($errno === E_USER_DEPRECATED) {
|
if ($errno === E_USER_DEPRECATED) {
|
||||||
if (str_contains($errstr, 'SilverStripe\\Dev\\Tests\\DeprecationTest')) {
|
if (str_contains($errstr, 'SilverStripe\\Dev\\Tests\\DeprecationTest')) {
|
||||||
@ -42,23 +46,140 @@ class DeprecationTest extends SapphireTest
|
|||||||
|
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
|
if (!$this->noticesWereEnabled) {
|
||||||
Deprecation::disable();
|
Deprecation::disable();
|
||||||
|
}
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
$this->oldHandler = null;
|
$this->oldHandler = null;
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function myDeprecatedMethod(): string
|
||||||
|
{
|
||||||
|
Deprecation::notice('1.2.3', 'My message');
|
||||||
|
return 'abc';
|
||||||
|
}
|
||||||
|
|
||||||
public function testNotice()
|
public function testNotice()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
'SilverStripe\Dev\Tests\DeprecationTest->testNotice is deprecated.',
|
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
||||||
'My message.',
|
'My message.',
|
||||||
'Called from PHPUnit\Framework\TestCase->runTest.'
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testNotice.'
|
||||||
]);
|
]);
|
||||||
$this->expectDeprecation();
|
$this->expectDeprecation();
|
||||||
$this->expectDeprecationMessage($message);
|
$this->expectDeprecationMessage($message);
|
||||||
Deprecation::enable();
|
Deprecation::enable();
|
||||||
Deprecation::notice('1.2.3', 'My message');
|
$ret = $this->myDeprecatedMethod();
|
||||||
|
$this->assertSame('abc', $ret);
|
||||||
|
// call outputNotices() directly because the regular shutdown function that emits
|
||||||
|
// the notices within Deprecation won't be called until after this unit-test has finished
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCallUserFunc()
|
||||||
|
{
|
||||||
|
$message = implode(' ', [
|
||||||
|
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
||||||
|
'My message.',
|
||||||
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testCallUserFunc.'
|
||||||
|
]);
|
||||||
|
$this->expectDeprecation();
|
||||||
|
$this->expectDeprecationMessage($message);
|
||||||
|
Deprecation::enable();
|
||||||
|
$ret = call_user_func([$this, 'myDeprecatedMethod']);
|
||||||
|
$this->assertSame('abc', $ret);
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCallUserFuncArray()
|
||||||
|
{
|
||||||
|
$message = implode(' ', [
|
||||||
|
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
||||||
|
'My message.',
|
||||||
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testCallUserFuncArray.'
|
||||||
|
]);
|
||||||
|
$this->expectDeprecation();
|
||||||
|
$this->expectDeprecationMessage($message);
|
||||||
|
Deprecation::enable();
|
||||||
|
$ret = call_user_func_array([$this, 'myDeprecatedMethod'], []);
|
||||||
|
$this->assertSame('abc', $ret);
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWithNoReplacementDefault()
|
||||||
|
{
|
||||||
|
Deprecation::enable();
|
||||||
|
$ret = Deprecation::withNoReplacement(function () {
|
||||||
|
return $this->myDeprecatedMethod();
|
||||||
|
});
|
||||||
|
$this->assertSame('abc', $ret);
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWithNoReplacementTrue()
|
||||||
|
{
|
||||||
|
$message = implode(' ', [
|
||||||
|
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
||||||
|
'My message.',
|
||||||
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrue.'
|
||||||
|
]);
|
||||||
|
$this->expectDeprecation();
|
||||||
|
$this->expectDeprecationMessage($message);
|
||||||
|
Deprecation::enable(true);
|
||||||
|
$ret = Deprecation::withNoReplacement(function () {
|
||||||
|
return $this->myDeprecatedMethod();
|
||||||
|
});
|
||||||
|
$this->assertSame('abc', $ret);
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testWithNoReplacementTrueCallUserFunc()
|
||||||
|
{
|
||||||
|
$message = implode(' ', [
|
||||||
|
'SilverStripe\Dev\Tests\DeprecationTest->myDeprecatedMethod is deprecated.',
|
||||||
|
'My message.',
|
||||||
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testWithNoReplacementTrueCallUserFunc.'
|
||||||
|
]);
|
||||||
|
$this->expectDeprecation();
|
||||||
|
$this->expectDeprecationMessage($message);
|
||||||
|
Deprecation::enable(true);
|
||||||
|
$ret = Deprecation::withNoReplacement(function () {
|
||||||
|
return call_user_func([$this, 'myDeprecatedMethod']);
|
||||||
|
});
|
||||||
|
$this->assertSame('abc', $ret);
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testClassWithNoReplacement()
|
||||||
|
{
|
||||||
|
$message = implode(' ', [
|
||||||
|
'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.',
|
||||||
|
'Some class message.',
|
||||||
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithNoReplacement.'
|
||||||
|
]);
|
||||||
|
$this->expectDeprecation();
|
||||||
|
$this->expectDeprecationMessage($message);
|
||||||
|
Deprecation::enable(true);
|
||||||
|
// using this syntax because my IDE was complaining about DeprecationTestObject not existing
|
||||||
|
// when trying to use `new DeprecationTestObject();`
|
||||||
|
$class = DeprecationTestObject::class;
|
||||||
|
new $class();
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testClassWithInjectorWithNoReplacement()
|
||||||
|
{
|
||||||
|
$message = implode(' ', [
|
||||||
|
'SilverStripe\Dev\Tests\DeprecationTest\DeprecationTestObject is deprecated.',
|
||||||
|
'Some class message.',
|
||||||
|
'Called from SilverStripe\Dev\Tests\DeprecationTest->testClassWithInjectorWithNoReplacement.'
|
||||||
|
]);
|
||||||
|
$this->expectDeprecation();
|
||||||
|
$this->expectDeprecationMessage($message);
|
||||||
|
Deprecation::enable(true);
|
||||||
|
Injector::inst()->get(DeprecationTestObject::class);
|
||||||
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,8 +187,12 @@ class DeprecationTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testDisabled()
|
public function testDisabled()
|
||||||
{
|
{
|
||||||
|
if ($this->noticesWereEnabled) {
|
||||||
|
$this->markTestSkipped('Notices are enabled for this project outside of this unit test');
|
||||||
|
}
|
||||||
// test that no error error is raised because by default Deprecation is disabled
|
// test that no error error is raised because by default Deprecation is disabled
|
||||||
Deprecation::notice('4.5.6', 'My message');
|
$this->myDeprecatedMethod();
|
||||||
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following tests would be better to put in the silverstripe/config module, however this is not
|
// The following tests would be better to put in the silverstripe/config module, however this is not
|
||||||
@ -76,7 +201,6 @@ class DeprecationTest extends SapphireTest
|
|||||||
// Adding a _config.php file will break existing unit-tests within silverstripe/config
|
// Adding a _config.php file will break existing unit-tests within silverstripe/config
|
||||||
// It is possible to put DeprecationTestObject in framework and the unit tests in config, however
|
// It is possible to put DeprecationTestObject in framework and the unit tests in config, however
|
||||||
// that's probably messier then just having everything within framework
|
// that's probably messier then just having everything within framework
|
||||||
|
|
||||||
public function testConfigGetFirst()
|
public function testConfigGetFirst()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
@ -87,6 +211,7 @@ class DeprecationTest extends SapphireTest
|
|||||||
$this->expectDeprecationMessage($message);
|
$this->expectDeprecationMessage($message);
|
||||||
Deprecation::enable();
|
Deprecation::enable();
|
||||||
Config::inst()->get(DeprecationTestObject::class, 'first_config');
|
Config::inst()->get(DeprecationTestObject::class, 'first_config');
|
||||||
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigGetSecond()
|
public function testConfigGetSecond()
|
||||||
@ -99,6 +224,7 @@ class DeprecationTest extends SapphireTest
|
|||||||
$this->expectDeprecationMessage($message);
|
$this->expectDeprecationMessage($message);
|
||||||
Deprecation::enable();
|
Deprecation::enable();
|
||||||
Config::inst()->get(DeprecationTestObject::class, 'second_config');
|
Config::inst()->get(DeprecationTestObject::class, 'second_config');
|
||||||
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigGetThird()
|
public function testConfigGetThird()
|
||||||
@ -108,6 +234,7 @@ class DeprecationTest extends SapphireTest
|
|||||||
$this->expectDeprecationMessage($message);
|
$this->expectDeprecationMessage($message);
|
||||||
Deprecation::enable();
|
Deprecation::enable();
|
||||||
Config::inst()->get(DeprecationTestObject::class, 'third_config');
|
Config::inst()->get(DeprecationTestObject::class, 'third_config');
|
||||||
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigSet()
|
public function testConfigSet()
|
||||||
@ -120,6 +247,7 @@ class DeprecationTest extends SapphireTest
|
|||||||
$this->expectDeprecationMessage($message);
|
$this->expectDeprecationMessage($message);
|
||||||
Deprecation::enable();
|
Deprecation::enable();
|
||||||
Config::modify()->set(DeprecationTestObject::class, 'first_config', 'abc');
|
Config::modify()->set(DeprecationTestObject::class, 'first_config', 'abc');
|
||||||
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfigMerge()
|
public function testConfigMerge()
|
||||||
@ -132,5 +260,6 @@ class DeprecationTest extends SapphireTest
|
|||||||
$this->expectDeprecationMessage($message);
|
$this->expectDeprecationMessage($message);
|
||||||
Deprecation::enable();
|
Deprecation::enable();
|
||||||
Config::modify()->merge(DeprecationTestObject::class, 'array_config', ['abc']);
|
Config::modify()->merge(DeprecationTestObject::class, 'array_config', ['abc']);
|
||||||
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,22 @@ namespace SilverStripe\Dev\Tests\DeprecationTest;
|
|||||||
|
|
||||||
use SilverStripe\Dev\TestOnly;
|
use SilverStripe\Dev\TestOnly;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
class DeprecationTestObject extends DataObject implements TestOnly
|
class DeprecationTestObject extends DataObject implements TestOnly
|
||||||
{
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
|
Deprecation::notice(
|
||||||
|
'1.2.3',
|
||||||
|
'Some class message',
|
||||||
|
Deprecation::SCOPE_CLASS
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private static $db = [
|
private static $db = [
|
||||||
"Name" => "Varchar"
|
"Name" => "Varchar"
|
||||||
];
|
];
|
||||||
|
@ -18,7 +18,7 @@ class DevAdminControllerTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
DevelopmentAdmin::config()->update(
|
DevelopmentAdmin::config()->merge(
|
||||||
'registered_controllers',
|
'registered_controllers',
|
||||||
[
|
[
|
||||||
'x1' => [
|
'x1' => [
|
||||||
|
@ -200,7 +200,7 @@ class ConfirmedPasswordFieldTest extends SapphireTest
|
|||||||
$this->assertSame($expectValid, $result, 'Validate method should return its result');
|
$this->assertSame($expectValid, $result, 'Validate method should return its result');
|
||||||
$this->assertSame($expectValid, $validator->getResult()->isValid());
|
$this->assertSame($expectValid, $validator->getResult()->isValid());
|
||||||
if ($expectedMessage) {
|
if ($expectedMessage) {
|
||||||
$this->assertStringContainsString($expectedMessage, $validator->getResult()->serialize());
|
$this->assertStringContainsString($expectedMessage, json_encode($validator->getResult()->__serialize()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ class ConfirmedPasswordFieldTest extends SapphireTest
|
|||||||
$this->assertFalse($validator->getResult()->isValid());
|
$this->assertFalse($validator->getResult()->isValid());
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
'Passwords must have at least one digit and one alphanumeric character',
|
'Passwords must have at least one digit and one alphanumeric character',
|
||||||
$validator->getResult()->serialize()
|
json_encode($validator->getResult()->__serialize())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ class ConfirmedPasswordFieldTest extends SapphireTest
|
|||||||
$this->assertFalse($validator->getResult()->isValid());
|
$this->assertFalse($validator->getResult()->isValid());
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
'You must enter your current password',
|
'You must enter your current password',
|
||||||
$validator->getResult()->serialize()
|
json_encode($validator->getResult()->__serialize())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ class ConfirmedPasswordFieldTest extends SapphireTest
|
|||||||
$this->assertFalse($validator->getResult()->isValid());
|
$this->assertFalse($validator->getResult()->isValid());
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
'You must be logged in to change your password',
|
'You must be logged in to change your password',
|
||||||
$validator->getResult()->serialize()
|
json_encode($validator->getResult()->__serialize())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ class ConfirmedPasswordFieldTest extends SapphireTest
|
|||||||
$this->assertFalse($validator->getResult()->isValid());
|
$this->assertFalse($validator->getResult()->isValid());
|
||||||
$this->assertStringContainsString(
|
$this->assertStringContainsString(
|
||||||
'The current password you have entered is not correct',
|
'The current password you have entered is not correct',
|
||||||
$validator->getResult()->serialize()
|
json_encode($validator->getResult()->__serialize())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class CurrencyFieldDisabledTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testFieldWithCustomisedCurrencySymbol()
|
public function testFieldWithCustomisedCurrencySymbol()
|
||||||
{
|
{
|
||||||
DBCurrency::config()->update('currency_symbol', '€');
|
DBCurrency::config()->set('currency_symbol', '€');
|
||||||
$field = new CurrencyField_Disabled('Test', '', '€5.00');
|
$field = new CurrencyField_Disabled('Test', '', '€5.00');
|
||||||
$result = $field->Field();
|
$result = $field->Field();
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class CurrencyFieldReadonlyTest extends SapphireTest
|
|||||||
|
|
||||||
public function testFieldWithOutValue()
|
public function testFieldWithOutValue()
|
||||||
{
|
{
|
||||||
DBCurrency::config()->update('currency_symbol', 'AUD');
|
DBCurrency::config()->set('currency_symbol', 'AUD');
|
||||||
$field = new CurrencyField_Readonly('Test', '', null);
|
$field = new CurrencyField_Readonly('Test', '', null);
|
||||||
$result = $field->Field();
|
$result = $field->Field();
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class CurrencyFieldReadonlyTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testFieldWithCustomisedCurrencySymbol()
|
public function testFieldWithCustomisedCurrencySymbol()
|
||||||
{
|
{
|
||||||
DBCurrency::config()->update('currency_symbol', '€');
|
DBCurrency::config()->set('currency_symbol', '€');
|
||||||
$field = new CurrencyField_Readonly('Test', '', '€5.00');
|
$field = new CurrencyField_Readonly('Test', '', '€5.00');
|
||||||
$result = $field->Field();
|
$result = $field->Field();
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class CurrencyFieldTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
|
|
||||||
//tests with updated currency symbol setting
|
//tests with updated currency symbol setting
|
||||||
DBCurrency::config()->update('currency_symbol', '€');
|
DBCurrency::config()->set('currency_symbol', '€');
|
||||||
|
|
||||||
$f->setValue('123.45');
|
$f->setValue('123.45');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
@ -180,7 +180,7 @@ class CurrencyFieldTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
|
|
||||||
//update currency symbol via config
|
//update currency symbol via config
|
||||||
DBCurrency::config()->update('currency_symbol', '€');
|
DBCurrency::config()->set('currency_symbol', '€');
|
||||||
|
|
||||||
$f->setValue('123.45');
|
$f->setValue('123.45');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -263,7 +263,7 @@ class CurrencyFieldTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
|
|
||||||
//tests with updated currency symbol setting
|
//tests with updated currency symbol setting
|
||||||
DBCurrency::config()->update('currency_symbol', '€');
|
DBCurrency::config()->set('currency_symbol', '€');
|
||||||
|
|
||||||
$f->setValue('€123.45');
|
$f->setValue('€123.45');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -302,11 +302,14 @@ class CurrencyFieldTest extends SapphireTest
|
|||||||
$field = new CurrencyField('Test', '', '$5.00');
|
$field = new CurrencyField('Test', '', '$5.00');
|
||||||
$validator = new RequiredFields();
|
$validator = new RequiredFields();
|
||||||
|
|
||||||
DBCurrency::config()->update('currency_symbol', '€');
|
DBCurrency::config()->set('currency_symbol', '€');
|
||||||
$result = $field->validate($validator);
|
$result = $field->validate($validator);
|
||||||
|
|
||||||
$this->assertFalse($result, 'Validation should fail since wrong currency was used');
|
$this->assertFalse($result, 'Validation should fail since wrong currency was used');
|
||||||
$this->assertFalse($validator->getResult()->isValid(), 'Validator should receive failed state');
|
$this->assertFalse($validator->getResult()->isValid(), 'Validator should receive failed state');
|
||||||
$this->assertStringContainsString('Please enter a valid currency', $validator->getResult()->serialize());
|
$this->assertStringContainsString(
|
||||||
|
'Please enter a valid currency',
|
||||||
|
json_encode($validator->getResult()->__serialize())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class FormFieldTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
Config::nest();
|
Config::nest();
|
||||||
|
|
||||||
FormField::config()->update(
|
FormField::config()->merge(
|
||||||
'default_classes',
|
'default_classes',
|
||||||
[
|
[
|
||||||
'class1',
|
'class1',
|
||||||
@ -42,7 +42,7 @@ class FormFieldTest extends SapphireTest
|
|||||||
|
|
||||||
$this->assertStringContainsString('class1', $field->extraClass(), 'Class list does not contain expected class');
|
$this->assertStringContainsString('class1', $field->extraClass(), 'Class list does not contain expected class');
|
||||||
|
|
||||||
FormField::config()->update(
|
FormField::config()->merge(
|
||||||
'default_classes',
|
'default_classes',
|
||||||
[
|
[
|
||||||
'class1',
|
'class1',
|
||||||
@ -54,7 +54,7 @@ class FormFieldTest extends SapphireTest
|
|||||||
|
|
||||||
$this->assertStringContainsString('class1 class2', $field->extraClass(), 'Class list does not contain expected class');
|
$this->assertStringContainsString('class1 class2', $field->extraClass(), 'Class list does not contain expected class');
|
||||||
|
|
||||||
FormField::config()->update(
|
FormField::config()->merge(
|
||||||
'default_classes',
|
'default_classes',
|
||||||
[
|
[
|
||||||
'class3',
|
'class3',
|
||||||
@ -69,7 +69,7 @@ class FormFieldTest extends SapphireTest
|
|||||||
|
|
||||||
$this->assertStringNotContainsString('class3', $field->extraClass(), 'Class list contains unexpected class');
|
$this->assertStringNotContainsString('class3', $field->extraClass(), 'Class list contains unexpected class');
|
||||||
|
|
||||||
TextField::config()->update(
|
TextField::config()->merge(
|
||||||
'default_classes',
|
'default_classes',
|
||||||
[
|
[
|
||||||
'textfield-class',
|
'textfield-class',
|
||||||
|
@ -792,7 +792,7 @@ class FormTest extends FunctionalTest
|
|||||||
|
|
||||||
public function testDefaultClasses()
|
public function testDefaultClasses()
|
||||||
{
|
{
|
||||||
Form::config()->update(
|
Form::config()->merge(
|
||||||
'default_classes',
|
'default_classes',
|
||||||
[
|
[
|
||||||
'class1',
|
'class1',
|
||||||
@ -803,7 +803,7 @@ class FormTest extends FunctionalTest
|
|||||||
|
|
||||||
$this->assertStringContainsString('class1', $form->extraClass(), 'Class list does not contain expected class');
|
$this->assertStringContainsString('class1', $form->extraClass(), 'Class list does not contain expected class');
|
||||||
|
|
||||||
Form::config()->update(
|
Form::config()->merge(
|
||||||
'default_classes',
|
'default_classes',
|
||||||
[
|
[
|
||||||
'class1',
|
'class1',
|
||||||
@ -815,7 +815,7 @@ class FormTest extends FunctionalTest
|
|||||||
|
|
||||||
$this->assertStringContainsString('class1 class2', $form->extraClass(), 'Class list does not contain expected class');
|
$this->assertStringContainsString('class1 class2', $form->extraClass(), 'Class list does not contain expected class');
|
||||||
|
|
||||||
Form::config()->update(
|
Form::config()->merge(
|
||||||
'default_classes',
|
'default_classes',
|
||||||
[
|
[
|
||||||
'class3',
|
'class3',
|
||||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\Logging\Tests;
|
|||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Logging\MonologErrorHandler;
|
use SilverStripe\Logging\MonologErrorHandler;
|
||||||
|
|
||||||
@ -26,8 +27,10 @@ class MonologErrorHandlerTest extends SapphireTest
|
|||||||
$handler->pushLogger($logger)->pushLogger($logger);
|
$handler->pushLogger($logger)->pushLogger($logger);
|
||||||
$this->assertCount(2, $handler->getLoggers(), 'Loggers are pushed to the stack');
|
$this->assertCount(2, $handler->getLoggers(), 'Loggers are pushed to the stack');
|
||||||
|
|
||||||
|
if (!Deprecation::isEnabled()) {
|
||||||
$handler->setLogger($logger);
|
$handler->setLogger($logger);
|
||||||
$this->assertCount(1, $handler->getLoggers(), 'setLogger resets stack and pushes');
|
$this->assertCount(1, $handler->getLoggers(), 'setLogger resets stack and pushes');
|
||||||
|
}
|
||||||
|
|
||||||
$handler->setLoggers([]);
|
$handler->setLoggers([]);
|
||||||
$this->assertCount(0, $handler->getLoggers(), 'setLoggers overwrites all configured loggers');
|
$this->assertCount(0, $handler->getLoggers(), 'setLoggers overwrites all configured loggers');
|
||||||
|
@ -133,6 +133,21 @@ class ArrayListTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLimitNull()
|
||||||
|
{
|
||||||
|
$list = new ArrayList(
|
||||||
|
[
|
||||||
|
['Key' => 1], ['Key' => 2], ['Key' => 3]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$list->limit(null, 0)->toArray(),
|
||||||
|
[
|
||||||
|
['Key' => 1], ['Key' => 2], ['Key' => 3]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAddRemove()
|
public function testAddRemove()
|
||||||
{
|
{
|
||||||
$list = new ArrayList(
|
$list = new ArrayList(
|
||||||
|
@ -101,7 +101,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest
|
|||||||
// Table will have been initially created by the $extraDataObjects setting
|
// Table will have been initially created by the $extraDataObjects setting
|
||||||
|
|
||||||
// Let's insert a new field here
|
// Let's insert a new field here
|
||||||
TestObject::config()->update(
|
TestObject::config()->merge(
|
||||||
'db',
|
'db',
|
||||||
[
|
[
|
||||||
'SecretField' => 'Varchar(100)'
|
'SecretField' => 'Varchar(100)'
|
||||||
@ -170,7 +170,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest
|
|||||||
// Table will have been initially created by the $extraDataObjects setting
|
// Table will have been initially created by the $extraDataObjects setting
|
||||||
|
|
||||||
// Update the SearchFields index here
|
// Update the SearchFields index here
|
||||||
TestIndexObject::config()->update(
|
TestIndexObject::config()->merge(
|
||||||
'indexes',
|
'indexes',
|
||||||
[
|
[
|
||||||
'SearchFields' => [
|
'SearchFields' => [
|
||||||
@ -265,35 +265,35 @@ class DataObjectSchemaGenerationTest extends SapphireTest
|
|||||||
'columns' => ['Sort'],
|
'columns' => ['Sort'],
|
||||||
], $indexes);
|
], $indexes);
|
||||||
DataObject::getSchema()->reset();
|
DataObject::getSchema()->reset();
|
||||||
Config::inst()->update(SortedObject::class, 'default_sort', 'Sort ASC');
|
Config::inst()->set(SortedObject::class, 'default_sort', 'Sort ASC');
|
||||||
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
||||||
$this->assertContains([
|
$this->assertContains([
|
||||||
'type' => 'index',
|
'type' => 'index',
|
||||||
'columns' => ['Sort'],
|
'columns' => ['Sort'],
|
||||||
], $indexes);
|
], $indexes);
|
||||||
DataObject::getSchema()->reset();
|
DataObject::getSchema()->reset();
|
||||||
Config::inst()->update(SortedObject::class, 'default_sort', 'Sort DESC');
|
Config::inst()->set(SortedObject::class, 'default_sort', 'Sort DESC');
|
||||||
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
||||||
$this->assertContains([
|
$this->assertContains([
|
||||||
'type' => 'index',
|
'type' => 'index',
|
||||||
'columns' => ['Sort'],
|
'columns' => ['Sort'],
|
||||||
], $indexes);
|
], $indexes);
|
||||||
DataObject::getSchema()->reset();
|
DataObject::getSchema()->reset();
|
||||||
Config::inst()->update(SortedObject::class, 'default_sort', '"Sort" DESC');
|
Config::inst()->set(SortedObject::class, 'default_sort', '"Sort" DESC');
|
||||||
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
||||||
$this->assertContains([
|
$this->assertContains([
|
||||||
'type' => 'index',
|
'type' => 'index',
|
||||||
'columns' => ['Sort'],
|
'columns' => ['Sort'],
|
||||||
], $indexes);
|
], $indexes);
|
||||||
DataObject::getSchema()->reset();
|
DataObject::getSchema()->reset();
|
||||||
Config::inst()->update(SortedObject::class, 'default_sort', '"DataObjectSchemaGenerationTest_SortedObject"."Sort" ASC');
|
Config::inst()->set(SortedObject::class, 'default_sort', '"DataObjectSchemaGenerationTest_SortedObject"."Sort" ASC');
|
||||||
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
||||||
$this->assertContains([
|
$this->assertContains([
|
||||||
'type' => 'index',
|
'type' => 'index',
|
||||||
'columns' => ['Sort'],
|
'columns' => ['Sort'],
|
||||||
], $indexes);
|
], $indexes);
|
||||||
DataObject::getSchema()->reset();
|
DataObject::getSchema()->reset();
|
||||||
Config::inst()->update(SortedObject::class, 'default_sort', '"Sort" DESC, "Title" ASC');
|
Config::inst()->set(SortedObject::class, 'default_sort', '"Sort" DESC, "Title" ASC');
|
||||||
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
$indexes = DataObject::getSchema()->databaseIndexes(SortedObject::class);
|
||||||
$this->assertContains([
|
$this->assertContains([
|
||||||
'type' => 'index',
|
'type' => 'index',
|
||||||
@ -305,7 +305,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest
|
|||||||
], $indexes);
|
], $indexes);
|
||||||
DataObject::getSchema()->reset();
|
DataObject::getSchema()->reset();
|
||||||
// make sure that specific indexes aren't overwritten
|
// make sure that specific indexes aren't overwritten
|
||||||
Config::inst()->update(SortedObject::class, 'indexes', [
|
Config::inst()->merge(SortedObject::class, 'indexes', [
|
||||||
'Sort' => [
|
'Sort' => [
|
||||||
'type' => 'unique',
|
'type' => 'unique',
|
||||||
'columns' => ['Sort'],
|
'columns' => ['Sort'],
|
||||||
|
@ -37,7 +37,7 @@ class HierachyCacheTest extends SapphireTest
|
|||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
parent::setUpBeforeClass();
|
parent::setUpBeforeClass();
|
||||||
HideTestObject::config()->update(
|
HideTestObject::config()->merge(
|
||||||
'hide_from_hierarchy',
|
'hide_from_hierarchy',
|
||||||
[ HideTestSubObject::class ]
|
[ HideTestSubObject::class ]
|
||||||
);
|
);
|
||||||
|
@ -273,7 +273,7 @@ class HierarchyTest extends SapphireTest
|
|||||||
|
|
||||||
public function testHideFromHierarchy()
|
public function testHideFromHierarchy()
|
||||||
{
|
{
|
||||||
HierarchyTest\HideTestObject::config()->update(
|
HierarchyTest\HideTestObject::config()->merge(
|
||||||
'hide_from_hierarchy',
|
'hide_from_hierarchy',
|
||||||
[ HierarchyTest\HideTestSubObject::class ]
|
[ HierarchyTest\HideTestSubObject::class ]
|
||||||
);
|
);
|
||||||
|
@ -423,7 +423,7 @@ class ManyManyListTest extends SapphireTest
|
|||||||
$obj->Clients()->add($obj2, ['Worth' => $money, 'Reference' => 'B']);
|
$obj->Clients()->add($obj2, ['Worth' => $money, 'Reference' => 'B']);
|
||||||
|
|
||||||
// Set the default sort for this relation
|
// Set the default sort for this relation
|
||||||
Config::inst()->update('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference ASC');
|
Config::inst()->set('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference ASC');
|
||||||
$clients = $obj->Clients();
|
$clients = $obj->Clients();
|
||||||
$this->assertCount(2, $clients);
|
$this->assertCount(2, $clients);
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ class ManyManyListTest extends SapphireTest
|
|||||||
$this->assertEquals('B', $second->Reference);
|
$this->assertEquals('B', $second->Reference);
|
||||||
|
|
||||||
// Now we ensure the default sort is being respected by reversing its order
|
// Now we ensure the default sort is being respected by reversing its order
|
||||||
Config::inst()->update('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference DESC');
|
Config::inst()->set('ManyManyListTest_ExtraFields_Clients', 'default_sort', 'Reference DESC');
|
||||||
$reverseClients = $obj->Clients();
|
$reverseClients = $obj->Clients();
|
||||||
$this->assertCount(2, $reverseClients);
|
$this->assertCount(2, $reverseClients);
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ class ManyManyThroughListTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
DataObject::reset();
|
DataObject::reset();
|
||||||
ManyManyThroughListTest\Item::config()->update(
|
ManyManyThroughListTest\Item::config()->merge(
|
||||||
'db',
|
'db',
|
||||||
[
|
[
|
||||||
ManyManyThroughListTest\JoinObject::class => 'Text'
|
ManyManyThroughListTest\JoinObject::class => 'Text'
|
||||||
@ -416,7 +416,7 @@ class ManyManyThroughListTest extends SapphireTest
|
|||||||
$this->assertSame('International', $second->Title);
|
$this->assertSame('International', $second->Title);
|
||||||
|
|
||||||
// Ensure that we're respecting the default sort by reversing it
|
// Ensure that we're respecting the default sort by reversing it
|
||||||
Config::inst()->update(FallbackLocale::class, 'default_sort', '"ManyManyThroughTest_FallbackLocale"."Sort" DESC');
|
Config::inst()->set(FallbackLocale::class, 'default_sort', '"ManyManyThroughTest_FallbackLocale"."Sort" DESC');
|
||||||
|
|
||||||
$reverse = $mexico->Fallbacks();
|
$reverse = $mexico->Fallbacks();
|
||||||
list($firstReverse, $secondReverse) = $reverse;
|
list($firstReverse, $secondReverse) = $reverse;
|
||||||
|
@ -10,6 +10,7 @@ use SilverStripe\Dev\TestOnly;
|
|||||||
use SilverStripe\ORM\Tests\MySQLPDOConnectorTest\PDOConnector;
|
use SilverStripe\ORM\Tests\MySQLPDOConnectorTest\PDOConnector;
|
||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\Tests\ORM\Utf8\Utf8TestHelper;
|
use SilverStripe\Tests\ORM\Utf8\Utf8TestHelper;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @requires extension PDO
|
* @requires extension PDO
|
||||||
@ -22,6 +23,9 @@ class MySQLPDOConnectorTest extends SapphireTest implements TestOnly
|
|||||||
*/
|
*/
|
||||||
public function testConnectionCharsetControl($charset, $defaultCollation)
|
public function testConnectionCharsetControl($charset, $defaultCollation)
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$config = DB::getConfig();
|
$config = DB::getConfig();
|
||||||
$config['driver'] = 'mysql';
|
$config['driver'] = 'mysql';
|
||||||
$config['charset'] = $charset;
|
$config['charset'] = $charset;
|
||||||
@ -51,6 +55,9 @@ class MySQLPDOConnectorTest extends SapphireTest implements TestOnly
|
|||||||
*/
|
*/
|
||||||
public function testConnectionCollationControl($charset, $defaultCollation, $customCollation)
|
public function testConnectionCollationControl($charset, $defaultCollation, $customCollation)
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$config = DB::getConfig();
|
$config = DB::getConfig();
|
||||||
$config['charset'] = $charset;
|
$config['charset'] = $charset;
|
||||||
$config['driver'] = 'mysql';
|
$config['driver'] = 'mysql';
|
||||||
@ -86,6 +93,9 @@ class MySQLPDOConnectorTest extends SapphireTest implements TestOnly
|
|||||||
|
|
||||||
public function testUtf8mb4GeneralCollation()
|
public function testUtf8mb4GeneralCollation()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$charset = 'utf8mb4';
|
$charset = 'utf8mb4';
|
||||||
$collation = 'utf8mb4_general_ci';
|
$collation = 'utf8mb4_general_ci';
|
||||||
|
|
||||||
@ -113,6 +123,9 @@ class MySQLPDOConnectorTest extends SapphireTest implements TestOnly
|
|||||||
|
|
||||||
public function testUtf8mb4UnicodeCollation()
|
public function testUtf8mb4UnicodeCollation()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$charset = 'utf8mb4';
|
$charset = 'utf8mb4';
|
||||||
$collation = 'utf8mb4_unicode_ci';
|
$collation = 'utf8mb4_unicode_ci';
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ use SilverStripe\ORM\Connect\MySQLDatabase;
|
|||||||
use SilverStripe\ORM\Queries\SQLSelect;
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
use SilverStripe\SQLite\SQLite3Database;
|
use SilverStripe\SQLite\SQLite3Database;
|
||||||
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
||||||
use SilverStripe\Dev\Deprecation;
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
class SQLSelectTest extends SapphireTest
|
class SQLSelectTest extends SapphireTest
|
||||||
@ -24,18 +23,6 @@ class SQLSelectTest extends SapphireTest
|
|||||||
|
|
||||||
protected $oldDeprecation = null;
|
protected $oldDeprecation = null;
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->oldDeprecation = Deprecation::dump_settings();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown(): void
|
|
||||||
{
|
|
||||||
Deprecation::restore_settings($this->oldDeprecation);
|
|
||||||
parent::tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCount()
|
public function testCount()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ namespace SilverStripe\ORM\Tests;
|
|||||||
use SilverStripe\ORM\DB;
|
use SilverStripe\ORM\DB;
|
||||||
use SilverStripe\ORM\DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\Dev\Deprecation;
|
|
||||||
use SilverStripe\ORM\Tests\TransactionTest\TestObject;
|
use SilverStripe\ORM\Tests\TransactionTest\TestObject;
|
||||||
|
|
||||||
class TransactionTest extends SapphireTest
|
class TransactionTest extends SapphireTest
|
||||||
@ -20,18 +19,6 @@ class TransactionTest extends SapphireTest
|
|||||||
|
|
||||||
private static $originalVersionInfo;
|
private static $originalVersionInfo;
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
self::$originalVersionInfo = Deprecation::dump_settings();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function tearDown(): void
|
|
||||||
{
|
|
||||||
Deprecation::restore_settings(self::$originalVersionInfo);
|
|
||||||
parent::tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function setUpBeforeClass(): void
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
parent::setUpBeforeClass();
|
parent::setUpBeforeClass();
|
||||||
@ -166,9 +153,6 @@ class TransactionTest extends SapphireTest
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This feature is deprecated in 4.4, but we're still testing it.
|
|
||||||
Deprecation::notification_version('4.3.0');
|
|
||||||
|
|
||||||
$page = new TestObject();
|
$page = new TestObject();
|
||||||
$page->Title = 'Read only success';
|
$page->Title = 'Read only success';
|
||||||
$page->write();
|
$page->write();
|
||||||
|
@ -15,10 +15,6 @@ class SessionAuthenticationHandlerTest extends SapphireTest
|
|||||||
|
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* @runInSeparateProcess
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
*/
|
|
||||||
public function testAuthenticateRequestDefersSessionStartWithoutSessionIdentifier()
|
public function testAuthenticateRequestDefersSessionStartWithoutSessionIdentifier()
|
||||||
{
|
{
|
||||||
$member = new Member(['Email' => 'test@example.com']);
|
$member = new Member(['Email' => 'test@example.com']);
|
||||||
@ -36,10 +32,6 @@ class SessionAuthenticationHandlerTest extends SapphireTest
|
|||||||
$this->assertNull($matchedMember);
|
$this->assertNull($matchedMember);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @runInSeparateProcess
|
|
||||||
* @preserveGlobalState disabled
|
|
||||||
*/
|
|
||||||
public function testAuthenticateRequestStartsSessionWithSessionIdentifier()
|
public function testAuthenticateRequestStartsSessionWithSessionIdentifier()
|
||||||
{
|
{
|
||||||
$member = new Member(['Email' => 'test@example.com']);
|
$member = new Member(['Email' => 'test@example.com']);
|
||||||
@ -49,12 +41,13 @@ class SessionAuthenticationHandlerTest extends SapphireTest
|
|||||||
|
|
||||||
$session = new Session(null); // unstarted
|
$session = new Session(null); // unstarted
|
||||||
$session->set($handler->getSessionVariable(), $member->ID);
|
$session->set($handler->getSessionVariable(), $member->ID);
|
||||||
|
$session = new Session($session); // started
|
||||||
|
|
||||||
$req = new HTTPRequest('GET', '/');
|
$req = new HTTPRequest('GET', '/');
|
||||||
$req->setSession($session);
|
$req->setSession($session);
|
||||||
|
|
||||||
|
// simulate detection of session cookie
|
||||||
Cookie::set(session_name(), '1234');
|
Cookie::set(session_name(), '1234');
|
||||||
$session->start($req); // simulate detection of session cookie
|
|
||||||
|
|
||||||
$matchedMember = $handler->authenticateRequest($req);
|
$matchedMember = $handler->authenticateRequest($req);
|
||||||
$this->assertNotNull($matchedMember);
|
$this->assertNotNull($matchedMember);
|
||||||
|
@ -9,6 +9,7 @@ use SilverStripe\Security\Member;
|
|||||||
use SilverStripe\Security\PasswordValidator;
|
use SilverStripe\Security\PasswordValidator;
|
||||||
use SilverStripe\Security\Security;
|
use SilverStripe\Security\Security;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
||||||
|
|
||||||
class MemberCsvBulkLoaderTest extends SapphireTest
|
class MemberCsvBulkLoaderTest extends SapphireTest
|
||||||
{
|
{
|
||||||
@ -105,7 +106,8 @@ class MemberCsvBulkLoaderTest extends SapphireTest
|
|||||||
|
|
||||||
// TODO Direct getter doesn't work, wtf!
|
// TODO Direct getter doesn't work, wtf!
|
||||||
$this->assertEquals(Security::config()->password_encryption_algorithm, $member->getField('PasswordEncryption'));
|
$this->assertEquals(Security::config()->password_encryption_algorithm, $member->getField('PasswordEncryption'));
|
||||||
$result = $member->checkPassword('mypassword');
|
$auth = new MemberAuthenticator();
|
||||||
|
$result = $auth->checkPassword($member, 'mypassword');
|
||||||
$this->assertTrue($result->isValid());
|
$this->assertTrue($result->isValid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ class MemberTest extends FunctionalTest
|
|||||||
*/
|
*/
|
||||||
public function testChangedPasswordEmaling()
|
public function testChangedPasswordEmaling()
|
||||||
{
|
{
|
||||||
Member::config()->update('notify_password_change', true);
|
Member::config()->set('notify_password_change', true);
|
||||||
|
|
||||||
$this->clearEmails();
|
$this->clearEmails();
|
||||||
|
|
||||||
@ -1187,7 +1187,7 @@ class MemberTest extends FunctionalTest
|
|||||||
$this->assertStringContainsString($message, $response->getBody());
|
$this->assertStringContainsString($message, $response->getBody());
|
||||||
|
|
||||||
// Logging out from the second device - only one device being logged out
|
// Logging out from the second device - only one device being logged out
|
||||||
RememberLoginHash::config()->update('logout_across_devices', false);
|
RememberLoginHash::config()->set('logout_across_devices', false);
|
||||||
$this->get(
|
$this->get(
|
||||||
'Security/logout',
|
'Security/logout',
|
||||||
$this->session(),
|
$this->session(),
|
||||||
@ -1205,7 +1205,7 @@ class MemberTest extends FunctionalTest
|
|||||||
// If session-manager module is installed then logout_across_devices is modified so skip
|
// If session-manager module is installed then logout_across_devices is modified so skip
|
||||||
if (!class_exists(LoginSession::class)) {
|
if (!class_exists(LoginSession::class)) {
|
||||||
// Logging out from any device when all login hashes should be removed
|
// Logging out from any device when all login hashes should be removed
|
||||||
RememberLoginHash::config()->update('logout_across_devices', true);
|
RememberLoginHash::config()->set('logout_across_devices', true);
|
||||||
Injector::inst()->get(IdentityStore::class)->logIn($m1, true);
|
Injector::inst()->get(IdentityStore::class)->logIn($m1, true);
|
||||||
$this->get('Security/logout', $this->session());
|
$this->get('Security/logout', $this->session());
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -1248,7 +1248,7 @@ class MemberTest extends FunctionalTest
|
|||||||
{
|
{
|
||||||
$maxFailedLoginsAllowed = 3;
|
$maxFailedLoginsAllowed = 3;
|
||||||
//set up the config variables to enable login lockouts
|
//set up the config variables to enable login lockouts
|
||||||
Member::config()->update('lock_out_after_incorrect_logins', $maxFailedLoginsAllowed);
|
Member::config()->set('lock_out_after_incorrect_logins', $maxFailedLoginsAllowed);
|
||||||
|
|
||||||
/** @var Member $member */
|
/** @var Member $member */
|
||||||
$member = $this->objFromFixture(Member::class, 'test');
|
$member = $this->objFromFixture(Member::class, 'test');
|
||||||
@ -1282,7 +1282,7 @@ class MemberTest extends FunctionalTest
|
|||||||
public function testMemberValidator()
|
public function testMemberValidator()
|
||||||
{
|
{
|
||||||
// clear custom requirements for this test
|
// clear custom requirements for this test
|
||||||
Member_Validator::config()->update('customRequired', null);
|
Member_Validator::config()->set('customRequired', null);
|
||||||
/** @var Member $memberA */
|
/** @var Member $memberA */
|
||||||
$memberA = $this->objFromFixture(Member::class, 'admin');
|
$memberA = $this->objFromFixture(Member::class, 'admin');
|
||||||
/** @var Member $memberB */
|
/** @var Member $memberB */
|
||||||
@ -1358,7 +1358,7 @@ class MemberTest extends FunctionalTest
|
|||||||
public function testMemberValidatorWithExtensions()
|
public function testMemberValidatorWithExtensions()
|
||||||
{
|
{
|
||||||
// clear custom requirements for this test
|
// clear custom requirements for this test
|
||||||
Member_Validator::config()->update('customRequired', null);
|
Member_Validator::config()->set('customRequired', null);
|
||||||
|
|
||||||
// create a blank form
|
// create a blank form
|
||||||
$form = new MemberTest\ValidatorForm();
|
$form = new MemberTest\ValidatorForm();
|
||||||
@ -1422,7 +1422,7 @@ class MemberTest extends FunctionalTest
|
|||||||
public function testCustomMemberValidator()
|
public function testCustomMemberValidator()
|
||||||
{
|
{
|
||||||
// clear custom requirements for this test
|
// clear custom requirements for this test
|
||||||
Member_Validator::config()->update('customRequired', null);
|
Member_Validator::config()->set('customRequired', null);
|
||||||
|
|
||||||
$member = $this->objFromFixture(Member::class, 'admin');
|
$member = $this->objFromFixture(Member::class, 'admin');
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace SilverStripe\Security\Tests;
|
namespace SilverStripe\Security\Tests;
|
||||||
|
|
||||||
use SilverStripe\Security\RandomGenerator;
|
use SilverStripe\Security\RandomGenerator;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,6 +14,9 @@ class RandomGeneratorTest extends SapphireTest
|
|||||||
|
|
||||||
public function testGenerateEntropy()
|
public function testGenerateEntropy()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$r = new RandomGenerator();
|
$r = new RandomGenerator();
|
||||||
$this->assertNotNull($r->generateEntropy());
|
$this->assertNotNull($r->generateEntropy());
|
||||||
$this->assertNotEquals($r->generateEntropy(), $r->generateEntropy());
|
$this->assertNotEquals($r->generateEntropy(), $r->generateEntropy());
|
||||||
|
@ -4,7 +4,6 @@ namespace SilverStripe\View\Tests;
|
|||||||
|
|
||||||
use SilverStripe\ORM\ArrayLib;
|
use SilverStripe\ORM\ArrayLib;
|
||||||
use SilverStripe\ORM\FieldType\DBVarchar;
|
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||||
use SilverStripe\Dev\Deprecation;
|
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\View\ArrayData;
|
use SilverStripe\View\ArrayData;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
@ -67,9 +66,6 @@ class ArrayDataTest extends SapphireTest
|
|||||||
|
|
||||||
public function testGetArray()
|
public function testGetArray()
|
||||||
{
|
{
|
||||||
$originalDeprecation = Deprecation::dump_settings();
|
|
||||||
Deprecation::notification_version('2.4');
|
|
||||||
|
|
||||||
$array = [
|
$array = [
|
||||||
'Foo' => 'Foo',
|
'Foo' => 'Foo',
|
||||||
'Bar' => 'Bar',
|
'Bar' => 'Bar',
|
||||||
@ -79,8 +75,6 @@ class ArrayDataTest extends SapphireTest
|
|||||||
$arrayData = new ArrayData($array);
|
$arrayData = new ArrayData($array);
|
||||||
|
|
||||||
$this->assertEquals($arrayData->toMap(), $array);
|
$this->assertEquals($arrayData->toMap(), $array);
|
||||||
|
|
||||||
Deprecation::restore_settings($originalDeprecation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArrayToObject()
|
public function testArrayToObject()
|
||||||
|
@ -516,7 +516,7 @@ class RequirementsTest extends SapphireTest
|
|||||||
$combinedFileName = '/_combinedfiles/RequirementsTest_bc-2a55d56.js';
|
$combinedFileName = '/_combinedfiles/RequirementsTest_bc-2a55d56.js';
|
||||||
$combinedFilePath = TestAssetStore::base_path() . $combinedFileName;
|
$combinedFilePath = TestAssetStore::base_path() . $combinedFileName;
|
||||||
|
|
||||||
$html = $backend->includeInHTML(false, self::$html_template);
|
$html = $backend->includeInHTML(self::$html_template);
|
||||||
|
|
||||||
/* ASYNC IS INCLUDED IN SCRIPT TAG */
|
/* ASYNC IS INCLUDED IN SCRIPT TAG */
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
|
@ -32,6 +32,7 @@ use SilverStripe\View\SSViewer_FromString;
|
|||||||
use SilverStripe\View\Tests\SSViewerTest\SSViewerTestModel;
|
use SilverStripe\View\Tests\SSViewerTest\SSViewerTestModel;
|
||||||
use SilverStripe\View\Tests\SSViewerTest\SSViewerTestModelController;
|
use SilverStripe\View\Tests\SSViewerTest\SSViewerTestModelController;
|
||||||
use SilverStripe\View\ViewableData;
|
use SilverStripe\View\ViewableData;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @skipUpgrade
|
* @skipUpgrade
|
||||||
@ -53,8 +54,8 @@ class SSViewerTest extends SapphireTest
|
|||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
SSViewer::config()->update('source_file_comments', false);
|
SSViewer::config()->set('source_file_comments', false);
|
||||||
SSViewer_FromString::config()->update('cache_template', false);
|
SSViewer_FromString::config()->set('cache_template', false);
|
||||||
TestAssetStore::activate('SSViewerTest');
|
TestAssetStore::activate('SSViewerTest');
|
||||||
$this->oldServer = $_SERVER;
|
$this->oldServer = $_SERVER;
|
||||||
}
|
}
|
||||||
@ -73,7 +74,10 @@ class SSViewerTest extends SapphireTest
|
|||||||
*/
|
*/
|
||||||
public function testCurrentTheme()
|
public function testCurrentTheme()
|
||||||
{
|
{
|
||||||
SSViewer::config()->update('theme', 'mytheme');
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
|
SSViewer::config()->set('theme', 'mytheme');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'mytheme',
|
'mytheme',
|
||||||
SSViewer::config()->uninherited('theme'),
|
SSViewer::config()->uninherited('theme'),
|
||||||
@ -1269,39 +1273,39 @@ after'
|
|||||||
$this->assertEquals("12345678910", $result, "Numbers rendered in order");
|
$this->assertEquals("12345678910", $result, "Numbers rendered in order");
|
||||||
|
|
||||||
//test First
|
//test First
|
||||||
$result = $this->render('<% loop Set %><% if First %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $IsFirst %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("1", $result, "Only the first number is rendered");
|
$this->assertEquals("1", $result, "Only the first number is rendered");
|
||||||
|
|
||||||
//test Last
|
//test Last
|
||||||
$result = $this->render('<% loop Set %><% if Last %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $IsLast %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("10", $result, "Only the last number is rendered");
|
$this->assertEquals("10", $result, "Only the last number is rendered");
|
||||||
|
|
||||||
//test Even
|
//test Even
|
||||||
$result = $this->render('<% loop Set %><% if Even() %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $Even() %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("246810", $result, "Even numbers rendered in order");
|
$this->assertEquals("246810", $result, "Even numbers rendered in order");
|
||||||
|
|
||||||
//test Even with quotes
|
//test Even with quotes
|
||||||
$result = $this->render('<% loop Set %><% if Even("1") %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $Even("1") %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("246810", $result, "Even numbers rendered in order");
|
$this->assertEquals("246810", $result, "Even numbers rendered in order");
|
||||||
|
|
||||||
//test Even without quotes
|
//test Even without quotes
|
||||||
$result = $this->render('<% loop Set %><% if Even(1) %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $Even(1) %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("246810", $result, "Even numbers rendered in order");
|
$this->assertEquals("246810", $result, "Even numbers rendered in order");
|
||||||
|
|
||||||
//test Even with zero-based start index
|
//test Even with zero-based start index
|
||||||
$result = $this->render('<% loop Set %><% if Even("0") %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $Even("0") %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("13579", $result, "Even (with zero-based index) numbers rendered in order");
|
$this->assertEquals("13579", $result, "Even (with zero-based index) numbers rendered in order");
|
||||||
|
|
||||||
//test Odd
|
//test Odd
|
||||||
$result = $this->render('<% loop Set %><% if Odd %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $Odd %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("13579", $result, "Odd numbers rendered in order");
|
$this->assertEquals("13579", $result, "Odd numbers rendered in order");
|
||||||
|
|
||||||
//test FirstLast
|
//test FirstLast
|
||||||
$result = $this->render('<% loop Set %><% if FirstLast %>$Number$FirstLast<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $FirstLast %>$Number$FirstLast<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("1first10last", $result, "First and last numbers rendered in order");
|
$this->assertEquals("1first10last", $result, "First and last numbers rendered in order");
|
||||||
|
|
||||||
//test Middle
|
//test Middle
|
||||||
$result = $this->render('<% loop Set %><% if Middle %>$Number<% end_if %><% end_loop %>', $data);
|
$result = $this->render('<% loop Set %><% if $Middle %>$Number<% end_if %><% end_loop %>', $data);
|
||||||
$this->assertEquals("23456789", $result, "Middle numbers rendered in order");
|
$this->assertEquals("23456789", $result, "Middle numbers rendered in order");
|
||||||
|
|
||||||
//test MiddleString
|
//test MiddleString
|
||||||
@ -1611,7 +1615,7 @@ after'
|
|||||||
$this->assertEqualIgnoringWhitespace(
|
$this->assertEqualIgnoringWhitespace(
|
||||||
'1ab23last',
|
'1ab23last',
|
||||||
$this->render(
|
$this->render(
|
||||||
'<% loop $Foo %>$Name<% loop Children %>$Name<% end_loop %><% if Last %>last<% end_if %>'
|
'<% loop $Foo %>$Name<% loop Children %>$Name<% end_loop %><% if $IsLast %>last<% end_if %>'
|
||||||
. '<% end_loop %>',
|
. '<% end_loop %>',
|
||||||
$data
|
$data
|
||||||
)
|
)
|
||||||
@ -1819,7 +1823,7 @@ EOC;
|
|||||||
|
|
||||||
public function testRenderWithSourceFileComments()
|
public function testRenderWithSourceFileComments()
|
||||||
{
|
{
|
||||||
SSViewer::config()->update('source_file_comments', true);
|
SSViewer::config()->set('source_file_comments', true);
|
||||||
$i = __DIR__ . '/SSViewerTest/templates/Includes';
|
$i = __DIR__ . '/SSViewerTest/templates/Includes';
|
||||||
$f = __DIR__ . '/SSViewerTest/templates/SSViewerTestComments';
|
$f = __DIR__ . '/SSViewerTest/templates/SSViewerTestComments';
|
||||||
$templates = [
|
$templates = [
|
||||||
@ -2099,7 +2103,7 @@ EOC;
|
|||||||
$this->render($content, null, null);
|
$this->render($content, null, null);
|
||||||
$this->assertFalse(file_exists($cacheFile ?? ''), 'Cache file was created when caching was off');
|
$this->assertFalse(file_exists($cacheFile ?? ''), 'Cache file was created when caching was off');
|
||||||
|
|
||||||
SSViewer_FromString::config()->update('cache_template', true);
|
SSViewer_FromString::config()->set('cache_template', true);
|
||||||
$this->render($content, null, null);
|
$this->render($content, null, null);
|
||||||
$this->assertTrue(file_exists($cacheFile ?? ''), 'Cache file wasn\'t created when it was meant to');
|
$this->assertTrue(file_exists($cacheFile ?? ''), 'Cache file wasn\'t created when it was meant to');
|
||||||
unlink($cacheFile ?? '');
|
unlink($cacheFile ?? '');
|
||||||
|
@ -1 +1 @@
|
|||||||
<% if $Title %>$Title<% else %>Untitled<% end_if %> <% if $ArgA %>_ $ArgA <% end_if %>- <% if $First %>First-<% end_if %><% if $Last %>Last-<% end_if %><%if $MultipleOf(2) %>EVEN<% else %>ODD<% end_if %> top:$Top.Title
|
<% if $Title %>$Title<% else %>Untitled<% end_if %> <% if $ArgA %>_ $ArgA <% end_if %>- <% if $IsFirst %>First-<% end_if %><% if $IsLast %>Last-<% end_if %><%if $MultipleOf(2) %>EVEN<% else %>ODD<% end_if %> top:$Top.Title
|
||||||
|
@ -1 +1 @@
|
|||||||
$Title - <% loop $Items %>$Title<% if not Last %> - <% else %> - {$Top.Title}<% end_if %><% end_loop %>
|
$Title - <% loop $Items %>$Title<% if not $IsLast %> - <% else %> - {$Top.Title}<% end_if %><% end_loop %>
|
@ -7,6 +7,7 @@ use SilverStripe\Dev\SapphireTest;
|
|||||||
use SilverStripe\View\ArrayData;
|
use SilverStripe\View\ArrayData;
|
||||||
use SilverStripe\View\SSViewer;
|
use SilverStripe\View\SSViewer;
|
||||||
use SilverStripe\View\ViewableData;
|
use SilverStripe\View\ViewableData;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See {@link SSViewerTest->testCastingHelpers()} for more tests related to casting and ViewableData behaviour,
|
* See {@link SSViewerTest->testCastingHelpers()} for more tests related to casting and ViewableData behaviour,
|
||||||
@ -208,6 +209,9 @@ class ViewableDataTest extends SapphireTest
|
|||||||
|
|
||||||
public function testThemeDir()
|
public function testThemeDir()
|
||||||
{
|
{
|
||||||
|
if (Deprecation::isEnabled()) {
|
||||||
|
$this->markTestSkipped('Test calls deprecated code');
|
||||||
|
}
|
||||||
$themes = [
|
$themes = [
|
||||||
"silverstripe/framework:/tests/php/View/ViewableDataTest/testtheme",
|
"silverstripe/framework:/tests/php/View/ViewableDataTest/testtheme",
|
||||||
SSViewer::DEFAULT_THEME
|
SSViewer::DEFAULT_THEME
|
||||||
|
@ -149,7 +149,7 @@ class i18nTest extends SapphireTest
|
|||||||
public function testTemplateTranslation()
|
public function testTemplateTranslation()
|
||||||
{
|
{
|
||||||
$oldLocale = i18n::get_locale();
|
$oldLocale = i18n::get_locale();
|
||||||
i18n::config()->update('missing_default_warning', false);
|
i18n::config()->set('missing_default_warning', false);
|
||||||
|
|
||||||
/** @var SymfonyMessageProvider $provider */
|
/** @var SymfonyMessageProvider $provider */
|
||||||
$provider = Injector::inst()->get(MessageProvider::class);
|
$provider = Injector::inst()->get(MessageProvider::class);
|
||||||
@ -311,7 +311,7 @@ class i18nTest extends SapphireTest
|
|||||||
* */
|
* */
|
||||||
public function testNewTemplateTranslation()
|
public function testNewTemplateTranslation()
|
||||||
{
|
{
|
||||||
i18n::config()->update('missing_default_warning', false);
|
i18n::config()->set('missing_default_warning', false);
|
||||||
|
|
||||||
/** @var SymfonyMessageProvider $provider */
|
/** @var SymfonyMessageProvider $provider */
|
||||||
$provider = Injector::inst()->get(MessageProvider::class);
|
$provider = Injector::inst()->get(MessageProvider::class);
|
||||||
@ -468,7 +468,7 @@ class i18nTest extends SapphireTest
|
|||||||
|
|
||||||
public function testGetLanguageName()
|
public function testGetLanguageName()
|
||||||
{
|
{
|
||||||
i18n::config()->update(
|
i18n::config()->merge(
|
||||||
'common_languages',
|
'common_languages',
|
||||||
['de_CGN' => ['name' => 'German (Cologne)', 'native' => 'Kölsch']]
|
['de_CGN' => ['name' => 'German (Cologne)', 'native' => 'Kölsch']]
|
||||||
);
|
);
|
||||||
|
@ -82,7 +82,7 @@ trait i18nTestManifest
|
|||||||
// Switch to test manifest
|
// Switch to test manifest
|
||||||
$s = DIRECTORY_SEPARATOR;
|
$s = DIRECTORY_SEPARATOR;
|
||||||
$this->alternateBasePath = __DIR__ . $s . 'i18nTest' . $s . "_fakewebroot";
|
$this->alternateBasePath = __DIR__ . $s . 'i18nTest' . $s . "_fakewebroot";
|
||||||
Director::config()->update('alternate_base_folder', $this->alternateBasePath);
|
Director::config()->set('alternate_base_folder', $this->alternateBasePath);
|
||||||
|
|
||||||
// New module manifest
|
// New module manifest
|
||||||
$moduleManifest = new ModuleManifest($this->alternateBasePath);
|
$moduleManifest = new ModuleManifest($this->alternateBasePath);
|
||||||
|
@ -533,8 +533,8 @@ PHP;
|
|||||||
public function testCollectFromFilesystemAndWriteMasterTables()
|
public function testCollectFromFilesystemAndWriteMasterTables()
|
||||||
{
|
{
|
||||||
i18n::set_locale('en_US'); //set the locale to the US locale expected in the asserts
|
i18n::set_locale('en_US'); //set the locale to the US locale expected in the asserts
|
||||||
i18n::config()->update('default_locale', 'en_US');
|
i18n::config()->set('default_locale', 'en_US');
|
||||||
i18n::config()->update('missing_default_warning', false);
|
i18n::config()->set('missing_default_warning', false);
|
||||||
|
|
||||||
$c = i18nTextCollector::create();
|
$c = i18nTextCollector::create();
|
||||||
$c->setWarnOnEmptyDefault(false);
|
$c->setWarnOnEmptyDefault(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user