Problem/Motivation
The #date_date_callbacks expects $element to be passed by reference but the change in #3213572: #date_time_callbacks and #date_date_callbacks bypass the TrustedCallbackInterface protections has broken this.
Steps to reproduce
Run webform tests on Drupal 9.3.x - or anything that uses #date_date_callbacks. Unfortunately core has no real usage only a test usage.
See https://git.drupalcode.org/project/webform/-/blob/6.x/includes/webform.d... for an existing callback function that is broken on 9.3.x.
Proposed resolution
Add an & to StaticTrustedCallbackHelper::callback($callback, [$element, $form_state, $date], $message, TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION);
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3250335-6.patch | 6.08 KB | alexpott |
| #6 | 4-6-interdiff.txt | 4.51 KB | alexpott |
| #4 | 3250335-3.patch | 5.17 KB | alexpott |
| #4 | 3250335-3.test-only.patch | 3 KB | alexpott |
Issue fork drupal-3250335
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
Comment #2
alexpottComment #3
beatrizrodriguesComment #4
alexpottHere's the fix.
Here's an example of an existing callback that is broken by this: https://git.drupalcode.org/project/webform/-/blob/6.x/includes/webform.d...
Comment #5
alexpottI'm not sure if we need the & on the $form_state and $date because they are objects but also arrays are copied so...
Gonna try to work out how to test this.
Comment #6
alexpottNope we don't need &'s for the objects - it's just the arrays that are being copied. Here's tests for that.
Comment #7
beatrizrodriguesComment #8
paulocsComment #10
longwaveI reran the updated test locally without the fix to the Datetime element and it fails as expected. The fix itself is trivial, the updated test looks good to me as well.
Comment #11
paulocsRTBC +1
Before patch is applied i got the error when running webform test
WebformElementDateTimeTestAfter patch is applied, the test passes.
The code looks good as well.
Comment #13
catchCommitted/pushed to 9.4.x and cherry-picked to 9.2.x, thanks!