Problem/Motivation

When visiting certain views that are created dynamically or programmatically (not stored as configuration entities), the views_access_conditions module throws a fatal error in version 2.1.x:

Error: Call to a member function getThirdPartySettings() on null in Drupal\views_access_conditions\ViewsAlters->preBuildAlter() (line 189 of modules/contrib/views_access_conditions/src/ViewsAlters.php).

This occurs because the preBuildAlter() method attempts to load the view configuration entity without checking if it exists. When EntityStorageInterface::load() returns NULL (because the view doesn't exist as a stored configuration entity), the code proceeds to call getThirdPartySettings() on NULL, causing the fatal error.

Steps to reproduce

1. Install drupal/views_access_conditions version 2.1.x
2. Install a module that creates programmatic/dynamic views (e.g., drupal/trash)
3. Navigate to a programmatically-created view (e.g., /admin/content/trash)
4. Observe the fatal error

Proposed resolution

Add a null check after attempting to load the view configuration entity. If the view configuration doesn't exist, return early from the method.

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

leoenriquezp created an issue. See original summary.

leoenriquezp’s picture

I just created a merge request and it's ready for review

leoenriquezp’s picture

Status: Active » Needs review
owenbush’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me.

  • leoenriquezp committed 42bd50a4 on 2.1.x
    Issue #3572056: Fix null view config check in preBuildAlter
owenbush’s picture

Status: Reviewed & tested by the community » Fixed

Merged. Thank you.

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.