From 4e92930134558af6fdac838970e376389d18552b Mon Sep 17 00:00:00 2001 From: Corey McKrill <916023+coreymckrill@users.noreply.github.com> Date: Mon, 30 Dec 2024 12:11:06 -0800 Subject: [PATCH] Terms: Update description generator for new Faker behavior With the new version of the Faker library introduced in #147, the behavior of the `realTextBetween` seems to have changed, making it more strict in its interpretation of the input parameters. This change avoids fatal errors by ensuring that there is always a range of 40 between the specified minimum number of characters and the maximum, so that the generator can always build a string with a length that falls somewhere within the range. --- includes/Generator/Term.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/Generator/Term.php b/includes/Generator/Term.php index 43b2791..969c606 100644 --- a/includes/Generator/Term.php +++ b/includes/Generator/Term.php @@ -57,8 +57,10 @@ public static function generate( $save = true, string $taxonomy = 'product_cat', $term_name = strtolower( $term_name ); } + $description_size = wp_rand( 20, 260 ); + $term_args = array( - 'description' => self::$faker->realTextBetween( 20, wp_rand( 20, 300 ), 4 ), + 'description' => self::$faker->realTextBetween( $description_size, $description_size + 40, 4 ), ); if ( 0 !== $parent ) { $term_args['parent'] = $parent;