mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENH Various fixes for PHP 8.1 compatibility
This commit is contained in:
parent
3e5a74c6b2
commit
f1678781a2
@ -19,6 +19,7 @@ use SilverStripe\View\SSViewer;
|
|||||||
use SilverStripe\View\ThemeResourceLoader;
|
use SilverStripe\View\ThemeResourceLoader;
|
||||||
use SilverStripe\View\ViewableData;
|
use SilverStripe\View\ViewableData;
|
||||||
use Swift_Message;
|
use Swift_Message;
|
||||||
|
use Swift_Mime_SimpleMessage;
|
||||||
use Swift_MimePart;
|
use Swift_MimePart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,7 +261,10 @@ class Email extends ViewableData
|
|||||||
public function getSwiftMessage()
|
public function getSwiftMessage()
|
||||||
{
|
{
|
||||||
if (!$this->swiftMessage) {
|
if (!$this->swiftMessage) {
|
||||||
$this->setSwiftMessage(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
|
||||||
|
$message->setPriority(Swift_Mime_SimpleMessage::PRIORITY_NORMAL);
|
||||||
|
$this->setSwiftMessage($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->swiftMessage;
|
return $this->swiftMessage;
|
||||||
|
@ -213,7 +213,7 @@ class DBText extends DBString
|
|||||||
$position = empty($keywords) ? 0 : (int) mb_stripos($text, $keywords);
|
$position = empty($keywords) ? 0 : (int) mb_stripos($text, $keywords);
|
||||||
|
|
||||||
// We want to search string to be in the middle of our block to give it some context
|
// We want to search string to be in the middle of our block to give it some context
|
||||||
$position = max(0, $position - ($characters / 2));
|
$position = floor(max(0, $position - ($characters / 2)));
|
||||||
|
|
||||||
if ($position > 0) {
|
if ($position > 0) {
|
||||||
// We don't want to start mid-word
|
// We don't want to start mid-word
|
||||||
|
@ -384,7 +384,7 @@ abstract class SQLConditionalExpression extends SQLExpression
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Split the array in half
|
// Split the array in half
|
||||||
$halfway = count($array) / 2;
|
$halfway = floor(count($array) / 2);
|
||||||
$array1 = array_slice($array, 0, $halfway);
|
$array1 = array_slice($array, 0, $halfway);
|
||||||
$array2 = array_slice($array, $halfway);
|
$array2 = array_slice($array, $halfway);
|
||||||
// Recurse to sort the two halves
|
// Recurse to sort the two halves
|
||||||
|
@ -46,12 +46,12 @@ class DateFieldTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setMinDate('-7 days');
|
$f->setMinDate('-7 days');
|
||||||
$f->setValue(strftime('%Y-%m-%d', strtotime('-8 days', DBDatetime::now()->getTimestamp())));
|
$f->setValue(date('Y-m-d', strtotime('-8 days', DBDatetime::now()->getTimestamp())));
|
||||||
$this->assertFalse($f->validate(new RequiredFields()), 'Date below min date, with strtotime');
|
$this->assertFalse($f->validate(new RequiredFields()), 'Date below min date, with strtotime');
|
||||||
|
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setMinDate('-7 days');
|
$f->setMinDate('-7 days');
|
||||||
$f->setValue(strftime('%Y-%m-%d', strtotime('-7 days', DBDatetime::now()->getTimestamp())));
|
$f->setValue(date('Y-m-d', strtotime('-7 days', DBDatetime::now()->getTimestamp())));
|
||||||
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching min date, with strtotime');
|
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching min date, with strtotime');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +59,12 @@ class DateFieldTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setMaxDate('7 days');
|
$f->setMaxDate('7 days');
|
||||||
$f->setValue(strftime('%Y-%m-%d', strtotime('8 days', DBDatetime::now()->getTimestamp())));
|
$f->setValue(date('Y-m-d', strtotime('8 days', DBDatetime::now()->getTimestamp())));
|
||||||
$this->assertFalse($f->validate(new RequiredFields()), 'Date above max date, with strtotime');
|
$this->assertFalse($f->validate(new RequiredFields()), 'Date above max date, with strtotime');
|
||||||
|
|
||||||
$f = new DateField('Date');
|
$f = new DateField('Date');
|
||||||
$f->setMaxDate('7 days');
|
$f->setMaxDate('7 days');
|
||||||
$f->setValue(strftime('%Y-%m-%d', strtotime('7 days', DBDatetime::now()->getTimestamp())));
|
$f->setValue(date('Y-m-d', strtotime('7 days', DBDatetime::now()->getTimestamp())));
|
||||||
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching max date, with strtotime');
|
$this->assertTrue($f->validate(new RequiredFields()), 'Date matching max date, with strtotime');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user