Problem/Motivation

This is a follow-up of #3557142: \Drupal\views\FieldViewsDataProvider::defaultFieldImplementation creates a join for a non-existing table causing deprecations on PHP 8.5 which didn't cover an edge case.

PHP 8.5 deprecation notices are popping up in FieldViewsDataProvider::defaultFieldImplementation() with this (edge case) scenario:

  • The entity type lacks a data table
  • A configurable field is declared as translatable in the field storage
  • At least two bundles are using the field but with different translatability setting: one is declaring it translatable, other non-translatable.

The deprecation notice:

Using null as an array offset is deprecated, use an empty string instead

The "test only" code proves the bug https://git.drupalcode.org/issue/drupal-3582171/-/jobs/9151088

Steps to reproduce

See the new added test.

Proposed resolution

Similar to #3557142: \Drupal\views\FieldViewsDataProvider::defaultFieldImplementation creates a join for a non-existing table causing deprecations on PHP 8.5, check if the data table exists.

Remaining tasks

None.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Issue fork drupal-3582171

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

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Title: Strengthen views data with entity types w/o data tables » [PHP 8.5] Strengthen views data with entity types w/o data tables
Issue summary: View changes
Parent issue: » #3557142: \Drupal\views\FieldViewsDataProvider::defaultFieldImplementation creates a join for a non-existing table causing deprecations on PHP 8.5
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Assigned: claudiu.cristea » Unassigned
Status: Active » Needs review

This is ready for review.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Looks ready for backport to 11.x

claudiu.cristea’s picture

Thank you. I think it needs main, 11.x and 11.3.x

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Made a small suggestion to improve the reliability of the test coverage if things we're assuming change later.

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community

I've added the suggested assertion. Set to RTBC as it was just one line change which was suggested by a core committer.

alexpott’s picture

Version: main » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 88805fc to main and 8aaa353e96b to 11.x and aa038bbc9b1 to 11.3.x. Thanks!

Backported to 11.3.x as a non-disruptive bug fix.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed aa038bbc on 11.3.x
    fix: #3582171 [PHP 8.5] Strengthen views data with entity types w/o data...

  • alexpott committed 8aaa353e on 11.x
    fix: #3582171 [PHP 8.5] Strengthen views data with entity types w/o data...

  • alexpott committed 88805fc7 on main
    fix: #3582171 [PHP 8.5] Strengthen views data with entity types w/o data...

larowlan made their first commit to this issue’s fork.

larowlan’s picture

Status: Fixed » Needs work

This broke 11.3.x, I'm going to try revert it. Opened an MR for the revert https://git.drupalcode.org/project/drupal/-/merge_requests/15430

  • larowlan committed 362ee497 on 11.3.x
    Revert "fix: #3582171 [PHP 8.5] Strengthen views data with entity types...

larowlan’s picture

Reverted from 11.3.x as the revert MR passed and applies cleanly

godotislate’s picture

Quick investigation is that #3347842: Deprecate the trusted data concept in configuration was not backported to 11.3.x, and without the change in ViewsViewsHooks, the views data for entity_test_label entity type is empty.

Explanation for the ViewsViewsHooks change originally is in this commit from the MR in that issue: https://git.drupalcode.org/project/drupal/-/merge_requests/6928/diffs?co...

Not sure what next steps should be. Maybe this issue should just not be backported to 11.3.x? Or is it safe just to bring over that specific ViewViewsHook change?

ETA Note that this was already released in 11.3.6.

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

Created a new 11.3.x MR to re-introduce the fix without the test. Given that fix has gone out in 11.3.6 and is in and tested in 11.x and main I think this approach seems ok. Setting to RTBC for either @larowlan or @godotislate to pick up.

  • catch committed 122c8e16 on 11.3.x
    fix: #3582171 [PHP 8.5] Strengthen views data with entity types w/o data...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.3.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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