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

Deprecate redundant HTTP keys #3973

Merged
merged 1 commit into from
Jan 5, 2021
Merged

Deprecate redundant HTTP keys #3973

merged 1 commit into from
Jan 5, 2021

Conversation

paulbalandan
Copy link
Member

Description
With the merge of the refactored Security class, the redundant HTTP.disallowedAction and HTTP.invalidSamSiteSetting can be removed in favor of the Security counterpart.

Checklist:

  • Securely signed commits

@sfadschm
Copy link
Contributor

sfadschm commented Dec 8, 2020

I just checked and they still seem to be in use, e.g., here:

public static function forInvalidSameSiteSetting(string $samesite)
{
return new static(lang('HTTP.invalidSameSiteSetting', [$samesite]));
}

and in the corresponding tests.
I'm all for dropping as many duplicates as possible but not sure if it makes sense to change HTTP to Security in the above example.

@sfadschm
Copy link
Contributor

sfadschm commented Dec 8, 2020

Can we maybe add some testing for all language strings called in the framework to see if they are really defined?

@MGatner
Copy link
Member

MGatner commented Dec 12, 2020

I like @sfadschm's idea, it could even be implemented as an Action for PRs. It should check both directions: for language calls missing a key and for unused keys.

For this PR, and generally, I think that we need to deprecate language strings instead of removing them because any module or project could be using the framework strings. While it technically would not crash the code the output could suddenly change to something unhelpful like "System.description"

@sfadschm
Copy link
Contributor

sfadschm commented Dec 12, 2020

Checking both directions sounds reasonable. I thought about such tests some days ago, but the only thing I could come up with was to load all language keys, then read the contents of all framework files and preg_match_all all the contents with lang('...').
The results could then be generated with two simple array_diffs but I still feel this puts some significant extra load on the tests.

I agree on the deprecation, but I think we can not really have both tests and deprecation, as the tests would have no way to tell a language string has already been deprecated and should not throw an error, or am I missing out on something?

@paulbalandan
Copy link
Member Author

I believe system messages should be strictly for internal use and should not be used in users' code and covered by BC promise. The usage should remain strictly in the framework alone and users should implement their own keys. Since these messages are typically used within thrown exceptions, users wanting to use the messages should use it rather indirectly, i.e. using the throw Exception::something();

@sfadschm
Copy link
Contributor

I believe system messages should be strictly for internal use and should not be used in users' code and covered by BC promise. The usage should remain strictly in the framework alone and users should implement their own keys. Since these messages are typically used within thrown exceptions, users wanting to use the messages should use it rather indirectly, i.e. using the throw Exception::something();

I'm with you on this, but I still also think that there is projects out there using those messages, which will face some unexpected messages like MGatner said.

How about applying this to 4.1 with a note in the update changelog and maybe a small notice in the user manual, that these keys are not BC covered?

@MGatner
Copy link
Member

MGatner commented Jan 5, 2021

@paulbalandan What do you think of @sfadschm's idea? I think that is a good compromise: we add a comment that these are deprecated but leave them, then note in the UG and changelog for 4.1 the system language strings are all considered internal and can be changed without warning.

@lonnieezell I think you should weigh in on this as well.

@lonnieezell
Copy link
Member

I agree system messages are intended to be for internal use. I like the suggested compromise.

@paulbalandan paulbalandan changed the title Remove redundant HTTP keys Deprecate redundant HTTP keys Jan 5, 2021
@paulbalandan paulbalandan requested a review from MGatner January 5, 2021 15:24
@MGatner
Copy link
Member

MGatner commented Jan 5, 2021

Key deprecation looks good. The PHP 8 SA is allowed (#4065). What about a line in the UG and changelog about language files being internal? or were you thinking that would be a separate PR?

@paulbalandan
Copy link
Member Author

Key deprecation looks good. The PHP 8 SA is allowed (#4065). What about a line in the UG and changelog about language files being internal? or were you thinking that would be a separate PR?

Yes, I'm thinking of a separate PR for them.

@MGatner MGatner merged commit 034e0c4 into develop Jan 5, 2021
@MGatner MGatner deleted the redundant-http-keys branch January 5, 2021 16:10
@paulbalandan paulbalandan removed the request for review from MGatner April 11, 2021 17:00
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.

4 participants