Return value must be of type int, none returned

Created on 27 July 2023, over 1 year ago
Updated 30 August 2023, over 1 year ago

Since version 2.3.0 we're getting this error on any form that uses the text_counter widget.

TypeError: Drupal\textfield_counter\Plugin\Field\FieldWidget\StringTextareaWithCounterWidget::getLengthOfSubmittedValue(): Return value must be of type int, none returned in Drupal\textfield_counter\Plugin\Field\FieldWidget\StringTextareaWithCounterWidget::getLengthOfSubmittedValue() (line 426 of /var/www/web/modules/contrib/textfield_counter/src/Plugin/Field/FieldWidget/TextFieldCounterWidgetTrait.php)

🐛 Bug report
Status

Needs work

Version

2.3

Component

Code

Created by

🇮🇪Ireland markconroy

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

Comments & Activities

  • Issue created by @markconroy
  • 🇮🇪Ireland markconroy

    I think the issue is caused because there is no return $value_length; in protected static function getLengthOfSubmittedValue

  • Status changed to Postponed: needs info over 1 year ago
  • 🇺🇸United States edmund.dunn Olympia, WA

    I am unable to replicate this. Could you please provide some more info on your setup?

  • 🇮🇪Ireland markconroy

    It's a very standard set up. We have a field for posting to twitter, and we use this module to let editors know to keep their post to fewer than 280 characters. Editors fill in that field and then the contents of it are posted to our Twitter account.

    When I try to edit any page of this "social post" content type, I get the error mentioned in the OP. If I add return $value_length to the getLengthOfSsubmittedValue, it's working fine. If I downgrade the module to a previous version, it's also working fine.

    I can try upgrade it again, maybe I did something wrong! Will report back.

  • 🇺🇸United States msbtterswrth

    Hey Edmund, I'm able to repro this seemingly only when the node in question has a boolean (checkbox) field on it. We had been using this just fine until I added that boolean field and BAM error.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India aayushi.kachhwaha

    Hi Edmund
    Confirmed the same as msbtterswrth. Reviwed and could not reproduce the issue until the node has a boolean field.

  • Status changed to Needs work over 1 year ago
  • 🇮🇪Ireland markconroy

    In our case, we don't have a boolean field in this content type, but we do have a list field. I'm going to guess that's what is tripping us up here.

Production build 0.71.5 2024