Skip to content

Commit

Permalink
API Remove deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 6, 2025
1 parent dc973c6 commit 4423eac
Show file tree
Hide file tree
Showing 33 changed files with 46 additions and 600 deletions.
6 changes: 1 addition & 5 deletions _config/encryptors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ name: coreencryptors
---
'SilverStripe\Security\PasswordEncryptor':
encryptors:
none:
'SilverStripe\Security\PasswordEncryptor_None':
md5:
'SilverStripe\Security\PasswordEncryptor_LegacyPHPHash': md5
sha1:
'SilverStripe\Security\PasswordEncryptor_LegacyPHPHash': sha1
'SilverStripe\Security\PasswordEncryptor_PHPHash': sha1
md5_v2.4:
'SilverStripe\Security\PasswordEncryptor_PHPHash': md5
sha1_v2.4:
Expand Down
27 changes: 0 additions & 27 deletions src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,33 +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
*/
public static function get_session_environment_type(?HTTPRequest $request = null)
{
$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()}.
Expand Down
11 changes: 2 additions & 9 deletions src/Control/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,12 @@ public static function absoluteURLs($html)
* </code>
*
* @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 = [];
Expand Down
52 changes: 4 additions & 48 deletions src/Core/Manifest/VersionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -197,51 +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
*/
protected function getComposerLockPath(): string
protected function getCacheKey(string $module = '_all'): string
{
return BASE_PATH . '/composer.lock';
return preg_replace("/[^A-Za-z0-9]/", '_', BASE_PATH . $module);
}
}
13 changes: 0 additions & 13 deletions src/Dev/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 0 additions & 9 deletions src/Forms/FieldList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 3 additions & 12 deletions src/Forms/GridField/GridFieldConfig_Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace SilverStripe\Forms\GridField;

use SilverStripe\Dev\Deprecation;

/**
* A simple readonly, paginated view of records, with sortable and searchable
* headers.
Expand All @@ -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');
}
}
16 changes: 3 additions & 13 deletions src/Forms/GridField/GridFieldConfig_RecordEditor.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
namespace SilverStripe\Forms\GridField;

use SilverStripe\Dev\Deprecation;

/**
* Allows editing of records contained within the GridField, instead of only allowing the ability to view records in
* the GridField.
Expand All @@ -18,26 +16,18 @@ class GridFieldConfig_RecordEditor extends GridFieldConfig
public function __construct($itemsPerPage = null, $showPagination = null, $showAdd = null)
{
parent::__construct();

$this->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');
}
}
10 changes: 0 additions & 10 deletions src/Forms/GridField/GridFieldConfig_RelationEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'));
Expand All @@ -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');
}
}
7 changes: 3 additions & 4 deletions src/Forms/GridField/GridFieldEditButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,16 @@ 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'),
$record->ID,
'edit'
);

return $gridField->addAllStateToUrl($link, $addState);
return $gridField->addAllStateToUrl($link);
}

/**
Expand Down Expand Up @@ -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()
]);

Expand Down
Loading

0 comments on commit 4423eac

Please sign in to comment.