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

[Bug]: A mapped WordPress hook that passes null as the first argument will throw an exception. #158

Closed
2 tasks done
calvinalkan opened this issue Oct 20, 2022 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers released

Comments

@calvinalkan
Copy link
Member

Thanks for taking the time to fill out this bug report!"

  • I have searched the issue tracker for similar issues
  • I have verified that the issue is present when using the most recent version of the affected package(s)

Which @snicco/* package(s) are the source of the bug?

better-wp-hooks

Is this a regression?

No

Composer dependencies

//

Current behaviour

A mapped WordPress hook that passes null as the first argument will throw an exception.

Expected behaviour

Null should be allowed as a first mapped argument.

How to reproduce

 $event_mapper->map('some_hook', 'SomeClass::class');
 
 do_action('some_hook', null, 'foo', 'bar');

Possible solution

 if (! isset($args_from_wordpress_hooks[0])) {
throw new RuntimeException(
                    sprintf('Event mapper received invalid arguments from WP for mapped hook [%s].', $event_class)
 );
}

We need to use array_key_exists instead of isset in EventMapper::dispatchMappedFilter

Relevant log output

No response

Additional Context

No response

@calvinalkan calvinalkan added bug Something isn't working good first issue Good for newcomers labels Oct 20, 2022
calvinalkan added a commit to calvinalkan/snicco that referenced this issue Nov 13, 2022
calvinalkan added a commit to calvinalkan/snicco that referenced this issue Nov 13, 2022
@snicco-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 1.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers released
Projects
None yet
Development

No branches or pull requests

2 participants