Run a drupal-check against current Tablefield 8.x-2.x development release (28 Apr 2019).

------ ---------------------------------------------------
Line src\Element\Tablefield.php
------ ---------------------------------------------------
276 Call to deprecated function drupal_set_message().
311 Call to deprecated function drupal_set_message().
337 Call to deprecated function drupal_set_message().
341 Call to deprecated function drupal_set_message().
------ ---------------------------------------------------

------ -------------------------------------------------------------------------------
Line src\Form\TablefieldConfigForm.php
------ -------------------------------------------------------------------------------
76 Call to deprecated method strlen() of class Drupal\Component\Utility\Unicode.
------ -------------------------------------------------------------------------------

Comments

Eric Heydrich created an issue. See original summary.

eric heydrich’s picture

Status: Active » Needs review
StatusFileSize
new2.42 KB

Changed all errors and rerun drupal-check with no errors.

lolandese’s picture

Status: Needs review » Reviewed & tested by the community

The patch applies cleanly:

martin@martin-XPS-13-9370 /var/www/html/brown.localhost/web/modules/tablefield (8.x-2.x=) $ git apply -v drupal_9_deprecated_code_report-3062227-2.patch
Checking patch src/Element/Tablefield.php...
Hunk #1 succeeded at 274 (offset 1 line).
Hunk #2 succeeded at 309 (offset 1 line).
Hunk #3 succeeded at 345 (offset 11 lines).
Checking patch src/Form/TablefieldConfigForm.php...
Applied patch src/Element/Tablefield.php cleanly.
Applied patch src/Form/TablefieldConfigForm.php cleanly.

Patch solves the errors:

martin@martin-XPS-13-9370 /var/www/html/brown.localhost/web/modules $ drupal-check tablefield
 12/12 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 [OK] No errors                                                                                                         

Manual test to trigger the changed code to check correct functionality BEFORE and AFTER the patch:

  • At node/1/edit CHANGE NUMBER OF ROWS/COLUMNS should result in status (green) message "Table structure rebuilt.". BEFORE: OK, AFTER: OK
  • At node/1/edit IMPORT FROM CSV when uploading a non-CSV file should result in error (red) message "Only files with the following extensions are allowed: csv.". BEFORE: OK, AFTER: OK
  • At node/1/edit IMPORT FROM CSV when uploading a CSV file should result in status (green) message "Successfully imported some-file.csv: csv.". BEFORE: OK, AFTER: OK

At admin/config/content/tablefield "CSV separator" that must be one character only cannot be tested as on the form '#maxlength' => 1,. We believe that validation on it can be removed. As it was present also before, it is no blocker for committing the patch though.

lolandese’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: +#2928994: Remove \Drupal\Core\Messenger\LegacyMessenger

Related Change record:
drupal_get_message() and drupal_set_message() replaced by Messenger service | Drupal.org

API:
MessengerInterface | MessengerInterface.php | Drupal 8.7.x | Drupal API

Looking at 8 - Best practice: $this->t() versus t() - Drupal Answers it seems we should rather use $this->t(). As is was already there, this is also no blocker. Opening new issues for the findings.

lolandese’s picture

Added some follow-up issues.

Thanks for your contribution,

lolandese’s picture

Seems that not all PHP version support this yet out-of-the-box.

Error: Call to undefined method Drupal\Component\Utility\Unicode::mb_strlen() in Drupal\tablefield\Form\TablefieldConfigForm->validateForm() (line 76 of /var/www/html/brown.localhost/web/modules/tablefield/src/Form/TablefieldConfigForm.php)

eric heydrich’s picture

Can you please provide some more information on PHP Version and Drupal Version tested. Mbstring has to be activated or there is a polyfill for mbstring in Symfony since D8.6. More info here: https://www.drupal.org/node/2850048. Maybe older versions than drupal 8.6 don't have the polyfill.

lolandese’s picture

Drupal Version
8.7.3

PHP
Version
7.2.19-1+ubuntu18.04.1+deb.sury.org+1

But it seems normal that the extension might be needed to be added:
php - Fatal error: Call to undefined function mb_strlen() - Stack Overflow

lolandese’s picture

The #7 error will not occur anymore as the validation function has been removed in #3064974: Unnecessary validation function. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

eric heydrich’s picture

Assigned: eric heydrich » Unassigned