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

WP/CronInterval: bugfix for fully qualified time constants #2073

Merged

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 7, 2022

If the WP time constants would be used in their fully qualified form, as is often encountered in namespaced files, the sniff would no longer be able to correctly determine the interval being scheduled.

Note: To prevent constants from a different namespace accidentally matching the WP native constants, the namespace separator is replaced by a space character rather than just ignored. The regex before running the eval() will prevent code with identifier names other than the WP time constants from being passed to the eval(), meaning those will still be reported as "interval undetermined".

This commit fixes that.
Includes unit tests.

WordPress/Tests/WP/CronIntervalUnitTest.inc Outdated Show resolved Hide resolved
WordPress/Tests/WP/CronIntervalUnitTest.inc Outdated Show resolved Hide resolved
WordPress/Tests/WP/CronIntervalUnitTest.inc Outdated Show resolved Hide resolved
@jrfnl
Copy link
Member Author

jrfnl commented Aug 8, 2022

Added a second commit addressing the review remarks for easier verification, Please squash the commit on merge (or I can squash and force push ahead of merge).

Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

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

Approving, with one suggestion / self-note.

WordPress/Tests/WP/CronIntervalUnitTest.inc Show resolved Hide resolved
@jrfnl jrfnl force-pushed the feature/wp-croninterval-bugfix-fully-qualified-constants branch from 6784816 to fe09fed Compare August 8, 2022 16:43
dingo-d pushed a commit that referenced this pull request Aug 9, 2022
See: #2073 (comment)

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
If the WP time constants would be used in their fully qualified form, as is often encountered in namespaced files, the sniff would no longer be able to correctly determine the interval being scheduled.

This commit fixes that.

Note: To prevent constants from a different namespace accidentally matching the WP native constants, the namespace separator is replace by a space character rather than just ignored. The regex before running the `eval()` will prevent code with identifier names other than the WP time constants from being passed to the `eval()`, meaning those will still be reported as "interval undetermined".

Includes unit tests.
@jrfnl jrfnl force-pushed the feature/wp-croninterval-bugfix-fully-qualified-constants branch from fe09fed to 935257b Compare August 9, 2022 12:21
@jrfnl
Copy link
Member Author

jrfnl commented Aug 9, 2022

I've rebased the PR (without changes) to get passed the imaginary merge conflict. I've squashed the second commit with the updates after review into the first one now as well, so if found okay, this PR can now be merged normally.

@dingo-d dingo-d merged commit 55aad08 into develop Aug 10, 2022
@dingo-d dingo-d deleted the feature/wp-croninterval-bugfix-fully-qualified-constants branch August 10, 2022 07:27
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.

None yet

3 participants