From 8c63c0c192052d6c5410a7f7f72bfa24d309af39 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Mon, 13 Nov 2023 12:12:03 +1300 Subject: [PATCH] DEP Deprecate configurable silent failures in GridField components --- src/Forms/GridField/GridFieldConfig_Base.php | 10 +++++++--- src/Forms/GridField/GridFieldConfig_RecordEditor.php | 10 +++++++--- src/Forms/GridField/GridFieldConfig_RelationEditor.php | 10 +++++++--- src/Forms/GridField/GridFieldFilterHeader.php | 7 +++++++ src/Forms/GridField/GridFieldPaginator.php | 7 +++++++ src/Forms/GridField/GridFieldSortableHeader.php | 7 +++++++ 6 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/Forms/GridField/GridFieldConfig_Base.php b/src/Forms/GridField/GridFieldConfig_Base.php index ea080390fc9..14066b0d003 100644 --- a/src/Forms/GridField/GridFieldConfig_Base.php +++ b/src/Forms/GridField/GridFieldConfig_Base.php @@ -2,6 +2,8 @@ namespace SilverStripe\Forms\GridField; +use SilverStripe\Dev\Deprecation; + /** * A simple readonly, paginated view of records, with sortable and searchable * headers. @@ -23,9 +25,11 @@ public function __construct($itemsPerPage = null) $this->addComponent(GridFieldPageCount::create('toolbar-header-right')); $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); - $sort->setThrowExceptionOnBadDataType(false); - $filter->setThrowExceptionOnBadDataType(false); - $pagination->setThrowExceptionOnBadDataType(false); + Deprecation::withNoReplacement(function() use ($sort, $filter, $pagination) { + $sort->setThrowExceptionOnBadDataType(false); + $filter->setThrowExceptionOnBadDataType(false); + $pagination->setThrowExceptionOnBadDataType(false); + }); $this->extend('updateConfig'); } diff --git a/src/Forms/GridField/GridFieldConfig_RecordEditor.php b/src/Forms/GridField/GridFieldConfig_RecordEditor.php index bcb3079d95f..fe1f2907ae7 100644 --- a/src/Forms/GridField/GridFieldConfig_RecordEditor.php +++ b/src/Forms/GridField/GridFieldConfig_RecordEditor.php @@ -1,6 +1,8 @@ addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); $this->addComponent(GridFieldDetailForm::create(null, $showPagination, $showAdd)); - $sort->setThrowExceptionOnBadDataType(false); - $filter->setThrowExceptionOnBadDataType(false); - $pagination->setThrowExceptionOnBadDataType(false); + Deprecation::withNoReplacement(function() use ($sort, $filter, $pagination) { + $sort->setThrowExceptionOnBadDataType(false); + $filter->setThrowExceptionOnBadDataType(false); + $pagination->setThrowExceptionOnBadDataType(false); + }); $this->extend('updateConfig'); } diff --git a/src/Forms/GridField/GridFieldConfig_RelationEditor.php b/src/Forms/GridField/GridFieldConfig_RelationEditor.php index 2cb243f51b5..66b5a667ec0 100644 --- a/src/Forms/GridField/GridFieldConfig_RelationEditor.php +++ b/src/Forms/GridField/GridFieldConfig_RelationEditor.php @@ -2,6 +2,8 @@ namespace SilverStripe\Forms\GridField; +use SilverStripe\Dev\Deprecation; + /** * Similar to {@link GridFieldConfig_RecordEditor}, but adds features to work * on has-many or many-many relationships. @@ -43,9 +45,11 @@ public function __construct($itemsPerPage = null) $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); $this->addComponent(GridFieldDetailForm::create()); - $sort->setThrowExceptionOnBadDataType(false); - $filter->setThrowExceptionOnBadDataType(false); - $pagination->setThrowExceptionOnBadDataType(false); + Deprecation::withNoReplacement(function() use ($sort, $filter, $pagination) { + $sort->setThrowExceptionOnBadDataType(false); + $filter->setThrowExceptionOnBadDataType(false); + $pagination->setThrowExceptionOnBadDataType(false); + }); $this->extend('updateConfig'); } diff --git a/src/Forms/GridField/GridFieldFilterHeader.php b/src/Forms/GridField/GridFieldFilterHeader.php index 187b9bd4fea..f7c1e74aabd 100755 --- a/src/Forms/GridField/GridFieldFilterHeader.php +++ b/src/Forms/GridField/GridFieldFilterHeader.php @@ -7,6 +7,7 @@ use SilverStripe\Control\Controller; use SilverStripe\Control\HTTPResponse; use SilverStripe\Core\ClassInfo; +use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\Schema\FormSchema; @@ -27,6 +28,7 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi * See {@link setThrowExceptionOnBadDataType()} * * @var bool + * @deprecated 5.2.0 Will be removed without equivalent functionality */ protected $throwExceptionOnBadDataType = true; @@ -66,17 +68,21 @@ public function getURLHandlers($gridField) * {@link GridFieldConfig} subclasses set this to false for flexibility. * * @param bool $throwExceptionOnBadDataType + * @deprecated 5.2.0 Will be removed without equivalent functionality */ public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType) { + Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); $this->throwExceptionOnBadDataType = $throwExceptionOnBadDataType; } /** * See {@link setThrowExceptionOnBadDataType()} + * @deprecated 5.2.0 Will be removed without equivalent functionality */ public function getThrowExceptionOnBadDataType() { + Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); return $this->throwExceptionOnBadDataType; } @@ -103,6 +109,7 @@ protected function checkDataType($dataList) if ($dataList instanceof Filterable) { return true; } else { + // This will be changed to always throw an exception in a future major release. if ($this->throwExceptionOnBadDataType) { throw new LogicException( static::class . " expects an SS_Filterable list to be passed to the GridField." diff --git a/src/Forms/GridField/GridFieldPaginator.php b/src/Forms/GridField/GridFieldPaginator.php index 970c1da2b78..5e2c4f01a2c 100755 --- a/src/Forms/GridField/GridFieldPaginator.php +++ b/src/Forms/GridField/GridFieldPaginator.php @@ -9,6 +9,7 @@ use SilverStripe\View\ArrayData; use SilverStripe\View\SSViewer; use LogicException; +use SilverStripe\Dev\Deprecation; /** * GridFieldPaginator paginates the {@link GridField} list and adds controls @@ -33,6 +34,7 @@ class GridFieldPaginator extends AbstractGridFieldComponent implements GridField /** * See {@link setThrowExceptionOnBadDataType()} + * @deprecated 5.2.0 Will be removed without equivalent functionality */ protected $throwExceptionOnBadDataType = true; @@ -57,9 +59,11 @@ public function __construct($itemsPerPage = null) * * @param bool $throwExceptionOnBadDataType * @return $this + * @deprecated 5.2.0 Will be removed without equivalent functionality */ public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType) { + Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); $this->throwExceptionOnBadDataType = $throwExceptionOnBadDataType; return $this; } @@ -68,9 +72,11 @@ public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType) * See {@link setThrowExceptionOnBadDataType()} * * @return bool + * @deprecated 5.2.0 Will be removed without equivalent functionality */ public function getThrowExceptionOnBadDataType() { + Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); return $this->throwExceptionOnBadDataType; } @@ -86,6 +92,7 @@ protected function checkDataType($dataList) if ($dataList instanceof Limitable) { return true; } else { + // This will be changed to always throw an exception in a future major release. if ($this->throwExceptionOnBadDataType) { throw new LogicException( static::class . " expects an SS_Limitable list to be passed to the GridField." diff --git a/src/Forms/GridField/GridFieldSortableHeader.php b/src/Forms/GridField/GridFieldSortableHeader.php index e43f1aa9e98..28cd0665f48 100644 --- a/src/Forms/GridField/GridFieldSortableHeader.php +++ b/src/Forms/GridField/GridFieldSortableHeader.php @@ -12,6 +12,7 @@ use SilverStripe\View\SSViewer; use LogicException; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Deprecation; /** * GridFieldSortableHeader adds column headers to a {@link GridField} that can @@ -26,6 +27,7 @@ class GridFieldSortableHeader extends AbstractGridFieldComponent implements Grid * See {@link setThrowExceptionOnBadDataType()} * * @var bool + * @deprecated 5.2.0 Will be removed without equivalent functionality */ protected $throwExceptionOnBadDataType = true; @@ -45,9 +47,11 @@ class GridFieldSortableHeader extends AbstractGridFieldComponent implements Grid * * @param bool $throwExceptionOnBadDataType * @return $this + * @deprecated 5.2.0 Will be removed without equivalent functionality */ public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType) { + Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); $this->throwExceptionOnBadDataType = $throwExceptionOnBadDataType; return $this; } @@ -56,9 +60,11 @@ public function setThrowExceptionOnBadDataType($throwExceptionOnBadDataType) * See {@link setThrowExceptionOnBadDataType()} * * @return bool + * @deprecated 5.2.0 Will be removed without equivalent functionality */ public function getThrowExceptionOnBadDataType() { + Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); return $this->throwExceptionOnBadDataType; } @@ -74,6 +80,7 @@ protected function checkDataType($dataList) if ($dataList instanceof Sortable) { return true; } else { + // This will be changed to always throw an exception in a future major release. if ($this->throwExceptionOnBadDataType) { throw new LogicException( static::class . " expects an SS_Sortable list to be passed to the GridField."