diff --git a/docs/en/02_Developer_Guides/19_GraphQL/05_plugins/03_writing_a_complex_plugin.md b/docs/en/02_Developer_Guides/19_GraphQL/05_plugins/03_writing_a_complex_plugin.md index 8d5344a8fee..6748399009e 100644 --- a/docs/en/02_Developer_Guides/19_GraphQL/05_plugins/03_writing_a_complex_plugin.md +++ b/docs/en/02_Developer_Guides/19_GraphQL/05_plugins/03_writing_a_complex_plugin.md @@ -56,7 +56,7 @@ class GeocodableDataObject implements ModelTypePlugin ); // only apply the plugin to geocodable DataObjects - if (!Extensible::has_extension($class, Geocodable::class)) { + if (!ViewableData::has_extension($class, Geocodable::class)) { return; } @@ -85,7 +85,7 @@ class GeocodableQuery implements ModelQueryPlugin { $class = $query->getModel()->getSourceClass(); // Only apply to geocodable objects - if (!Extensible::has_extension($class, Geocodable::class)) { + if (!ViewableData::has_extension($class, Geocodable::class)) { return; } @@ -177,7 +177,7 @@ public function apply(ModelQuery $query, Schema $schema, array $config = []): vo { $class = $query->getModel()->getSourceClass(); // Only apply to geocodable objects - if (!Extensible::has_extension($class, Geocodable::class)) { + if (!ViewableData::has_extension($class, Geocodable::class)) { return; } diff --git a/src/Control/HTTP.php b/src/Control/HTTP.php index 61c9bdabd60..f15d4f877ae 100644 --- a/src/Control/HTTP.php +++ b/src/Control/HTTP.php @@ -259,7 +259,7 @@ public static function setGetVar($varname, $varvalue, $currentURL = null, $separ $path = (isset($parts['path']) && $parts['path'] != '') ? $parts['path'] : ''; // handle URL params which are existing / new - $params = ($params) ? '?' . http_build_query($params, null, $separator) : ''; + $params = ($params) ? '?' . http_build_query($params, '', $separator) : ''; // keep fragments (anchors) intact. $fragment = (isset($parts['fragment']) && $parts['fragment'] != '') ? '#' . $parts['fragment'] : ''; diff --git a/src/Control/HTTPResponse_Exception.php b/src/Control/HTTPResponse_Exception.php index 5075765179f..355e28000f4 100644 --- a/src/Control/HTTPResponse_Exception.php +++ b/src/Control/HTTPResponse_Exception.php @@ -49,7 +49,7 @@ public function __construct($body = null, $statusCode = null, $statusDescription $this->setResponse($response); } - parent::__construct($this->getResponse()->getBody(), $this->getResponse()->getStatusCode()); + parent::__construct((string) $this->getResponse()->getBody(), $this->getResponse()->getStatusCode()); } /** diff --git a/src/Core/ClassInfo.php b/src/Core/ClassInfo.php index 0c98e9cd863..736dd7e5530 100644 --- a/src/Core/ClassInfo.php +++ b/src/Core/ClassInfo.php @@ -10,6 +10,7 @@ use SilverStripe\Dev\Deprecation; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; +use SilverStripe\View\ViewableData; /** * Provides introspection information about the class tree. @@ -597,7 +598,7 @@ public static function classesWithExtension( // only keep classes with the Extension applied $classes = array_filter($classes, function ($class) use ($extensionClass) { - return Extensible::has_extension($class, $extensionClass); + return ViewableData::has_extension($class, $extensionClass); }); return $classes; diff --git a/src/Dev/CSVParser.php b/src/Dev/CSVParser.php index 1b23a866194..3d99426c300 100644 --- a/src/Dev/CSVParser.php +++ b/src/Dev/CSVParser.php @@ -168,7 +168,6 @@ public function provideHeaderRow($headerRow) */ protected function openFile() { - ini_set('auto_detect_line_endings', 1); $this->fileHandle = fopen($this->filename, 'r'); if ($this->providedHeaderRow) { diff --git a/src/Dev/CsvBulkLoader.php b/src/Dev/CsvBulkLoader.php index 07b12b867e4..94708eabab5 100644 --- a/src/Dev/CsvBulkLoader.php +++ b/src/Dev/CsvBulkLoader.php @@ -68,9 +68,6 @@ public function preview($filepath) */ protected function processAll($filepath, $preview = false) { - $previousDetectLE = ini_get('auto_detect_line_endings'); - ini_set('auto_detect_line_endings', true); - $this->extend('onBeforeProcessAll', $filepath, $preview); $result = BulkLoader_Result::create(); @@ -144,8 +141,6 @@ protected function processAll($filepath, $preview = false) $failedMessage = sprintf($failedMessage . " because %s", $e->getMessage()); } print $failedMessage . PHP_EOL; - } finally { - ini_set('auto_detect_line_endings', $previousDetectLE); } $this->extend('onAfterProcessAll', $result, $preview); @@ -182,9 +177,6 @@ protected function getNormalisedColumnMap() protected function splitFile($path, $lines = null) { Deprecation::notice('5.0', 'splitFile is deprecated, please process files using a stream'); - $previous = ini_get('auto_detect_line_endings'); - - ini_set('auto_detect_line_endings', true); if (!is_int($lines)) { $lines = $this->config()->get("lines"); @@ -230,11 +222,8 @@ protected function splitFile($path, $lines = null) $count = 0; } } - fclose($to); - ini_set('auto_detect_line_endings', $previous); - return $files; } diff --git a/src/ORM/FieldType/DBDecimal.php b/src/ORM/FieldType/DBDecimal.php index 92394770d33..0ecf6c6bd0c 100644 --- a/src/ORM/FieldType/DBDecimal.php +++ b/src/ORM/FieldType/DBDecimal.php @@ -126,7 +126,7 @@ public function prepValueForDB($value) return 0; } - if (ctype_digit($value)) { + if (ctype_digit((string) $value)) { return (int)$value; } diff --git a/src/ORM/Hierarchy/Hierarchy.php b/src/ORM/Hierarchy/Hierarchy.php index 6f6d2e84c2c..6293273bc65 100644 --- a/src/ORM/Hierarchy/Hierarchy.php +++ b/src/ORM/Hierarchy/Hierarchy.php @@ -5,7 +5,6 @@ use SilverStripe\Admin\LeftAndMain; use SilverStripe\Control\Controller; use SilverStripe\Core\ClassInfo; -use SilverStripe\Core\Extensible; use SilverStripe\ORM\DataList; use SilverStripe\ORM\SS_List; use SilverStripe\ORM\ValidationResult; @@ -17,6 +16,7 @@ use SilverStripe\Core\Config\Config; use SilverStripe\Core\Convert; use Exception; +use SilverStripe\View\ViewableData; /** * DataObjects that use the Hierarchy extension can be be organised as a hierarchy, with children and parents. The most @@ -418,7 +418,7 @@ private function getHierarchyBaseClass(): string { $ancestry = ClassInfo::ancestry($this->owner); $ancestorClass = array_shift($ancestry); - while ($ancestorClass && !Extensible::has_extension($ancestorClass, self::class)) { + while ($ancestorClass && !ViewableData::has_extension($ancestorClass, self::class)) { $ancestorClass = array_shift($ancestry); } diff --git a/src/View/Parsers/HTMLValue.php b/src/View/Parsers/HTMLValue.php index 8809bad5da5..a5ee8b7134c 100644 --- a/src/View/Parsers/HTMLValue.php +++ b/src/View/Parsers/HTMLValue.php @@ -146,7 +146,7 @@ public function __call($method, $arguments) { $doc = $this->getDocument(); - if (method_exists($doc, $method)) { + if ($doc && method_exists($doc, $method)) { return call_user_func_array([$doc, $method], $arguments); } else { return parent::__call($method, $arguments); diff --git a/tests/php/Forms/DatetimeFieldTest.php b/tests/php/Forms/DatetimeFieldTest.php index cf77ab75f22..af1090784c4 100644 --- a/tests/php/Forms/DatetimeFieldTest.php +++ b/tests/php/Forms/DatetimeFieldTest.php @@ -2,6 +2,7 @@ namespace SilverStripe\Forms\Tests; +use IntlDateFormatter; use SilverStripe\Control\Controller; use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\DatetimeField; @@ -256,12 +257,12 @@ public function testValidateMinDateStrtotime() { $f = new DatetimeField('Datetime'); $f->setMinDatetime('-7 days'); - $f->setValue(strftime('%Y-%m-%d %T', strtotime('-8 days', DBDatetime::now()->getTimestamp()))); + $f->setValue(date('Y-m-d H:i:s', strtotime('-8 days', DBDatetime::now()->getTimestamp()))); $this->assertFalse($f->validate(new RequiredFields()), 'Date below min datetime, with strtotime'); $f = new DatetimeField('Datetime'); $f->setMinDatetime('-7 days'); - $f->setValue(strftime('%Y-%m-%d %T', strtotime('-7 days', DBDatetime::now()->getTimestamp()))); + $f->setValue(date('Y-m-d H:i:s', strtotime('-7 days', DBDatetime::now()->getTimestamp()))); $this->assertTrue($f->validate(new RequiredFields()), 'Date matching min datetime, with strtotime'); } @@ -269,12 +270,12 @@ public function testValidateMaxDateStrtotime() { $f = new DatetimeField('Datetime'); $f->setMaxDatetime('7 days'); - $f->setValue(strftime('%Y-%m-%d %T', strtotime('8 days', DBDatetime::now()->getTimestamp()))); + $f->setValue(date('Y-m-d H:i:s', strtotime('8 days', DBDatetime::now()->getTimestamp()))); $this->assertFalse($f->validate(new RequiredFields()), 'Date above max date, with strtotime'); $f = new DatetimeField('Datetime'); $f->setMaxDatetime('7 days'); - $f->setValue(strftime('%Y-%m-%d %T', strtotime('7 days', DBDatetime::now()->getTimestamp()))); + $f->setValue(date('Y-m-d H:i:s', strtotime('7 days', DBDatetime::now()->getTimestamp()))); $this->assertTrue($f->validate(new RequiredFields()), 'Date matching max date, with strtotime'); } diff --git a/tests/php/Forms/FormTest.php b/tests/php/Forms/FormTest.php index e0d2a9a2676..0ccb35f8f1d 100644 --- a/tests/php/Forms/FormTest.php +++ b/tests/php/Forms/FormTest.php @@ -1143,8 +1143,8 @@ protected function clean($input) { return str_replace( [ - html_entity_decode(' ', null, 'UTF-8'), - html_entity_decode(' ', null, 'UTF-8'), // narrow non-breaking space + html_entity_decode(' ', 0, 'UTF-8'), + html_entity_decode(' ', 0, 'UTF-8'), // narrow non-breaking space ], ' ', trim($input) diff --git a/tests/php/Forms/NumericFieldTest.php b/tests/php/Forms/NumericFieldTest.php index f7aa46b4d00..8bf3e9ef6c9 100644 --- a/tests/php/Forms/NumericFieldTest.php +++ b/tests/php/Forms/NumericFieldTest.php @@ -24,8 +24,8 @@ protected function clean($input) { return str_replace( [ - html_entity_decode(' ', null, 'UTF-8'), - html_entity_decode(' ', null, 'UTF-8'), // narrow non-breaking space + html_entity_decode(' ', 0, 'UTF-8'), + html_entity_decode(' ', 0, 'UTF-8'), // narrow non-breaking space ], ' ', trim($input) diff --git a/tests/php/ORM/DBMoneyTest.php b/tests/php/ORM/DBMoneyTest.php index a231f6aac51..9709614b513 100644 --- a/tests/php/ORM/DBMoneyTest.php +++ b/tests/php/ORM/DBMoneyTest.php @@ -350,7 +350,7 @@ public function testHasAmount() */ protected function clean($input) { - $nbsp = html_entity_decode(' ', null, 'UTF-8'); + $nbsp = html_entity_decode(' ', 0, 'UTF-8'); return str_replace(' ', $nbsp, trim($input)); } }