From e2a4804f01b46662b44d4f142eccea7b2a57d43a Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:12:40 +1300 Subject: [PATCH] API Remove deprecated API (#11524) --- _config/encryptors.yml | 6 +-- src/Control/Director.php | 30 ----------- src/Control/HTTP.php | 11 +--- src/Control/HTTPApplication.php | 5 +- .../Middleware/URLSpecialsMiddleware.php | 11 +--- .../SessionEnvTypeSwitcher.php | 53 ------------------ src/Core/Manifest/VersionProvider.php | 54 ++----------------- src/Dev/Deprecation.php | 13 ----- src/Forms/FieldList.php | 9 ---- src/Forms/GridField/GridFieldConfig_Base.php | 15 ++---- .../GridFieldConfig_RecordEditor.php | 16 ++---- .../GridFieldConfig_RelationEditor.php | 10 ---- src/Forms/GridField/GridFieldEditButton.php | 7 ++- src/Forms/GridField/GridFieldFilterHeader.php | 48 ++--------------- src/Forms/GridField/GridFieldPaginator.php | 51 ++---------------- .../GridField/GridFieldSortableHeader.php | 52 ++---------------- src/Forms/SearchableDropdownTrait.php | 1 - src/Forms/Validation/CompositeValidator.php | 1 - src/Logging/ErrorOutputHandler.php | 13 ----- src/ORM/DataObject.php | 31 +---------- src/ORM/DataQuery.php | 24 +-------- src/ORM/DataQuery_SubGroup.php | 14 +---- src/ORM/PolymorphicHasManyList.php | 24 +++------ src/Security/InheritedPermissions.php | 15 ------ .../PasswordEncryptor_LegacyPHPHash.php | 45 ---------------- .../PasswordEncryptor_MySQLOldPassword.php | 33 ------------ .../PasswordEncryptor_MySQLPassword.php | 33 ------------ src/Security/PasswordEncryptor_None.php | 33 ------------ src/View/ThemeResourceLoader.php | 1 - .../Symfony/FlushInvalidatedResource.php | 10 ---- src/includes/constants.php | 15 +----- tests/php/Cli/SakeTest.php | 1 - .../GridField/GridFieldPaginatorTest.php | 1 - tests/php/Forms/GridField/GridFieldTest.php | 12 ++--- tests/php/Security/MemberTest.php | 6 +-- tests/php/Security/PasswordEncryptorTest.php | 23 -------- 36 files changed, 52 insertions(+), 675 deletions(-) delete mode 100644 src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php delete mode 100644 src/Security/PasswordEncryptor_LegacyPHPHash.php delete mode 100644 src/Security/PasswordEncryptor_MySQLOldPassword.php delete mode 100644 src/Security/PasswordEncryptor_MySQLPassword.php delete mode 100644 src/Security/PasswordEncryptor_None.php diff --git a/_config/encryptors.yml b/_config/encryptors.yml index f583515c4f8..51fa7138587 100644 --- a/_config/encryptors.yml +++ b/_config/encryptors.yml @@ -3,12 +3,10 @@ name: coreencryptors --- 'SilverStripe\Security\PasswordEncryptor': encryptors: - none: - 'SilverStripe\Security\PasswordEncryptor_None': md5: - 'SilverStripe\Security\PasswordEncryptor_LegacyPHPHash': md5 + 'SilverStripe\Security\PasswordEncryptor_PHPHash': md5 sha1: - 'SilverStripe\Security\PasswordEncryptor_LegacyPHPHash': sha1 + 'SilverStripe\Security\PasswordEncryptor_PHPHash': sha1 md5_v2.4: 'SilverStripe\Security\PasswordEncryptor_PHPHash': md5 sha1_v2.4: diff --git a/src/Control/Director.php b/src/Control/Director.php index f7321196c5e..c9d9306411c 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -13,7 +13,6 @@ use SilverStripe\Core\Kernel; use SilverStripe\Core\Path; use SilverStripe\PolyExecution\PolyCommand; -use SilverStripe\Dev\Deprecation; use SilverStripe\Versioned\Versioned; use SilverStripe\View\Requirements; use SilverStripe\View\Requirements_Backend; @@ -1054,35 +1053,6 @@ public static function get_environment_type() return $kernel->getEnvironment(); } - - /** - * Returns the session environment override - * - * @internal This method is not a part of public API and will be deleted without a deprecation warning - * - * @param HTTPRequest $request - * - * @return string|null null if not overridden, otherwise the actual value - * @deprecated 5.4.0 Use get_environment_type() instead. - */ - public static function get_session_environment_type(?HTTPRequest $request = null) - { - Deprecation::notice('5.4.0', 'Use get_environment_type() instead.'); - $request = static::currentRequest($request); - - if (!$request) { - return null; - } - - $session = $request->getSession(); - - if (!empty($session->get('isDev'))) { - return Kernel::DEV; - } elseif (!empty($session->get('isTest'))) { - return Kernel::TEST; - } - } - /** * This function will return true if the site is in a live environment. For information about * environment types, see {@link Director::set_environment_type()}. diff --git a/src/Control/HTTP.php b/src/Control/HTTP.php index d8a3b7248c9..b576bd56ce6 100644 --- a/src/Control/HTTP.php +++ b/src/Control/HTTP.php @@ -93,19 +93,12 @@ public static function absoluteURLs($html) * * * @param string $content The HTML to search for links to rewrite. - * @param callable $code Either a string that can evaluate to an expression to rewrite links - * (depreciated), or a callable that takes a single parameter and returns the rewritten URL. + * @param callable $code A callable that takes a single parameter and returns the rewritten URL. * * @return string The content with all links rewritten as per the logic specified in $code. */ - public static function urlRewriter($content, $code) + public static function urlRewriter($content, callable $code) { - if (!is_callable($code)) { - throw new InvalidArgumentException( - 'HTTP::urlRewriter expects a callable as the second parameter' - ); - } - // Replace attributes $attribs = ["src", "background", "a" => "href", "link" => "href", "base" => "href"]; $regExps = []; diff --git a/src/Control/HTTPApplication.php b/src/Control/HTTPApplication.php index ed3baffa91e..b5bbd142f7c 100644 --- a/src/Control/HTTPApplication.php +++ b/src/Control/HTTPApplication.php @@ -12,7 +12,6 @@ use SilverStripe\Core\Startup\RequestFlushDiscoverer; use SilverStripe\Core\Startup\ScheduledFlushDiscoverer; use SilverStripe\Core\Startup\DeployFlushDiscoverer; -use SilverStripe\Dev\Deprecation; class HTTPApplication implements Application { @@ -166,8 +165,6 @@ public function execute(HTTPRequest $request, callable $callback, $flush = false */ private function warnAboutDeprecatedSetups() { - if (defined('CUSTOM_INCLUDE_PATH')) { - Deprecation::notice('5.4.0', 'Use of the "CUSTOM_INCLUDE_PATH" constant is deprecated.', Deprecation::SCOPE_GLOBAL); - } + // noop } } diff --git a/src/Control/Middleware/URLSpecialsMiddleware.php b/src/Control/Middleware/URLSpecialsMiddleware.php index ddbec1a2d0f..0154e9eb258 100644 --- a/src/Control/Middleware/URLSpecialsMiddleware.php +++ b/src/Control/Middleware/URLSpecialsMiddleware.php @@ -5,7 +5,6 @@ use SilverStripe\Control\Controller; use SilverStripe\Control\Director; use SilverStripe\Control\Middleware\URLSpecialsMiddleware\FlushScheduler; -use SilverStripe\Control\Middleware\URLSpecialsMiddleware\SessionEnvTypeSwitcher; use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\HTTPResponse; use SilverStripe\Security\RandomGenerator; @@ -29,18 +28,13 @@ class URLSpecialsMiddleware extends PermissionAwareConfirmationMiddleware { use FlushScheduler; - use SessionEnvTypeSwitcher; /** * Initializes the middleware with the required rules */ public function __construct() { - parent::__construct( - new ConfirmationMiddleware\GetParameter("flush"), - new ConfirmationMiddleware\GetParameter("isDev"), - new ConfirmationMiddleware\GetParameter("isTest") - ); + parent::__construct(new ConfirmationMiddleware\GetParameter("flush")); } /** @@ -57,9 +51,8 @@ public function __construct() public function buildImpactRedirect(HTTPRequest $request) { $flush = $this->scheduleFlush($request); - $env_type = $this->setSessionEnvType($request); - if ($flush || $env_type) { + if ($flush) { // the token only purpose is to invalidate browser/proxy cache $request['urlspecialstoken'] = bin2hex(random_bytes(4)); diff --git a/src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php b/src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php deleted file mode 100644 index ee3ed456460..00000000000 --- a/src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php +++ /dev/null @@ -1,53 +0,0 @@ -getSession(); - - if (array_key_exists('isTest', $request->getVars() ?? [])) { - if (!is_null($isTest = $request->getVar('isTest'))) { - if ($isTest === $session->get('isTest')) { - return false; - } - } - - $session->clear('isDev'); - $session->set('isTest', $isTest); - - return true; - } elseif (array_key_exists('isDev', $request->getVars() ?? [])) { - if (!is_null($isDev = $request->getVar('isDev'))) { - if ($isDev === $session->get('isDev')) { - return false; - } - } - - $session->clear('isTest'); - $session->set('isDev', $isDev); - - return true; - } - - return false; - } -} diff --git a/src/Core/Manifest/VersionProvider.php b/src/Core/Manifest/VersionProvider.php index a951c0c9966..2b9128db801 100644 --- a/src/Core/Manifest/VersionProvider.php +++ b/src/Core/Manifest/VersionProvider.php @@ -4,7 +4,6 @@ use InvalidArgumentException; use Composer\InstalledVersions; -use SilverStripe\Dev\Deprecation; use Psr\SimpleCache\CacheInterface; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Injector\Injector; @@ -46,7 +45,7 @@ class VersionProvider */ public function getVersion() { - $key = preg_replace("/[^A-Za-z0-9]/", '_', $this->getComposerLockPath() . '_all'); + $key = $this->getCacheKey(); $version = $this->getCachedValue($key); if ($version) { return $version; @@ -82,7 +81,7 @@ public function getVersion() */ public function getModuleVersion(string $module): string { - $key = preg_replace("/[^A-Za-z0-9]/", '_', $this->getComposerLockPath() . '_' . $module); + $key = $this->getCacheKey($module); $version = $this->getCachedValue($key); if ($version) { return $version; @@ -197,53 +196,8 @@ public function getModuleVersionFromComposer($modules = []) return $versions; } - /** - * Load composer.lock's contents and return it - * - * @deprecated 5.1 Has been replaced by composer-runtime-api - * @param bool $cache - * @return array - */ - protected function getComposerLock($cache = true) - { - Deprecation::notice("5.1", "Has been replaced by composer-runtime-api", Deprecation::SCOPE_METHOD); - $composerLockPath = $this->getComposerLockPath(); - if (!file_exists($composerLockPath)) { - return []; - } - - $lockData = []; - $jsonData = file_get_contents($composerLockPath); - $jsonData = $jsonData ? $jsonData : ''; - $cacheKey = md5($jsonData); - - if ($cache) { - $cache = Injector::inst()->get(CacheInterface::class . '.VersionProvider_composerlock'); - if ($versions = $cache->get($cacheKey)) { - $lockData = json_decode($versions, true); - } - } - - if (empty($lockData) && $jsonData) { - $lockData = json_decode($jsonData, true); - - if ($cache) { - $cache->set($cacheKey, $jsonData); - } - } - - $lockData = $lockData ? $lockData : []; - - return $lockData; - } - - /** - * @return string - * @deprecated 5.4.0 Will be removed without equivalent functionality to replace it. - */ - protected function getComposerLockPath(): string + protected function getCacheKey(string $module = '_all'): string { - Deprecation::noticeWithNoReplacment('5.4.0'); - return BASE_PATH . '/composer.lock'; + return preg_replace("/[^A-Za-z0-9]/", '_', BASE_PATH . $module); } } diff --git a/src/Dev/Deprecation.php b/src/Dev/Deprecation.php index 5251fb04eda..81d9be590b3 100644 --- a/src/Dev/Deprecation.php +++ b/src/Dev/Deprecation.php @@ -117,19 +117,6 @@ public static function disable(): void static::$currentlyEnabled = false; } - /** - * Used to wrap deprecated methods and deprecated config get()/set() called from the vendor - * dir that projects have no ability to change. - * - * @return mixed - * @deprecated 5.4.0 Use withSuppressedNotice() instead - */ - public static function withNoReplacement(callable $func) - { - Deprecation::notice('5.4.0', 'Use withSuppressedNotice() instead'); - return Deprecation::withSuppressedNotice($func); - } - /** * Used to wrap deprecated methods and deprecated config get()/set() called from the vendor * dir that projects have no ability to change. diff --git a/src/Forms/FieldList.php b/src/Forms/FieldList.php index d0dc54ac822..f38215fe2ad 100644 --- a/src/Forms/FieldList.php +++ b/src/Forms/FieldList.php @@ -7,7 +7,6 @@ use SilverStripe\Forms\Tab; use SilverStripe\Forms\TabSet; use SilverStripe\Model\List\ArrayList; -use SilverStripe\Dev\Deprecation; /** * A list designed to hold form field instances. @@ -212,10 +211,6 @@ public function addFieldToTab(string $tabName, FormField $field, ?string $insert */ public function addFieldsToTab(string $tabName, array $fields, ?string $insertBefore = null): static { - if (!is_array($fields)) { - Deprecation::notice('5.3.0', '$fields will need to be passed as an array in CMS 6', Deprecation::SCOPE_METHOD); - } - $this->flushFieldsCache(); // Find the tab @@ -261,10 +256,6 @@ public function removeFieldFromTab(string $tabName, string $fieldName): static */ public function removeFieldsFromTab(string $tabName, array $fields): static { - if (!is_array($fields)) { - Deprecation::notice('5.3.0', '$fields will need to be passed as an array in CMS 6', Deprecation::SCOPE_METHOD); - } - $this->flushFieldsCache(); // Find the tab diff --git a/src/Forms/GridField/GridFieldConfig_Base.php b/src/Forms/GridField/GridFieldConfig_Base.php index 7994475da7c..3e3e33f8251 100644 --- a/src/Forms/GridField/GridFieldConfig_Base.php +++ b/src/Forms/GridField/GridFieldConfig_Base.php @@ -2,8 +2,6 @@ namespace SilverStripe\Forms\GridField; -use SilverStripe\Dev\Deprecation; - /** * A simple readonly, paginated view of records, with sortable and searchable * headers. @@ -19,18 +17,11 @@ public function __construct($itemsPerPage = null) parent::__construct(); $this->addComponent(GridFieldToolbarHeader::create()); $this->addComponent(GridFieldButtonRow::create('before')); - $this->addComponent($sort = GridFieldSortableHeader::create()); - $this->addComponent($filter = GridFieldFilterHeader::create()); + $this->addComponent(GridFieldSortableHeader::create()); + $this->addComponent(GridFieldFilterHeader::create()); $this->addComponent(GridFieldDataColumns::create()); $this->addComponent(GridFieldPageCount::create('toolbar-header-right')); - $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); - - Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) { - $sort->setThrowExceptionOnBadDataType(false); - $filter->setThrowExceptionOnBadDataType(false); - $pagination->setThrowExceptionOnBadDataType(false); - }); - + $this->addComponent(GridFieldPaginator::create($itemsPerPage)); $this->extend('updateConfig'); } } diff --git a/src/Forms/GridField/GridFieldConfig_RecordEditor.php b/src/Forms/GridField/GridFieldConfig_RecordEditor.php index 12d4cdf9ce3..34af72ac7f3 100644 --- a/src/Forms/GridField/GridFieldConfig_RecordEditor.php +++ b/src/Forms/GridField/GridFieldConfig_RecordEditor.php @@ -1,8 +1,6 @@ addComponent(GridFieldButtonRow::create('before')); $this->addComponent(GridFieldAddNewButton::create('buttons-before-left')); $this->addComponent(GridFieldToolbarHeader::create()); - $this->addComponent($sort = GridFieldSortableHeader::create()); - $this->addComponent($filter = GridFieldFilterHeader::create()); + $this->addComponent(GridFieldSortableHeader::create()); + $this->addComponent(GridFieldFilterHeader::create()); $this->addComponent(GridFieldDataColumns::create()); $this->addComponent(GridFieldEditButton::create()); $this->addComponent(GridFieldDeleteAction::create()); $this->addComponent(GridField_ActionMenu::create()); $this->addComponent(GridFieldPageCount::create('toolbar-header-right')); - $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); + $this->addComponent(GridFieldPaginator::create($itemsPerPage)); $this->addComponent(GridFieldDetailForm::create(null, $showPagination, $showAdd)); - - Deprecation::withSuppressedNotice(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 5ed3eea3142..5019cd10601 100644 --- a/src/Forms/GridField/GridFieldConfig_RelationEditor.php +++ b/src/Forms/GridField/GridFieldConfig_RelationEditor.php @@ -2,8 +2,6 @@ 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. @@ -30,7 +28,6 @@ class GridFieldConfig_RelationEditor extends GridFieldConfig public function __construct($itemsPerPage = null) { parent::__construct(); - $this->addComponent(GridFieldButtonRow::create('before')); $this->addComponent(GridFieldAddNewButton::create('buttons-before-left')); $this->addComponent(GridFieldAddExistingAutocompleter::create('buttons-before-right')); @@ -44,13 +41,6 @@ public function __construct($itemsPerPage = null) $this->addComponent(GridFieldPageCount::create('toolbar-header-right')); $this->addComponent($pagination = GridFieldPaginator::create($itemsPerPage)); $this->addComponent(GridFieldDetailForm::create()); - - Deprecation::withSuppressedNotice(function () use ($sort, $filter, $pagination) { - $sort->setThrowExceptionOnBadDataType(false); - $filter->setThrowExceptionOnBadDataType(false); - $pagination->setThrowExceptionOnBadDataType(false); - }); - $this->extend('updateConfig'); } } diff --git a/src/Forms/GridField/GridFieldEditButton.php b/src/Forms/GridField/GridFieldEditButton.php index 0654817e7d2..4b658530726 100644 --- a/src/Forms/GridField/GridFieldEditButton.php +++ b/src/Forms/GridField/GridFieldEditButton.php @@ -61,9 +61,8 @@ public function getExtraData($gridField, $record, $columnName) /** * @inheritdoc - * @param bool $addState DEPRECATED: Should be removed in major release */ - public function getUrl($gridField, $record, $columnName, $addState = true) + public function getUrl($gridField, $record, $columnName) { $link = Controller::join_links( $gridField->Link('item'), @@ -71,7 +70,7 @@ public function getUrl($gridField, $record, $columnName, $addState = true) 'edit' ); - return $gridField->addAllStateToUrl($link, $addState); + return $gridField->addAllStateToUrl($link); } /** @@ -149,7 +148,7 @@ public function getColumnContent($gridField, $record, $columnName) // which can make the form readonly if no edit permissions are available. $data = new ArrayData([ - 'Link' => $this->getURL($gridField, $record, $columnName, false), + 'Link' => $this->getURL($gridField, $record, $columnName), 'ExtraClass' => $this->getExtraClass() ]); diff --git a/src/Forms/GridField/GridFieldFilterHeader.php b/src/Forms/GridField/GridFieldFilterHeader.php index fa273c1b0bc..e9e655fe761 100755 --- a/src/Forms/GridField/GridFieldFilterHeader.php +++ b/src/Forms/GridField/GridFieldFilterHeader.php @@ -7,7 +7,6 @@ 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; @@ -24,14 +23,6 @@ */ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridField_URLHandler, GridField_HTMLProvider, GridField_DataManipulator, GridField_ActionProvider, GridField_StateProvider { - /** - * See {@link setThrowExceptionOnBadDataType()} - * - * @var bool - * @deprecated 5.2.0 Will be removed without equivalent functionality - */ - protected $throwExceptionOnBadDataType = true; - /** * @var SearchContext */ @@ -60,34 +51,6 @@ public function getURLHandlers($gridField) ]; } - /** - * Determine what happens when this component is used with a list that isn't {@link SS_Filterable}. - * - * - true: An exception is thrown - * - false: This component will be ignored - it won't make any changes to the GridField. - * - * By default, this is set to true so that it's clearer what's happening, but the predefined - * {@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; - } - public function getSearchField(): ?string { return $this->searchField; @@ -110,15 +73,10 @@ protected function checkDataType($dataList) { if ($dataList instanceof SS_List) { 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_List list to be passed to the GridField." - ); - } - return false; } + throw new LogicException( + static::class . " expects an SS_List list to be passed to the GridField." + ); } /** diff --git a/src/Forms/GridField/GridFieldPaginator.php b/src/Forms/GridField/GridFieldPaginator.php index dd5b7497048..b2d6e6fb730 100755 --- a/src/Forms/GridField/GridFieldPaginator.php +++ b/src/Forms/GridField/GridFieldPaginator.php @@ -8,7 +8,6 @@ use SilverStripe\Model\ArrayData; use SilverStripe\View\SSViewer; use LogicException; -use SilverStripe\Dev\Deprecation; /** * GridFieldPaginator paginates the {@link GridField} list and adds controls @@ -31,12 +30,6 @@ class GridFieldPaginator extends AbstractGridFieldComponent implements GridField */ protected $itemsPerPage; - /** - * See {@link setThrowExceptionOnBadDataType()} - * @deprecated 5.2.0 Will be removed without equivalent functionality - */ - protected $throwExceptionOnBadDataType = true; - /** * * @param int $itemsPerPage - How many items should be displayed per page @@ -47,38 +40,6 @@ public function __construct($itemsPerPage = null) ?: GridFieldPaginator::config()->uninherited('default_items_per_page'); } - /** - * Determine what happens when this component is used with a list that isn't {@link SS_Filterable}. - * - * - true: An exception is thrown - * - false: This component will be ignored - it won't make any changes to the GridField. - * - * By default, this is set to true so that it's clearer what's happening, but the predefined - * {@link GridFieldConfig} subclasses set this to false for flexibility. - * - * @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; - } - - /** - * 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; - } - /** * Check that this dataList is of the right data type. * Returns false if it's a bad data type, and if appropriate, throws an exception. @@ -90,15 +51,11 @@ protected function checkDataType($dataList) { if ($dataList instanceof SS_List) { 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_List list to be passed to the GridField." - ); - } - return false; } + + throw new LogicException( + static::class . " expects an SS_List list to be passed to the GridField." + ); } /** diff --git a/src/Forms/GridField/GridFieldSortableHeader.php b/src/Forms/GridField/GridFieldSortableHeader.php index fe09fb854a6..338cda2bab2 100644 --- a/src/Forms/GridField/GridFieldSortableHeader.php +++ b/src/Forms/GridField/GridFieldSortableHeader.php @@ -12,7 +12,6 @@ use LogicException; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Injector\Injector; -use SilverStripe\Dev\Deprecation; /** * GridFieldSortableHeader adds column headers to a {@link GridField} that can @@ -23,51 +22,11 @@ class GridFieldSortableHeader extends AbstractGridFieldComponent implements GridField_HTMLProvider, GridField_DataManipulator, GridField_ActionProvider, GridField_StateProvider { - /** - * See {@link setThrowExceptionOnBadDataType()} - * - * @var bool - * @deprecated 5.2.0 Will be removed without equivalent functionality - */ - protected $throwExceptionOnBadDataType = true; - /** * @var array */ public $fieldSorting = []; - /** - * Determine what happens when this component is used with a list that isn't {@link SS_Filterable}. - * - * - true: An exception is thrown - * - false: This component will be ignored - it won't make any changes to the GridField. - * - * By default, this is set to true so that it's clearer what's happening, but the predefined - * {@link GridFieldConfig} subclasses set this to false for flexibility. - * - * @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; - } - - /** - * 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; - } - /** * Check that this dataList is of the right data type. * Returns false if it's a bad data type, and if appropriate, throws an exception. @@ -79,15 +38,10 @@ protected function checkDataType($dataList) { if ($dataList instanceof SS_List) { 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_List list to be passed to the GridField." - ); - } - return false; } + throw new LogicException( + static::class . " expects an SS_List list to be passed to the GridField." + ); } /** diff --git a/src/Forms/SearchableDropdownTrait.php b/src/Forms/SearchableDropdownTrait.php index de0240bff58..a01697aabf2 100644 --- a/src/Forms/SearchableDropdownTrait.php +++ b/src/Forms/SearchableDropdownTrait.php @@ -139,7 +139,6 @@ public function getPlaceholder(): string return $emptyString; } } - $name = $this->getName(); if ($this->getUseDynamicPlaceholder()) { if ($this->getIsSearchable()) { if (!$this->getIsLazyLoaded()) { diff --git a/src/Forms/Validation/CompositeValidator.php b/src/Forms/Validation/CompositeValidator.php index b77bed9559b..d9a666ccbd6 100644 --- a/src/Forms/Validation/CompositeValidator.php +++ b/src/Forms/Validation/CompositeValidator.php @@ -4,7 +4,6 @@ use InvalidArgumentException; use SilverStripe\Core\Validation\ValidationResult; -use SilverStripe\Dev\Deprecation; /** * CompositeValidator can contain between 0 and many different types of Validators. Each Validator is itself still diff --git a/src/Logging/ErrorOutputHandler.php b/src/Logging/ErrorOutputHandler.php index 5f858c001ec..1813e7259f0 100644 --- a/src/Logging/ErrorOutputHandler.php +++ b/src/Logging/ErrorOutputHandler.php @@ -4,7 +4,6 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Handler\AbstractProcessingHandler; -use Monolog\Level; use Monolog\LogRecord; use SilverStripe\Control\Controller; use SilverStripe\Control\Director; @@ -32,18 +31,6 @@ class ErrorOutputHandler extends AbstractProcessingHandler */ private $cliFormatter = null; - public function __construct(int|string|Level $level = Level::Debug, bool $bubble = true) - { - parent::__construct($level, $bubble); - Deprecation::withSuppressedNotice(function () { - Deprecation::notice( - '5.4.0', - 'Will be renamed to ErrorOutputHandler', - Deprecation::SCOPE_CLASS - ); - }); - } - /** * Get the mime type to use when displaying this error. * diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index 08f99de6bf2..65b00fe9ed9 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -2014,10 +2014,8 @@ public function getComponents($componentName, $id = null) // Determine type and nature of foreign relation $details = $schema->getHasManyComponentDetails(static::class, $componentName); if ($details['polymorphic']) { - $result = PolymorphicHasManyList::create($componentClass, $details['joinField'], static::class); - if ($details['needsRelation']) { - Deprecation::withSuppressedNotice(fn () => $result->setForeignRelation($componentName)); - } + $relation = $details['needsRelation'] ? $componentName : null; + $result = PolymorphicHasManyList::create($componentClass, $details['joinField'], static::class, $relation); } else { $result = HasManyList::create($componentClass, $details['joinField']); } @@ -4137,31 +4135,6 @@ public function isInDB() return is_numeric($this->ID) && $this->ID > 0; } - /* - * @ignore - * @deprecated 5.2.0 Will be removed without equivalent functionality - */ - private static $subclass_access = true; - - /** - * Temporarily disable subclass access in data object qeur - * @deprecated 5.2.0 Will be removed without equivalent functionality - */ - public static function disable_subclass_access() - { - Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); - DataObject::$subclass_access = false; - } - - /** - * @deprecated 5.2.0 Will be removed without equivalent functionality - */ - public static function enable_subclass_access() - { - Deprecation::notice('5.2.0', 'Will be removed without equivalent functionality'); - DataObject::$subclass_access = true; - } - //-------------------------------------------------------------------------------------------// /** diff --git a/src/ORM/DataQuery.php b/src/ORM/DataQuery.php index 29f7153421b..1aeea361e79 100644 --- a/src/ORM/DataQuery.php +++ b/src/ORM/DataQuery.php @@ -704,19 +704,9 @@ public function union(DataQuery|SQLSelect $query, ?string $type = null): static * Create a disjunctive subgroup. * * That is a subgroup joined by OR - * - * @param string $clause - * @return DataQuery_SubGroup */ - public function disjunctiveGroup() + public function disjunctiveGroup(string $clause = 'WHERE'): DataQuery_SubGroup { - // using func_get_args to add a new param while retaining BC - // @deprecated - add a new param for CMS 6 - string $clause = 'WHERE' - $clause = 'WHERE'; - $args = func_get_args(); - if (count($args) > 0) { - $clause = $args[0]; - } return new DataQuery_SubGroup($this, 'OR', $clause); } @@ -724,19 +714,9 @@ public function disjunctiveGroup() * Create a conjunctive subgroup * * That is a subgroup joined by AND - * - * @param string $clause - * @return DataQuery_SubGroup */ - public function conjunctiveGroup() + public function conjunctiveGroup(string $clause = 'WHERE'): DataQuery_SubGroup { - // using func_get_args to add a new param while retaining BC - // @deprecated - add a new param for CMS 6 - string $clause = 'WHERE' - $clause = 'WHERE'; - $args = func_get_args(); - if (count($args) > 0) { - $clause = $args[0]; - } return new DataQuery_SubGroup($this, 'AND', $clause); } diff --git a/src/ORM/DataQuery_SubGroup.php b/src/ORM/DataQuery_SubGroup.php index b6c6df1bb91..046457010d9 100644 --- a/src/ORM/DataQuery_SubGroup.php +++ b/src/ORM/DataQuery_SubGroup.php @@ -28,20 +28,8 @@ class DataQuery_SubGroup extends DataQuery implements SQLConditionGroup */ protected $havingQuery; - /** - * @param DataQuery $base - * @param string $connective - * @param string $clause - */ - public function __construct(DataQuery $base, $connective) + public function __construct(DataQuery $base, string $connective, string $clause = 'WHERE') { - // using func_get_args to add a 3rd param while retaining BC - // @deprecated - add a 3rd param for CMS 6 - string $clause = 'WHERE' - $clause = 'WHERE'; - $args = func_get_args(); - if (count($args) > 2) { - $clause = $args[2]; - } parent::__construct($base->dataClass); $this->query = $base->query; $this->clause = strtoupper($clause); diff --git a/src/ORM/PolymorphicHasManyList.php b/src/ORM/PolymorphicHasManyList.php index 2eac5a2f4e0..ba5225466cd 100644 --- a/src/ORM/PolymorphicHasManyList.php +++ b/src/ORM/PolymorphicHasManyList.php @@ -5,7 +5,6 @@ use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Convert; use InvalidArgumentException; -use SilverStripe\Dev\Deprecation; use Traversable; /** @@ -49,20 +48,6 @@ public function getForeignRelation(): ?string return $this->dataQuery->getQueryParam('Foreign.Relation'); } - /** - * Retrieve the name of the has_many relation this list is filtered by - * - * @deprecated 5.2.0 Will be replaced with a parameter in the constructor - */ - public function setForeignRelation(string $relationName): static - { - Deprecation::notice('5.2.0', 'Will be replaced with a parameter in the constructor'); - $foreignRelationColumn = DataObject::getSchema()->sqlColumnForField($this->dataClass, $this->relationForeignKey); - $this->dataQuery->where([$foreignRelationColumn => $relationName]); - $this->dataQuery->setQueryParam('Foreign.Relation', $relationName); - return $this; - } - /** * Gets the field name which holds the related (has_many) object class. */ @@ -89,8 +74,9 @@ public function getForeignRelationKey(): string * @param string $foreignField The name of the composite foreign (has_one) relation field. Used * to generate the ID, Class, and Relation foreign keys. * @param class-string $foreignClass Name of the class filter this relation is filtered against + * @param string $foreignRelation The name of the has_many relation this list is filtered by, if any. */ - public function __construct($dataClass, $foreignField, $foreignClass) + public function __construct(string $dataClass, string $foreignField, string $foreignClass, ?string $foreignRelation = null) { // Set both id foreign key (as in HasManyList) and the class foreign key parent::__construct($dataClass, "{$foreignField}ID"); @@ -100,6 +86,12 @@ public function __construct($dataClass, $foreignField, $foreignClass) // Ensure underlying DataQuery globally references the class filter $this->dataQuery->setQueryParam('Foreign.Class', $foreignClass); + if ($foreignRelation !== null) { + $foreignRelationColumn = DataObject::getSchema()->sqlColumnForField($this->dataClass, $this->relationForeignKey); + $this->dataQuery->where([$foreignRelationColumn => $foreignRelation]); + $this->dataQuery->setQueryParam('Foreign.Relation', $foreignRelation); + } + // For queries with multiple foreign IDs (such as that generated by // DataList::relation) the filter must be generalised to filter by subclasses $classNames = Convert::raw2sql(ClassInfo::subclassesFor($foreignClass)); diff --git a/src/Security/InheritedPermissions.php b/src/Security/InheritedPermissions.php index 9b06cce28dd..49f9498ad27 100644 --- a/src/Security/InheritedPermissions.php +++ b/src/Security/InheritedPermissions.php @@ -10,7 +10,6 @@ use SilverStripe\Versioned\Versioned; use Psr\SimpleCache\CacheInterface; use SilverStripe\Core\Cache\MemberCacheFlusher; -use SilverStripe\Dev\Deprecation; /** * Calculates batch permissions for nested objects for: @@ -637,20 +636,6 @@ protected function getPermissionField($type) } } - /** - * Get join table for type - * Defaults to those provided by {@see InheritedPermissionsExtension) - * - * @deprecated 5.1.0 Use getGroupJoinTable() instead - * @param string $type - * @return string - */ - protected function getJoinTable($type) - { - Deprecation::notice('5.1.0', 'Use getGroupJoinTable() instead'); - return $this->getGroupJoinTable($type); - } - /** * Get group join table for type * Defaults to those provided by {@see InheritedPermissionsExtension) diff --git a/src/Security/PasswordEncryptor_LegacyPHPHash.php b/src/Security/PasswordEncryptor_LegacyPHPHash.php deleted file mode 100644 index d8657ff2a52..00000000000 --- a/src/Security/PasswordEncryptor_LegacyPHPHash.php +++ /dev/null @@ -1,45 +0,0 @@ -encrypt($password, $salt, $member) ?? '', 0, 10)); - } -} diff --git a/src/Security/PasswordEncryptor_MySQLOldPassword.php b/src/Security/PasswordEncryptor_MySQLOldPassword.php deleted file mode 100644 index 2190313a900..00000000000 --- a/src/Security/PasswordEncryptor_MySQLOldPassword.php +++ /dev/null @@ -1,33 +0,0 @@ -value(); - } - - public function salt($password, $member = null) - { - return false; - } -} diff --git a/src/Security/PasswordEncryptor_MySQLPassword.php b/src/Security/PasswordEncryptor_MySQLPassword.php deleted file mode 100644 index f5b9fb506b2..00000000000 --- a/src/Security/PasswordEncryptor_MySQLPassword.php +++ /dev/null @@ -1,33 +0,0 @@ -value(); - } - - public function salt($password, $member = null) - { - return false; - } -} diff --git a/src/Security/PasswordEncryptor_None.php b/src/Security/PasswordEncryptor_None.php deleted file mode 100644 index d860545c27b..00000000000 --- a/src/Security/PasswordEncryptor_None.php +++ /dev/null @@ -1,33 +0,0 @@ -set(Director::class, 'alternate_base_folder', ). * - TEMP_PATH: Path to temporary folder for manifest and template caches. May be relative to project root or an * absolute path. No trailing slash. Can be set with the SS_TEMP_PATH environment variable. - * - TEMP_FOLDER: DEPRECATED. Same as TEMP_PATH. * - ASSETS_DIR: Dir for assets folder. e.g. "assets" * - ASSETS_PATH: Full path to assets folder. e.g. "/var/www/my-webroot/assets" * - THEMES_DIR: Path relative to webroot, e.g. "themes" @@ -186,16 +185,9 @@ }); } -// Custom include path - deprecated -if (defined('CUSTOM_INCLUDE_PATH')) { - set_include_path(CUSTOM_INCLUDE_PATH . PATH_SEPARATOR . get_include_path()); -} - // Define the temporary folder if it wasn't defined yet if (!defined('TEMP_PATH')) { - if (defined('TEMP_FOLDER')) { - define('TEMP_PATH', TEMP_FOLDER); - } elseif ($path = Environment::getEnv('SS_TEMP_PATH')) { + if ($path = Environment::getEnv('SS_TEMP_PATH')) { // If path is relative, rewrite it to be relative to BASE_PATH - as web requests are relative to // public/index.php, and we don't want the TEMP_PATH to be inside the public/ directory by default if (ltrim($path ?? '', DIRECTORY_SEPARATOR) === $path) { @@ -207,11 +199,6 @@ } } -// Define the temporary folder for backwards compatibility -if (!defined('TEMP_FOLDER')) { - define('TEMP_FOLDER', TEMP_PATH); -} - // Define the resource dir constant that will be use to exposed vendor assets if (!defined('RESOURCES_DIR')) { $project = new SilverStripe\Core\Manifest\Module(BASE_PATH, BASE_PATH); diff --git a/tests/php/Cli/SakeTest.php b/tests/php/Cli/SakeTest.php index 8434484c2ba..f585298ae2f 100644 --- a/tests/php/Cli/SakeTest.php +++ b/tests/php/Cli/SakeTest.php @@ -3,7 +3,6 @@ namespace SilverStripe\Cli\Tests; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Error\Deprecated; use ReflectionClass; use SilverStripe\Cli\Sake; use SilverStripe\Cli\Tests\SakeTest\TestBuildTask; diff --git a/tests/php/Forms/GridField/GridFieldPaginatorTest.php b/tests/php/Forms/GridField/GridFieldPaginatorTest.php index f2febae4b1a..131dbdc59de 100644 --- a/tests/php/Forms/GridField/GridFieldPaginatorTest.php +++ b/tests/php/Forms/GridField/GridFieldPaginatorTest.php @@ -95,7 +95,6 @@ public function testUnlimitedRowCount() // set up the paginator /** @var GridFieldPaginator $paginator */ $paginator = $this->gridField->getConfig()->getComponentByType(GridFieldPaginator::class); - $paginator->setThrowExceptionOnBadDataType(true); $paginator->setItemsPerPage(1); $paginator->getManipulatedData($this->gridField, $this->list); diff --git a/tests/php/Forms/GridField/GridFieldTest.php b/tests/php/Forms/GridField/GridFieldTest.php index 2b580961bea..a4a9760f410 100644 --- a/tests/php/Forms/GridField/GridFieldTest.php +++ b/tests/php/Forms/GridField/GridFieldTest.php @@ -65,16 +65,13 @@ public function testGridFieldDefaultConfig() $expectedComponents = new ArrayList([ new GridFieldToolbarHeader(), new GridFieldButtonRow(), - $sort = new GridFieldSortableHeader(), - $filter = new GridFieldFilterHeader(), + new GridFieldSortableHeader(), + new GridFieldFilterHeader(), new GridFieldDataColumns(), new GridFieldPageCount('toolbar-header-right'), - $pagination = new GridFieldPaginator(), + new GridFieldPaginator(), new GridState_Component(), ]); - $sort->setThrowExceptionOnBadDataType(false); - $filter->setThrowExceptionOnBadDataType(false); - $pagination->setThrowExceptionOnBadDataType(false); $this->assertEquals($expectedComponents, $obj->getConfig()->getComponents(), 'Testing default Config'); } @@ -299,7 +296,8 @@ public function testGetColumnMetadataBadArguments() public function testHandleActionBadArgument() { $this->expectException(\InvalidArgumentException::class); - $obj = new GridField('testfield', 'testfield'); + $list = ArrayList::create(); + $obj = new GridField('testfield', 'testfield', $list); $obj->handleAlterAction('prft', [], []); } diff --git a/tests/php/Security/MemberTest.php b/tests/php/Security/MemberTest.php index 935fa90fc88..5104f3a85cb 100644 --- a/tests/php/Security/MemberTest.php +++ b/tests/php/Security/MemberTest.php @@ -80,12 +80,12 @@ protected function setUp(): void public function testPasswordEncryptionUpdatedOnChangedPassword() { - Config::modify()->set(Security::class, 'password_encryption_algorithm', 'none'); + Config::modify()->set(Security::class, 'password_encryption_algorithm', 'sha1'); $member = Member::create(); $member->Password = 'password'; $member->write(); - $this->assertEquals('password', $member->Password); - $this->assertEquals('none', $member->PasswordEncryption); + $this->assertNotEquals('password', $member->Password); + $this->assertEquals('sha1', $member->PasswordEncryption); Config::modify()->set(Security::class, 'password_encryption_algorithm', 'blowfish'); $member->Password = 'newpassword'; $member->write(); diff --git a/tests/php/Security/PasswordEncryptorTest.php b/tests/php/Security/PasswordEncryptorTest.php index 11f13413b6d..024bc235c3b 100644 --- a/tests/php/Security/PasswordEncryptorTest.php +++ b/tests/php/Security/PasswordEncryptorTest.php @@ -142,27 +142,4 @@ public function testEncryptorPHPHashCheck() $this->assertTrue($e->check(sha1('mypassword'), 'mypassword')); $this->assertFalse($e->check(sha1('mypassword'), 'mywrongpassword')); } - - /** - * See http://open.silverstripe.org/ticket/3004 - * - * Handy command for reproducing via CLI on different architectures: - * php -r "echo(base_convert(sha1('mypassword'), 16, 36));" - */ - public function testEncryptorLegacyPHPHashCheck() - { - Config::modify()->merge( - PasswordEncryptor::class, - 'encryptors', - ['test_sha1legacy' => [PasswordEncryptor_LegacyPHPHash::class => 'sha1']] - ); - $e = Deprecation::withSuppressedNotice(fn() => PasswordEncryptor::create_for_algorithm('test_sha1legacy')); - // precomputed hashes for 'mypassword' from different architectures - $amdHash = 'h1fj0a6m4o6k0sosks88oo08ko4gc4s'; - $intelHash = 'h1fj0a6m4o0g04ocg00o4kwoc4wowws'; - $wrongHash = 'h1fjxxxxxxxxxxxxxxxxxxxxxxxxxxx'; - $this->assertTrue($e->check($amdHash, "mypassword")); - $this->assertTrue($e->check($intelHash, "mypassword")); - $this->assertFalse($e->check($wrongHash, "mypassword")); - } }