Skip to content

fix: wrong number of $accepted_args on add_filter() calls - #66694

Merged
gziolo merged 2 commits into
WordPress:trunkfrom
justlevine:fix/add-filter-accepted-args
Jan 2, 2025
Merged

gziolo merged 2 commits into
WordPress:trunkfrom
justlevine:fix/add-filter-accepted-args

Conversation

@justlevine

@justlevine justlevine commented Nov 2, 2024 •

Copy link
Copy Markdown
Contributor

What?

This PR fixes several instances of the wrong number of $accepted_args being passed to add_filter(), so the match the correct number of args taken by their callbacks.

As the correct $accepted_args and $priority are the defaults once corrected, the explicit args have been removed entirely.

Why?

While this issue was surfaced by PHPStan (via #66693) it can be remediated independently as part of #66598

How?

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

@github-actions

github-actions Bot commented Nov 2, 2024 •

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: Gutenberg Plugin, [Type] Code Quality, No Core Sync Required.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Nov 2, 2024 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: szepeviktor <szepeviktor@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 2, 2024
@github-actions

github-actions Bot commented Nov 2, 2024

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @justlevine! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@szepeviktor

Copy link
Copy Markdown
Contributor

Yes, level 0 problems must be fixed.

I consider applications with level 4 problems broken.

@Mamaduka Mamaduka added Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Code Quality Issues or PRs that relate to code quality labels Nov 5, 2024
@Mamaduka

Mamaduka commented Nov 5, 2024

Copy link
Copy Markdown
Member

I think we can just omit $accepted_args when the value is one. It's the default value for hooks.

@justlevine

Copy link
Copy Markdown
Contributor Author

I think we can just omit $accepted_args when the value is one. It's the default value for hooks.

Perhaps, but figured I'd match the existing patterns e.g.

add_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_block_style_variation_styles', 1 );

@Mamaduka

Mamaduka commented Nov 5, 2024

Copy link
Copy Markdown
Member

The 1 in that example is $priority and not the $accepted_args. In any case, it was a minor nitpick, nothing blocker for this PR.

@justlevine

Copy link
Copy Markdown
Contributor Author

@gziolo / @Mamaduka apologies, I thought I pushed this back in november 😅

Updated in 0beec7c

@gziolo gziolo removed the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 28, 2024

@gziolo gziolo 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.

Thank you for addressing the feedback.

@gziolo gziolo added the No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core label Jan 2, 2025
@gziolo
gziolo merged commit e2e9c32 into WordPress:trunk Jan 2, 2025
@github-actions github-actions Bot added this to the Gutenberg 20.0 milestone Jan 2, 2025
@justlevine
justlevine deleted the fix/add-filter-accepted-args branch January 2, 2025 10:11
bph pushed a commit to bph/gutenberg that referenced this pull request Jan 8, 2025
…ess#66694)

* fix: wrong number of `$accepted_args` on `add_filter()` calls

* fix: use default priority/accepted_args

Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: szepeviktor <szepeviktor@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Gulamdastgir-Momin pushed a commit to Gulamdastgir-Momin/gutenberg that referenced this pull request Jan 23, 2025
…ess#66694)

* fix: wrong number of `$accepted_args` on `add_filter()` calls

* fix: use default priority/accepted_args

Co-authored-by: justlevine <justlevine@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: szepeviktor <szepeviktor@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants