Problem/Motivation

Since Drupal 9.3.x, core has deprecated use of arbitrary callbacks in favor of trusted callbacks for #date_time_callbacks and #date_date_callbacks, see change record #date_time_callbacks and #date_date_callbacks must implement TrustedCallbackInterface. Legacy functionality will be removed in Drupal 10.

Proposed resolution

Remaining tasks

- Update Webform implementations
- This may affect custom webform implementations if they have defined their own?

API changes

tbd

-

Marking as major since its inevitable.

CommentFileSizeAuthor
#4 webform.webform.3221398.yml4.82 KBpaulocs
#2 3221398-2.patch11.29 KBjrockowitz

Issue fork webform-3221398

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dpi created an issue. See original summary.

jrockowitz’s picture

Version: 6.x-dev » 8.x-5.x-dev
Status: Active » Needs review
StatusFileSize
new11.29 KB

I would like to create a backward-compatible patch that would be supported via 8.x-5.x

paulocs’s picture

The patch #2 looks good to me.
I made a code review. For me, documentation and logic look good.
I also tested it on three different Drupal environments:
Drupal 8.9.14
Drupal 9.2.1
Drupal 9.3.x

On all Drupal environments it works as expected and all three callback functions are properly called.
I'm re-adding the tests to see if tests pass on 9.3.x branch and than I move to RTBC.
I'm also attaching a webform config file with the webform that I tested the issue.

paulocs’s picture

StatusFileSize
new4.82 KB
paulocs’s picture

I don't know why the tests are passing locally but failing with test bots.

paulocs’s picture

jrockowitz’s picture

Title: Update use of date_time_callbacks and date_date_callbacks in Webform » [Drupal 9.x] Update use of date_time_callbacks and date_date_callbacks in Webform
alexpott’s picture

The tests might be broken because Drupal 9.3 is broken - see #3250335: #date_date_callbacks is broken in Drupal 9.3

alexpott’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/WebformElement/DateList.php
@@ -57,7 +58,9 @@ class DateList extends DateBase {
+      $element['#date_date_callbacks'][] = (floatval(\Drupal::VERSION) >= 9.3)
+        ? '::dateListDateDateCallback'
+        : '_webform_datelist_date_date_callback';

+++ b/src/Plugin/WebformElement/DateTime.php
@@ -108,7 +108,9 @@ class DateTime extends DateBase {
-    $element['#date_date_callbacks'][] = '_webform_datetime_date';
+    $element['#date_date_callbacks'][] = (floatval(\Drupal::VERSION) >= 9.3)
+        ? '::dateTimeDateCallback'
+        : '_webform_datetime_date';

@@ -118,7 +120,9 @@ class DateTime extends DateBase {
-    $element['#date_time_callbacks'][] = '_webform_datetime_time';
+    $element['#date_time_callbacks'][] = (floatval(\Drupal::VERSION) >= 9.3)
+        ? '::dateTimeTimeCallback'
+        : '_webform_datetime_time';

Is this version check necessary necessary? I think previous versions of Drupal will work with the new array callback. See https://3v4l.org/Suleg

Also given changes on 6.x is not possible to make a patch that applies to both 6.x and 8.x-5.x

alexpott’s picture

Version: 8.x-5.x-dev » 6.x-dev

Given a single patch accross 6.x and 8.x-5.x is not possible because the callback have changed in 6.x recently going to change this to target 6.x

alexpott’s picture

Status: Needs work » Needs review

So the 6.x branch I just pushed should pass on 9.2.x and will fail on 9.3.x until #3250335: #date_date_callbacks is broken in Drupal 9.3 is fixed. Fingers crossed.

alexpott’s picture

Oh well #9 is wrong because of the function_exists() check in Drupal 9.2 and lower... so the floatval trick is the way to go.

alexpott’s picture

Now that webform tests are passing on 9.3.x I think this one ready too.

jrockowitz’s picture

Status: Needs review » Fixed

@alexpott Thank you for supporting backward compatibility.

  • jrockowitz committed 8050ecd on 6.x authored by alexpott
    Issue #3221398 by alexpott, jrockowitz, paulocs: [Drupal 9.x] Update use...
  • jrockowitz committed 8050ecd on 6.x authored by alexpott
    Issue #3221398 by alexpott, jrockowitz, paulocs: [Drupal 9.x] Update use...

  • jrockowitz committed 8050ecd on 6.1.x authored by alexpott
    Issue #3221398 by alexpott, jrockowitz, paulocs: [Drupal 9.x] Update use...
  • jrockowitz committed 8050ecd on 6.1.x authored by alexpott
    Issue #3221398 by alexpott, jrockowitz, paulocs: [Drupal 9.x] Update use...

Status: Fixed » Closed (fixed)

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