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.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | Screenshot 2025-08-25 112804.png | 75.83 KB | kensae |
Issue fork xero-3539326
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
Comment #3
kensae commentedComment #4
mradcliffegetPropertyDefinition 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.
Comment #5
mradcliffeComment #6
kensae commentedIn 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.
Comment #7
kensae commentedIt seems to be an issue in \Drupal\xero\TypedData\Definition\ItemDefiniton, where the class DataDefinition for
should be:
Comment #8
kensae commentedI've updated the MR
Comment #9
kensae commentedComment #10
kensae commentedComment #11
kensae commentedComment #12
mradcliffeThank 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.
Comment #14
mradcliffeMerged.