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

New DateTime.CurrentTimeTimestamp sniff #1808

Merged
merged 1 commit into from Oct 30, 2019

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 5, 2019

This new sniff adds a check for use of current_time() to retrieve a timestamp.

A (fixable) error will be thrown when the $gmt parameter is set to true or 1, a warning when it is not.

Includes unit tests.
Includes fixer.
Includes documentation.

This new sniff has been added to the Core ruleset.

Fixes #1791

/cc @Rarst

@jrfnl
Copy link
Member Author

jrfnl commented Oct 5, 2019

@Rarst Looking at your blogpost at Make, should this sniff also check for get_post_time( 'U' ) ?

@Rarst
Copy link
Contributor

Rarst commented Oct 7, 2019

should this sniff also check for get_post_time( 'U' )

Uh... Maybe later. We hadn't scraped those out of core yet. Want to just let release go out and dust settle for a bit right now. :)

@jrfnl
Copy link
Member Author

jrfnl commented Oct 7, 2019

Uh... Maybe later. We hadn't scraped those out of core yet.

That shouldn't really be a consideration.
If that code pattern shouldn't be used, we can already start throwing errors/warnings for it.

As long as we don't make the error/warning auto-fixable, the Core builds won't fail on it (and it will help detect the issue in Core).

@Rarst
Copy link
Contributor

Rarst commented Oct 7, 2019

That shouldn't really be a consideration.
If that code pattern shouldn't be used, we can already start throwing errors/warnings for it.

Well, it is for me. Getting these things out of core is a necessary legwork to figure out what depends on it and what needs to be done to dump it in all (or at least a lot of) cases.

My opinion is that we hadn't done equivalent amount of work to get rid of that one and are not ready to start sniffing it out. Soft recommendation to start using replacements takes a lower level of confidence than a hard sniff for me.

@jrfnl
Copy link
Member Author

jrfnl commented Oct 7, 2019

Soft recommendation to start using replacements takes a lower level of confidence than a hard sniff for me.

Ok, fair enough. We can always add it at a later point in time.

*
* Disallow using the current_time() function to get "timestamps" as it
* doesn't produce a *real* timestamp, but a "WordPress timestamp", i.e.
* a Unix timestamp with current timezone offset, not a Unix timestamp ansich.
Copy link
Member

Choose a reason for hiding this comment

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

What is ansich?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@dingo-d dingo-d left a comment

Choose a reason for hiding this comment

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

The OK. Well not really, but not our concern. made me chuckle 😄

This new sniff adds a check for use of current_time() to retrieve a timestamp.

A (fixable) `error` will be thrown when the `$gmt` parameter is set to `true` or `1`, a `warning` when it is not.

Includes unit tests.
Includes fixer.
Includes documentation.

This new sniff has been added to the `Core` ruleset.

Fixes 1791
@jrfnl jrfnl force-pushed the feature/new-currenttime-timestamp-sniff branch from 1dcfae7 to e4f838c Compare October 27, 2019 12:06
@jrfnl
Copy link
Member Author

jrfnl commented Oct 27, 2019

Rebased for merge conflict.

@jrfnl
Copy link
Member Author

jrfnl commented Oct 29, 2019

Anything I can do to move this PR forward ?

@dingo-d dingo-d merged commit b922e44 into develop Oct 30, 2019
@dingo-d dingo-d deleted the feature/new-currenttime-timestamp-sniff branch October 30, 2019 07:16
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.

Discourage use current_time( 'timestamp' )
4 participants