Fix TypeError: Unsupported operand types: int + string#144
Merged
Conversation
bordoni
approved these changes
Jan 30, 2021
bordoni
added a commit
that referenced
this pull request
Feb 25, 2021
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.
I was running PHP 8.0 when I encountered the following error:
The error can be replicated by adding any sort of user and running PHP 8.
[28-Jan-2021 16:08:37 UTC] PHP Fatal error: Uncaught TypeError: Unsupported operand types: int + string in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/src/FakerPress/Provider/WP_User.php:19 Stack trace: #0 [internal function]: FakerPress\Provider\WP_User->user_pass() #1 /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/vendor/fzaninotto/faker/src/Faker/Generator.php(228): call_user_func_array(Array, Array) #2 /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/vendor/fzaninotto/faker/src/Faker/Generator.php(285): Faker\Generator->format('user_pass', Array) #3 [internal function]: Faker\Generator->__call('user_pass', Array) #4 /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/src/FakerPress/Module/Base.php(214): call_user_func_array(Array, Array) #5 /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/src/FakerPress/Module/Base.php(191): FakerPress\Module\Base->apply(Object(stdClass)) #6 /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/src/FakerPress/Module/User.php(164): FakerPress\Module\Base->generate() #7 /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/src/FakerPress/Ajax.php(76): FakerPress\Module\User->parse_request(2, Array) #8 /Applications/MAMP/htdocs/wordpress/wp-includes/class-wp-hook.php(287): FakerPress\Ajax::module_generate('') #9 /Applications/MAMP/htdocs/wordpress/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters('', Array) #10 /Applications/MAMP/htdocs/wordpress/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #11 /Applications/MAMP/htdocs/wordpress/wp-admin/admin-ajax.php(184): do_action('wp_ajax_fakerpr...') #12 {main} thrown in /Applications/MAMP/htdocs/wordpress/wp-content/plugins/fakerpress/src/FakerPress/Provider/WP_User.php on line 19The $pass variable's value will now be a result of the wp_generate_password() function, so long as the function exists. If the function does not exist, then the $pass variable's value will hold the random number and random letter created by the generator. However, the random number and random letter will be concatenated instead of being added together, due to type errors being raised in newer versions of PHP.