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

Missing parameter on apply_filters( 'pre_as_enqueue_async_action') #1084

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

crstauf
Copy link
Contributor

@crstauf crstauf commented Aug 8, 2024

Makes it possible for pre_as_enqueue_async_action callbacks to see if the action about to be created is considered unique.

Fixes #1082.

Testing instructions

Add the following to a mu-plugin file, such as wp-content/mu-plugins/test-pr-1084.php:

<?php

add_filter( 'pre_as_enqueue_async_action', function ( $null, $hook, $args, $group, $priority, $unique ) {
	var_dump( $null, $hook, $args, $group, $priority, $unique );
}, 10, 6 );

Now create a new async action via WP CLI:

wp eval "as_enqueue_async_action( 'foo', [ 'bar' => 'baz' ], 'foobar', true, 100 );"

You should see output similar to the following (whitespace added for readability):

./wp-content/mu-plugins/test-pr-1084.php.php:4:
NULL

./wp-content/mu-plugins/test-pr-1084.php.php:4:
string(3) "foo"

./wp-content/mu-plugins/test-pr-1084.php.php:4:
array(1) {
  'bar' =>
  string(3) "baz"
}

./wp-content/mu-plugins/test-pr-1084.php.php:4:
string(6) "foobar"

./wp-content/mu-plugins/test-pr-1084.php.php:4:
int(100)

./wp-content/mu-plugins/test-pr-1084.php.php:4:
bool(true)

In particular, we expect to see (bool) true for that final entry.

Changelog

Fix - Allows pre_as_enqueue_async_action callbacks to see if the action about to be scheduled should be unique.

@crstauf
Copy link
Contributor Author

crstauf commented Aug 10, 2024

@barryhughes All the failed checks are with Composer. Can you please fix and/or re-run?

@barryhughes barryhughes self-requested a review August 12, 2024 17:44
@barryhughes
Copy link
Member

Re-running again. Not sure why we're having such a spate of fails, but at least those I sampled are clearly unrelated to the change at hand:

Error: file_put_contents(/home/runner/work/action-scheduler/action-scheduler/vendor/bin/phpunit): failed to open stream: No such file or directory

@crstauf
Copy link
Contributor Author

crstauf commented Aug 12, 2024

Re-running again. Not sure why we're having such a spate of fails, but at least those I sampled are clearly unrelated to the change at hand

Thanks, @barryhughes.

Copy link
Member

@barryhughes barryhughes left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM!

  • Added testing instructions and verified the new behavior.
  • No back-compat concerns, since we don't consume this filter ourselves (we've previously had cases where third party code independently triggers the same hook, with the original number of parameters, which can potentially lead to problems).
  • CI test fails are sporadic and pretty clearly unrelated.

@barryhughes barryhughes merged commit 7335514 into woocommerce:trunk Aug 12, 2024
42 of 46 checks passed
@crstauf crstauf deleted the fix/1082 branch August 12, 2024 20:52
@barryhughes barryhughes added this to the 3.8.2 milestone Aug 12, 2024
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.

Missing parameter on apply_filters( 'pre_as_enqueue_async_action')
2 participants