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 passing timezone information to methods where it is ignored #6020

Closed
wants to merge 1 commit into from

Conversation

phansys
Copy link
Contributor

@phansys phansys commented Apr 19, 2023

Q A
Type improvement
Fixed issues n/a

Summary

The offset comparison is made against the default timezone instead of UTC because the user may be using a specific default timezone on purpose.

Related to #6014 and #6017 (comment).

@phansys
Copy link
Contributor Author

phansys commented Apr 19, 2023

@greg0ire, do you think something like this can prevent those foot shots?

@phansys phansys force-pushed the tz_offsets branch 2 times, most recently from 84e812e to 0cdd7a4 Compare April 21, 2023 14:22
@github-actions
Copy link

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
If you want to continue working on it, please leave a comment.

@github-actions github-actions bot added the Stale label Jul 21, 2023
@greg0ire
Copy link
Member

@phansys sorry for ignoring you, I must have get swamped. Yes, I think that would help.

@phansys phansys force-pushed the tz_offsets branch 3 times, most recently from 694728b to f4767aa Compare July 21, 2023 13:17
@phansys
Copy link
Contributor Author

phansys commented Jul 21, 2023

@phansys sorry for ignoring you, I must have get swamped. Yes, I think that would help.

Don't worry! no problem. we all have our times and own occupations.
Thank you.

@phansys phansys force-pushed the tz_offsets branch 2 times, most recently from bcd0866 to 5260030 Compare July 21, 2023 13:35
@phansys phansys marked this pull request as ready for review July 21, 2023 14:28
@phansys phansys changed the title [PoC] Deprecate passing timezone information to methods where it is ignored Deprecate passing timezone information to methods where it is ignored Jul 21, 2023
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

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

Please add tests. doctrine/deprecations comes with helpers for catching deprecations.

if ($offset !== $defaultOffset) {
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/xxxx',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'https://github.com/doctrine/dbal/pull/xxxx',
'https://github.com/doctrine/dbal/pull/6020',

if ($offset !== $defaultOffset) {
Deprecation::triggerIfCalledFromOutside(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/xxxx',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'https://github.com/doctrine/dbal/pull/xxxx',
'https://github.com/doctrine/dbal/pull/6020',

@phansys phansys marked this pull request as draft July 21, 2023 15:00
@phansys phansys force-pushed the tz_offsets branch 4 times, most recently from ed2abda to b10717c Compare July 21, 2023 16:55
@phansys phansys marked this pull request as ready for review July 21, 2023 19:24
@phansys phansys requested a review from greg0ire July 21, 2023 19:24
@github-actions github-actions bot removed the Stale label Jul 22, 2023
greg0ire
greg0ire previously approved these changes Jul 25, 2023
@greg0ire greg0ire closed this Jul 25, 2023
@greg0ire greg0ire reopened this Jul 25, 2023
@greg0ire
Copy link
Member

Ah I need to merge up. Hang on.

@greg0ire greg0ire closed this Jul 25, 2023
@greg0ire greg0ire reopened this Jul 25, 2023
@greg0ire
Copy link
Member

That worked. Please address the remaining CS issues.

@@ -117,4 +130,96 @@ public function testRequiresSQLCommentHint(): void
{
self::assertTrue($this->type->requiresSQLCommentHint($this->platform));
}

/** @dataProvider provideDateTimeInstancesWithTimezone */
public function testTimezoneDeprecationFromConvertsToDatabaseValue(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public function testTimezoneDeprecationFromConvertsToDatabaseValue(
public function testTimezoneDeprecationFromConvertToDatabaseValue(

$defaultOffset = (new DateTimeImmutable())->format('O');

if ($offset !== $defaultOffset) {
Deprecation::triggerIfCalledFromOutside(
Copy link
Member

Choose a reason for hiding this comment

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

Is there a realistic situation where this deprecation might be triggered? In what case could the DBAL provide timezone information to this method? If it is lost when saving to the database, this seems unlikely, but maybe there are other situations I did not think of? If the timezone of the database server and the application server differ, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, I must review the flow in order to answer.

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
If you want to continue working on it, please leave a comment.

@github-actions github-actions bot added the Stale label Oct 25, 2023
Copy link

github-actions bot commented Nov 2, 2023

This pull request was closed due to inactivity.

@github-actions github-actions bot closed this Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants