Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Remove deprecated API #11524

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions _config/encryptors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 0 additions & 30 deletions src/Control/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't used anywhere in core or supported modules. It was added in ca56e8d#diff-983f05f9a107b9bf66a1ed4230e524be82118dd71f4a795529f8794b762c8b47R1091 as a replacement for CoreKernel::sessionEnvironment(). It was removed in #10456.

It and this method seem to have only existed to support the isDev and isTest GET variables, which were intentionally removed in CMS 5.

isDev and isTest query string arguments have been removed due to security concerns (see ss-2018-005).

{
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()}.
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'
);
}
Comment on lines -101 to -107
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really a deprecation but seems sensible to have an explicit typed parameter instead of an exception here.


// Replace attributes
$attribs = ["src", "background", "a" => "href", "link" => "href", "base" => "href"];
$regExps = [];
Expand Down
5 changes: 1 addition & 4 deletions src/Control/HTTPApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
}
}
11 changes: 2 additions & 9 deletions src/Control/Middleware/URLSpecialsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
}

/**
Expand All @@ -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));

Expand Down

This file was deleted.

54 changes: 4 additions & 50 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,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);
}
}
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');
}
}
Loading
Loading