Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json_form_widget throws deprecation messages in PHP 8.2 #4129

Merged
merged 13 commits into from
Feb 22, 2024

Conversation

paul-m
Copy link
Contributor

@paul-m paul-m commented Feb 16, 2024

Now that PHP 8.2 is our default testing environment, 10_workflow_transitions.spec.js fails because json_form_widget adds dynamic properties to classes. It emits a message like this:

Deprecated function: Creation of dynamic property Drupal\Core\Form\FormState::$has_json_form_widget is deprecated in json_form_widget_field_widget_complete_form_alter() (line 79 of /var/www/html/dkan/modules/json_form_widget/json_form_widget.module).

This PR:

  • Modifies json_form_widget_field_widget_complete_form_alter() and json_form_widget_form_alter() to use FormStateInterface::get() and set() to store information rather than the now-deprecated technique of setting a new dynamic property on the form state object.
  • Converts 07_admin_dataset_json_form.spec.js and 11_admin_dataset_file_upload.spec.js to be BrowserTestBase tests. This way the deprecation shows up in PHP scope. We can't count on Cypress to fail for a deprecation, but they'll stand out in PHPUnit-land.
  • Improves other tests in json_form_widget with group annotation.
  • Limits PHPUnit test coverage so that we're not showing coverage for tests.

To manually test:

  • Create a local development environment using PHP 8.2 using this branch.
  • git checkout 2.x modules/json_form_widget/json_form_widget.module
  • ddev dkan-phpunit --filter AdminDatasetJsonFormTest
  • This test will error due to the deprecation.
  • git restore --staged modules/json_form_widget/json_form_widget.module
  • git restore modules/json_form_widget/json_form_widget.module
  • ddev dkan-phpunit --filter AdminDatasetJsonFormTest
  • No deprecation error.

@paul-m paul-m marked this pull request as ready for review February 20, 2024 23:17
@dafeder dafeder merged commit a9cf4dc into 2.x Feb 22, 2024
10 checks passed
@dafeder dafeder deleted the 18869-json_form_widget-deprecation branch February 22, 2024 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants