Error with mb_strlen in CommerceAutoSkuGeneratorBase

Created on 15 November 2023, about 1 year ago

I get this error:

Message ArgumentCountError: mb_strlen() expects at most 2 arguments, 3 given in mb_strlen() (line 61 of .../public_html/web/modules/contrib/commerce_autosku/src/Plugin/CommerceAutoSkuGenerator/CommerceAutoSkuGeneratorBase.php)

This code:

  protected function makeUnique(ProductVariationInterface $entity, $sku) {
    // Strip tags.
    $generated_sku = preg_replace('/[\t\n\r\0\x0B]/', '', strip_tags($sku));
    $output = $generated_sku;
    $i = 0;
    while (!$this->isUnique($entity, $output)) {
      $counter_length = mb_strlen($i) + 1;
      $un_prefixed_max_length = 255 - $counter_length;
      $sku = mb_strlen($generated_sku, 0, $un_prefixed_max_length);
      $output = $sku . '_' . $i;
      $i++;
    };
    return $output;
  }
🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇵🇱Poland Patryk Padus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024