When using the Autocomplete widget, for some types the following error is thrown when searching for items: Call to undefined method Drupal\Core\TypedData\DataDefinition::getPropertyDefinitions()

The origin of this error leads back to the the getSpecifiedProperties method, in the XeroItemBase class. Here the method getProperties on the parent class is called. In this method, then the getPropertyDefinitions method is called on Drupal\Core\TypedData\DataDefinition.

For some xero data definitions, the getpropertyDefinition method is not available. I don't know why exactly.
A quick way to resolve this is a method_exists upon $this->definiton, to check in the getSpecifiedProperties method.

   if (method_exists($this->definition, 'getPropertyDefinitions')) {
      $properties = $this->getProperties(FALSE);
    } else {
      $properties = [];
    }

Maybe there is a better way, but this resolves the issue for me.

UPDATE
The cause for this issue is a faulty dataDefintion for the properties PurchaseDetails and SalesDetaills in the propertyDefintions function of Drupal\xero\TypedData\Definition\ItemDefinition class.

CommentFileSizeAuthor
#6 Screenshot 2025-08-25 112804.png75.83 KBkensae

Issue fork xero-3539326

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

kensae created an issue. See original summary.

kensae’s picture

Status: Active » Needs review
mradcliffe’s picture

getPropertyDefinition comes from \Drupal\Core\TypedData\ComplexDataDefinitionInterface and \Drupal\Core\TypedData\ComplexDataDefinitionBase which implements that method.

As far as I remember, all xero data type plugins should use a complex data definition, but I think that Drupal's Typed Data Manager will technically let a data type be instantiated with a different definition. My guess is that something happened during denormalization that caused the data type to be instantiated incorrectly.

mradcliffe’s picture

Status: Needs review » Postponed (maintainer needs more info)
kensae’s picture

StatusFileSize
new75.83 KB

In my case, this error is happening when trying to add a Xero Reference with the xero autocomplete widget to a Xero Item. It fails when trying to getProperties on the xero Detail Datatype.

Screenshot of debugging XeroItemBase

kensae’s picture

It seems to be an issue in \Drupal\xero\TypedData\Definition\ItemDefiniton, where the class DataDefinition for

$info['PurchaseDetails'] = DataDefinition::create('xero_detail')->setLabel('Purchase Details');
$info['SalesDetails'] = DataDefinition::create('xero_detail')->setLabel('Sales Details');

should be:

$info['PurchaseDetails'] = DetailDefinition::create('xero_detail')->setLabel('Purchase Details');
$info['SalesDetails'] = DetailDefinition::create('xero_detail')->setLabel('Sales Details');
kensae’s picture

I've updated the MR

kensae’s picture

Title: Call to undefined method Drupal\Core\TypedData\DataDefinition::getPropertyDefinitions() » Call to undefined method Drupal\Core\TypedData\DataDefinition::getPropertyDefinitions() upon creating ItemDefinition
kensae’s picture

Issue summary: View changes
kensae’s picture

Status: Postponed (maintainer needs more info) » Needs review
mradcliffe’s picture

Thank you for finding the root cause. This looks good to me. I added a test to go through non-list properties that start with "xero" and assert the definition interface.

  • mradcliffe committed a6e9b1f8 on 3.1.x authored by kensae
    Issue #3539326 by kensae, mradcliffe: Call to undefined method Drupal\...
mradcliffe’s picture

Status: Needs review » Fixed

Merged.

Status: Fixed » Closed (fixed)

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