Fixes default global options array merging.#7538
Merged
dereksmart merged 2 commits intomasterfrom Jul 31, 2017
Merged
Conversation
A change introduced in #6355 started merging the regular options array with the global options. This has been largely unnoticed, but sometimes resulted in weird errors like this: ``` PHP Catchable fatal error: Argument 2 passed to Share_Twitter::__construct() must be of the type array, null given, called in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-service.php on line 227 and defined in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-sources.php on line 562 PHP Warning: array_merge(): Argument #1 is not an array in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-service.php on line 227 PHP Notice: Undefined index: global in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-service.php on line 196 ```
thingalon
approved these changes
Jul 27, 2017
Member
thingalon
left a comment
There was a problem hiding this comment.
Oops! Fix looks good to me.
eliorivero
reviewed
Jul 27, 2017
| $options = array_merge( | ||
| is_array( $options ) ? $options : array(), | ||
| array( 'global' => $this->get_global_options() ) | ||
| ); |
Contributor
There was a problem hiding this comment.
We shouldn't do an array_merge unnecessarily (with an empty array) since it's expensive. Can we do this?
$options = is_array( $options )
? array_merge( $options, array( 'global' => $this->get_global_options() ) )
: array( 'global' => $this->get_global_options() );Props @eliorivero for the tip.
Contributor
Author
|
Thanks Elio! Fixed! |
eliorivero
pushed a commit
that referenced
this pull request
Jul 31, 2017
* Fixes default global options array merging. A change introduced in #6355 started merging the regular options array with the global options. This has been largely unnoticed, but sometimes resulted in weird errors like this: ``` PHP Catchable fatal error: Argument 2 passed to Share_Twitter::__construct() must be of the type array, null given, called in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-service.php on line 227 and defined in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-sources.php on line 562 PHP Warning: array_merge(): Argument #1 is not an array in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-service.php on line 227 PHP Notice: Undefined index: global in /home/asotestjetpack/main/wp-content/plugins/jetpack-dev/modules/sharedaddy/sharing-service.php on line 196 ``` * Improved array merge logic. Props @eliorivero for the tip.
Contributor
|
cherry picked to 5.2 in ccf4950 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A change introduced in #6355 started merging the regular options array with the global options. This has been largely unnoticed, but sometimes resulted in weird errors like this:
Testing instructions: