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

Avoid using func_get_args #1741

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/HttpClient/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function constructRequest($method, $absUrl, $headers, $params, $hasFile)

$opts = [];
if (\is_callable($this->defaultOptions)) { // call defaultOptions callback, set options to return value
$opts = \call_user_func_array($this->defaultOptions, \func_get_args());
$opts = \call_user_func_array($this->defaultOptions, [$method, $absUrl, $headers, $params, $hasFile]);
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a really obscure case where this is breaking. For users on PHP < 7, \call_user_func_array returns the original value of $method (i.e. before we do $method = \strtolower($method) on line 198), but this change will change it to lower case it. Since $this->defaultOptions is a potentially-user-defined callback we can't be 100% certain this won't break somebody, but this would only happen in an instance where somebody was introducing a non-lower-cased verb into our request infrastructure (custom requests?)

I think this case is unlikely but maybe it would be better to postpone this to the major?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

custom requests are only available on the beta SDKs, not the GA ones - so we should be good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately you can initialize StripeClient or ApiRequestor directly and call ->request (happens in the wild). I don't think we ever documented this though, so it's probably fine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough, will close this out and this can go in the next month's major release

if (!\is_array($opts)) {
throw new Exception\UnexpectedValueException('Non-array value returned by defaultOptions CurlClient callback');
}
Expand Down
Loading