Call ..ArgumentPluginBase->getContextDefinition() on null causes WSOD

Created on 16 January 2022, almost 3 years ago
Updated 25 October 2023, about 1 year ago

Problem/Motivation

Import a view with an invalid argument. Get "Website encountered an error" on every page inc. admin pages.

Error: Call to a member function getContextDefinition() on null in Drupal\views\Plugin\views\argument\ArgumentPluginBase->getContextDefinition() (line 1355 of ../core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php)

Steps to reproduce

I have not positively identified which view has an null argument, but suspect it is a View left over from long-uninstalled module "similar", where the contextual filter looks for table "similar_entries", which does not exist.

Proposed resolution

It may be possible to check a views argument is valid before attempting to report it. For me it is a critical core bug, and one I have battled with before, that a faulty view in the database can crash every page on the site. I am nervous of opening a core ticket, especially for a Drupal problem which is probably pretty well known.

Remaining tasks

1. Consider opening a core ticket covering broken contextual filters, and any other views errors, which can crash every page on a site.

2. Consider validating contextual arguments before attempting to import the view with this module. Or more generally, check that all the tables and columns which a view will require already exist on the target dabase.

User interface changes

None.

API changes

Data model changes

šŸ› Bug report
Status

Closed: works as designed

Version

1.2

Component

Code

Created by

šŸ‡¬šŸ‡§United Kingdom John_B London (UK), Worthing (UK), Innsbruck (Tirol)

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • šŸ‡©šŸ‡°Denmark ressa Copenhagen

    I was also seeing this error when running the migration via the browser. The migration stalls at 56% with these lines:

    Source ID tracker: VIEW: tracker DISPLAY: default - The 'uid_touch' argument Plugin is missing and will be listed as broken.
    Source ID tracker: VIEW: tracker DISPLAY: default - The field timestamp does not exist and has been removed from the fields configuration.
    ā€¦

    If I open a page from the web site, I get this error:

    The website encountered an unexpected error. Please try again later.

    Error: Call to a member function getContextDefinition() on null in Drupal\views\Plugin\views\argument\ArgumentPluginBase->getContextDefinition() (line 1410 of core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php).

    If I hit F5 to refresh, the migration continues and completes.

    I don't need the Tracker view, and can disable the Tracker view in Drupal 7, but cannot delete it ... I looked in the export source for the View, and saw this:

    [...]
    /* Contextual filter: Content: User posted or commented */
    $handler->display->display_options['arguments']['uid_touch']['id'] = 'uid_touch';
    $handler->display->display_options['arguments']['uid_touch']['table'] = 'node';
    $handler->display->display_options['arguments']['uid_touch']['field'] = 'uid_touch';
    $handler->display->display_options['arguments']['uid_touch']['exception']['title_enable'] = TRUE;
    $handler->display->display_options['arguments']['uid_touch']['title_enable'] = TRUE;
    $handler->display->display_options['arguments']['uid_touch']['title'] = 'Recent posts for %1';
    $handler->display->display_options['arguments']['uid_touch']['default_argument_type'] = 'fixed';
    $handler->display->display_options['arguments']['uid_touch']['summary']['format'] = 'default_summary';
    $handler->display->display_options['arguments']['uid_touch']['specify_validation'] = TRUE;
    [...]
    

    After deleting the Contextual filters "User posted or commented" and saving the View, the Migration no longer hangs at 56%. I am not sure there's anything to do about it, but maybe this can help someone else?

    And by the way, Views are getting imported and work well, so thanks for working on the module!

  • šŸ‡®šŸ‡³India hemuvyas97

    We also faced this issue while trying to migrate views from D7 to D10 site. The below patch helped me in moving forward with the migration.

Production build 0.71.5 2024