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

error when creating users with custom meta #182

Open
izuio opened this issue Jan 25, 2025 · 0 comments
Open

error when creating users with custom meta #182

izuio opened this issue Jan 25, 2025 · 0 comments

Comments

@izuio
Copy link

izuio commented Jan 25, 2025

this code WP_Meta.php(27):

$qty = (int) ( is_array( $qty ) && count( $_qty ) > 1 ? call_user_func_array( [ $this->generator, 'numberBetween' ], $qty ) : reset( $_qty ) );

changed to
$qty_args = array_values( (array) $qty ); $qty = (int) ( is_array( $qty_args ) && count( $qty_args ) > 1 ? call_user_func_array( [ $this->generator, 'numberBetween' ], $qty_args ) : reset( $qty_args ) );

works so far on a test site, problem exists when trying to write to a custom field (user) occurs using both jetengine and simple php.

recreation

  • Add User meta with php or plugin like jetengine
  • then generate users with Meta Field Rules of Type Text, Name Fake, config sentences (1 or more)

explanation
array_values() re‐indexes the array to [0 => value_for_min, 1 => value_for_max], removing the string keys.
Now call_user_func_array([...], $qty_args) sees a plain numeric array (e.g., [1, 5]) and calls numberBetween($min = 1, $max = 5) positionally, which works with the standard Faker signature.

debug log
[24-Jan-2025 07:27:06 UTC] PHP Fatal error: Uncaught Error: Unknown named parameter $min in /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/src/FakerPress/Provider/WP_Meta.php:27
Stack trace:
#0 /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/src/FakerPress/Provider/WP_Meta.php(27): call_user_func_array(Array, Array)
#1 /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/src/FakerPress/Provider/WP_Meta.php(105): FakerPress\Provider\WP_Meta->meta_parse_qty(Array)
#2 [internal function]: FakerPress\Provider\WP_Meta->meta_type_text('sentences', Array, '\n', 100)
#3 /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/vendor-prefixed/fakerphp/faker/src/Faker/Generator.php(713): call_user_func_array(Array, Array)
#4 /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/vendor-prefixed/fakerphp/faker/src/Faker/Generator.php(978): FakerPress\ThirdParty\Faker\Generator->format('meta_type_text', Array)
#5 [internal function]: FakerPress\ThirdParty\Faker\Generator->__call('meta_type_text', Array)
#6 /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/src/FakerPress/Module/Meta.php(145): call_user_func_array(Array, Array)
#7 /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/src/FakerPress/Module/User.php(196): FakerPress\Module\Meta->generate()
#8 /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/src/FakerPress/Ajax.php(83): FakerPress\Module\User->parse_request(4, Array)
#9 /Users/b/Local Sites/carg/app/public/wp-includes/class-wp-hook.php(324): FakerPress\Ajax::module_generate('')
#10 /Users/b/Local Sites/carg/app/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#11 /Users/b/Local Sites/carg/app/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#12 /Users/b/Local Sites/carg/app/public/wp-admin/admin-ajax.php(192): do_action('wp_ajax_fakerpr...')
#13 {main}
thrown in /Users/b/Local Sites/carg/app/public/wp-content/plugins/fakerpress/src/FakerPress/Provider/WP_Meta.php on line 27

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

No branches or pull requests

1 participant