syntax error unexpected identifier

Created on 15 October 2023, 9 months ago

I'm having an issue with content that has a Computed Field in it, but it seems to be connected to the Field Permissions module.
It might be connect to https://www.drupal.org/project/field_permissions/issues/3371144 🐛 Invalid context for call to FieldDefinitionInterface->isDisplayConfigurable() Fixed .

The error is caused by a Computed Field being displayed using Views. It first showed like this on a blank page:
UnhandledMatchError: Unhandled match case '...' in Drupal\computed_field\Entity\ComputedField->isDisplayConfigurable() (line 296 of /www/mysite.com/website/web/modules/contrib/computed_field/src/Entity/ComputedField.php).

Line #296 of /www/mysite.com/website/web/modules/contrib/computed_field/src/Entity/ComputedField.php is the 'return match':

  /**
   * {@inheritdoc}
   */
  public function isDisplayConfigurable($context) {
    return match ($context) {
      'view' => TRUE,
      'form' => FALSE,
    };
  }

I set up a backtrace and the error started to show as this:
ParseError: syntax error, unexpected identifier "view" in Composer\Autoload\{closure}() (line 298 of /www/mysite.com/website/web/modules/contrib/computed_field/src/Entity/ComputedField.php)

The results of the backtrace showed where the error was crashing it:

 0 => array:7 [▼
    "file" => "/www/mysite.com/website/web/modules/contrib/field_permissions/field_permissions.module"
    "line" => 36
    "function" => "isDisplayConfigurable"
    "class" => "Drupal\computed_field\Entity\ComputedField"
    "object" => Drupal\computed_field\Entity\ComputedField {#2240 ▼
      #entityTypeId: "computed_field"
      #enforceIsNew: null
      #typedData: null
      #cacheContexts: []
      #cacheTags: []
      #cacheMaxAge: -1
      #_serviceIds: []
      #_entityStorages: []
      #originalId: "node.book_page.computed_buy_amazon"
      #status: true
      #uuid: "794b4003-cd4a-4202-aca5-af1f2588ba57"
      -isUninstalling: false
      #langcode: "en"
      #third_party_settings: []
      #_core: []
      #trustedData: false
      #dependencies: array:2 [▶]
      #isSyncing: false
      #id: "node.book_page.computed_buy_amazon"
      #field_name: "computed_buy_amazon"
      #field_type: null
      #entity_type: "node"
      #bundle: "book_page"
      #label: "Buy Amazon"
      #description: ""
      #settings: []
      #required: false
      #translatable: true
      #default_value: []
      #default_value_callback: ""
      #fieldStorage: null
      #itemDefinition: null
      #constraints: []
      #propertyConstraints: []
      #plugin_id: "buy_amazon_computedbuyamazon"
      #plugin_config: []
      #pluginCollection: Drupal\Core\Plugin\DefaultSingleLazyPluginCollection {#3238 ▼
        #pluginInstances: array:1 [ …1]
        #instanceIds: array:1 [ …1]
        #manager: Drupal\computed_field\ComputedFieldManager {#3243 …16}
        #configuration: []
        #instanceId: "buy_amazon_computedbuyamazon"
        #_serviceIds: []
        #_entityStorages: []
      }
    }
    "type" => "->"
    "args" => array:1 [▼
      0 => "display"
    ]
  ]

You can see at the end that it should say this:

    "args" => array:1 [▼
      0 => "view"
    ]

instead of "display". I don't have any special permission being used for that computed field, and it works perfectly if I remove the Field Permissions module. I thought I'd ask here because the Computed Field is working as it should, and I just can't find where this error could be happening.

I did try applying the changes from Issue 3371144 and still got
TypeError: Drupal\field_permissions\FieldPermissionsService::fieldGetPermissionType(): Argument #1 ($field) must be of type Drupal\field\FieldStorageConfigInterface, Drupal\computed_field\Field\FieldStorageDefinition given, called in /www/mysite.com/website/web/modules/contrib/field_permissions/src/FieldPermissionsService.php on line 163 in Drupal\field_permissions\FieldPermissionsService->fieldGetPermissionType() (line 138 of modules/contrib/field_permissions/src/FieldPermissionsService.php).

💬 Support request
Status

Active

Version

1.2

Component

Code

Created by

🇺🇸United States wxman

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

Comments & Activities

Production build 0.69.0 2024