Skip to content

Drop php4 support for do action first arg array object type in favor of better support of PHP7+ native types#5839

Closed
kkmuffme wants to merge 4 commits intoWordPress:trunkfrom
kkmuffme:drop-php4-support-for-do_action-first-arg-array-object-type
Closed

Drop php4 support for do action first arg array object type in favor of better support of PHP7+ native types#5839
kkmuffme wants to merge 4 commits intoWordPress:trunkfrom
kkmuffme:drop-php4-support-for-do_action-first-arg-array-object-type

Conversation

@kkmuffme
Copy link
Copy Markdown

@kkmuffme kkmuffme commented Jan 4, 2024

Drop PHP 4 support for do_action with 1 array argument where the array contains only 1 element, in favor of better support for PHP 7+ native types

Trac ticket: https://core.trac.wordpress.org/ticket/60190

@kkmuffme kkmuffme force-pushed the drop-php4-support-for-do_action-first-arg-array-object-type branch from b57f606 to d7c7c28 Compare January 4, 2024 01:42
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 4, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Copy Markdown
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

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

Can you provide some new unit tests that demonstrate the benefit of this change? What can be done after this change that can't be done currently?

@kkmuffme kkmuffme force-pushed the drop-php4-support-for-do_action-first-arg-array-object-type branch from d7c7c28 to a8e2d9e Compare March 27, 2024 19:41
@github-actions
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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props kkmuffme, johnbillion.

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

@kkmuffme kkmuffme force-pushed the drop-php4-support-for-do_action-first-arg-array-object-type branch 3 times, most recently from 6da0392 to f9bff26 Compare March 27, 2024 20:36
@kkmuffme kkmuffme force-pushed the drop-php4-support-for-do_action-first-arg-array-object-type branch from f9bff26 to 25ed69e Compare March 27, 2024 20:40
@kkmuffme
Copy link
Copy Markdown
Author

Yes, I added a test now (which would result in a fatal error without this PR on standard WP 6.5)

@kkmuffme kkmuffme requested a review from johnbillion March 27, 2024 20:44
}

if ( empty( $arg ) ) {
if ( array() === $arg ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably missing something but this change doesn't seem to be part of the trac ticket?

This changes the behavior for false, null, 0, etc. (all things considered "empty" in PHP). After this patch $arg will not be an empty string in these cases, right? Thinking this is a potentially big back-compat break, and also not part of the proposed fix as in the trac ticket.

If this is intentional please open a new ticket with reasoning why this is needed and tests to confirm the back-compat issues it may introduce.

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.

$arg is a variadic parameter which means it'll only ever be an array. This change could have been made as part of r46322.

@azaozz azaozz self-requested a review May 23, 2025 16:46
Copy link
Copy Markdown
Contributor

@azaozz azaozz left a comment

Choose a reason for hiding this comment

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

@johnbillion johnbillion closed this Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants