Skip to main content

Post upgrading from Drupal 9.5.10 to Drupal 10.1.3, I was seeing the following error when viewing a view page:

TypeError: Cannot assign null to property Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator of type string in Drupal\views\Plugin\views\argument\ArgumentPluginBase->unpackArgumentValue() (line 1310 of core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php).

Finding an insight to this error was on the following Drupal issues page -

Where, line 111 of the ArgumentPluginBase.php file originally was

   * Is argument a default.
  public bool $is_default;

   * The operator used for the query: or|and.
  public string $operator;

   * The title set by argument validation.
  public ?string $validated_title;

The line 'public string $operator;' need to change to

public ?string $operator;

Obviously, this change cannot be directly be applied to core code.  Instead a patch is required for this to be applied.

How do you create a patch?


Creating a patch

Current path to the file: web/core/modules/views/src/Plugin/views/argument/

Orignal filename: ArgumentPluginBase.php

Adjusted filename: ArgumentPluginBase-adjusted.php


Create a Patch

A patch is used to create or override changes in another file.  The command to create a patch is:

diff -u {original filename} {changed filename} > {patchfile}.patch
diff -u web/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php web/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase-adjusted.php > patches/argument-plugin-base-operator.patch


--- web/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php	2023-09-08 01:19:51
+++ web/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase-adjusted.php	2023-09-18 21:52:15
@@ -108,7 +108,7 @@
    * The operator used for the query: or|and.
-  public string $operator;
+  public ?string $operator;
    * The title set by argument validation.



Related articles

Andrew Fletcher31 May 2024
Connecting AWS S3 with Docker for Drupal 10
Recently, I encountered an issue where my local Docker environment refused to connect to AWS S3, although everything worked seamlessly in AWS-managed environments. This challenge was not just a technical hurdle; it was a crucial bottleneck that needed resolution to ensure smooth Drupal deployments...