Skip to content

WP/CronInterval: make callback function name lookup case-insensitive#2730

Open
rodrigoprimo wants to merge 2 commits into
developfrom
fix-cron-interval
Open

WP/CronInterval: make callback function name lookup case-insensitive#2730
rodrigoprimo wants to merge 2 commits into
developfrom
fix-cron-interval

Conversation

@rodrigoprimo

Copy link
Copy Markdown
Contributor

Description

The WordPress.WP.CronInterval sniff was incorrectly treating callback function names as case-sensitive when trying to locate the callback function definition. This led to false positives when the callback reference case did not match the function declaration case.

The fix ensures callback names are compared case-insensitively using strcasecmp() when searching for function declarations in the code.

Suggested changelog entry

WordPress.WP.CronInterval: false positive when the callback function reference used different casing than the function declaration.

The sniff was incorrectly treating callback function names as case-sensitive when trying to locate the callback function definition. This led to false positives when the callback reference case did not match the function declaration case.

The fix ensures callback names are compared case-insensitively using `strcasecmp()` when searching for function declarations in the code.

@jrfnl jrfnl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rodrigoprimo Thanks for this PR. Looks good to me. Just one tiny nitpick.

Comment on lines 167 to 169
add_filter( 'cron_schedules', array( $this, 'ADD_WEEKLY_SCHEDULE' ) ); // Ok: > 15 min.
\add_filter( 'cron_schedules', array( $this, 'add_eight_minute_schedule' ) ); // Warning: 8 min.
ADD_FILTER( 'cron_schedules', array( $this, 'add_hundred_minute_schedule' ) ); // Warning: time undetermined.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

May I suggest using the "Warning: time undetermined" case for the "all caps" test instead ? That way all three possible situations (OK, warning time, warning undetermined) all have a test with a different cased callback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review, Juliette! I applied your suggestion in a new commit.

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.

2 participants