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

Conversation

GuySartorelli
Copy link
Member

Comment on lines 8 to 9
md5:
'SilverStripe\Security\PasswordEncryptor_LegacyPHPHash': md5
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 keeping this key and setting it to PasswordEncryptor_PHPHash because md5 is inherently insecure, so anyone already using it should be prompted to consider changing to something else.

Copy link
Member

Choose a reason for hiding this comment

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

This, isn't just removing deprecated code? Seems like this is something else where we're making a decision that md5 is not good? Seems a bit out of scope?. Wouldn't this means there are other things to consider, for instance is it worth considering if sha1 and blowfish also up to scratch? Also there's an md5_v2.4 key below that's retained

Copy link
Member Author

@GuySartorelli GuySartorelli Jan 7, 2025

Choose a reason for hiding this comment

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

This is literally just removing code. I have decided not to add other code because md5 sucks - but as far as this PR which is to remove deprecated code, that's exactly what is being done here.

Copy link
Member

@emteknetnz emteknetnz Jan 7, 2025

Choose a reason for hiding this comment

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

I get that md5 isn't good, though we still have md5 support via the md5_v2.4 key below. Also, again, removing md5 support is out of scope since the scope of this issue is to only to remove deprecated code and we haven't "deprecated" md5 support.

Seems like the correct thing would be to retain the md5 key and just change its class to SilverStripe\Security\PasswordEncryptor_PHPHash like you did for sha1?

Copy link
Member Author

@GuySartorelli GuySartorelli Jan 7, 2025

Choose a reason for hiding this comment

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

I wholeheartedly and completely disagree with every fibre of my being but I'll do it anyway so we can move on.

The implication to me is that the encryptor being deprecated means the config that instantiates it is also deprecated. Anyone who has explicitly set their project to use md5 will currently be getting a deprecation notice telling them that the legacy PHP hash encrpytor is deprecated.

I only migrated the sha1 key because that's still a sensible hash algorithm to use. md5 very very very much isn't. We should really remove it even from the encryptor we are keeping but that is farther out of scope than I want to do in this PR.

Anyway, md5 is back :(

Copy link
Member

@emteknetnz emteknetnz Jan 7, 2025

Choose a reason for hiding this comment

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

The class which is deprecated is separate from the algorithm. People would also be getting deprecation notices for the sha1 algorithm as well though we're not removing that

I've backlogged a new issue for this #11530

*
* @return string|null null if not overridden, otherwise the actual value
*/
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).

Copy link
Member Author

Choose a reason for hiding this comment

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

Should have been removed in #10456 back when we did CMS 5 work.
No need to mention this in the changelog, since this is dead code as the tests mentioned in the linked PR prove.

Comment on lines -101 to -107
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'
);
}
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.

Copy link
Member Author

Choose a reason for hiding this comment

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

See comment about SessionEnvTypeSwitcher

@@ -4,7 +4,6 @@

use InvalidArgumentException;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Dev\Deprecation;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused

Comment on lines -2017 to +2018
$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);
Copy link
Member Author

Choose a reason for hiding this comment

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

setForeignRelation() is removed, and a new constructor arg is added in its place.

@@ -9,7 +9,6 @@
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Core\Manifest\ModuleResourceLoader;
use SilverStripe\Core\Path;
use SilverStripe\Dev\Deprecation;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused

@@ -3,7 +3,6 @@
namespace SilverStripe\Cli\Tests;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Error\Deprecated;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unused

Comment on lines -302 to +300
$obj = new GridField('testfield', 'testfield');
$list = ArrayList::create();
$obj = new GridField('testfield', 'testfield', $list);
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed to avoid LogicException now that setThrowExceptionOnBadDataType() is removed from various components.

@GuySartorelli GuySartorelli force-pushed the pulls/6.0/remove-deprecated branch 2 times, most recently from 3e7be21 to e70fcc0 Compare January 7, 2025 01:06
Comment on lines 8 to 9
md5:
'SilverStripe\Security\PasswordEncryptor_LegacyPHPHash': md5
Copy link
Member

Choose a reason for hiding this comment

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

This, isn't just removing deprecated code? Seems like this is something else where we're making a decision that md5 is not good? Seems a bit out of scope?. Wouldn't this means there are other things to consider, for instance is it worth considering if sha1 and blowfish also up to scratch? Also there's an md5_v2.4 key below that's retained

*/
public function __construct($dataClass, $foreignField, $foreignClass)
public function __construct(string $dataClass, string $foreignField, string $foreignClass, ?string $foreignRelation = null)
Copy link
Member

Choose a reason for hiding this comment

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

Why is a new param being added here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because that was always the intention. As per the deprecation notice:

@deprecated 5.2.0 Will be replaced with a parameter in the constructor

@emteknetnz emteknetnz merged commit e2a4804 into silverstripe:6.0 Jan 7, 2025
12 checks passed
@emteknetnz emteknetnz deleted the pulls/6.0/remove-deprecated branch January 7, 2025 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants