Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If the destination plugin is url_alias
and we try to use the entity_lookup
plugin for some reason, the following lines in the constructor lead to an error saying something like Entity type 1 does not exist..
$this->destinationEntityType = empty($pluginIdParts[1]) ?: $pluginIdParts[1];
this->destinationBundleKey = !$this->destinationEntityType ?: $this->entityManager->getDefinition($this->destinationEntityType)->getKey('bundle');
The problem is the ternary operator in the first line returns 1
if $pluginIdParts[1] is empty. So, the ternary operator should be like:
$this->destinationEntityType = empty($pluginIdParts[1]) ? NULL : $pluginIdParts[1];
$this->destinationBundleKey = !$this->destinationEntityType ? NULL : $this->entityManager->getDefinition($this->destinationEntityType)->getKey('bundle');
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff.txt | 675 bytes | marvil07 |
#8 | 2896600-8.patch | 3.67 KB | marvil07 |
#6 | 2896600-6-test_only.patch | 2.66 KB | marvil07 |
Comments
Comment #2
jigariusSwitching to 8.x-4.x.
Comment #3
mvcThis patch works for us; I'll let someone else set this to RTBC since I work with jigarius and this should be reviewed by someone at another organization.
Comment #4
heddnGreat find. Bumping back to NW for tests. We're really trying hard to beef up testing on this.
Comment #5
marvil07 CreditAttribution: marvil07 at Isovera for Pegasystems commented+1
The patch at #2 worked as expected. Another case for this is the book destination plugin, which does not have the bundle in the destination name.
Comment #6
marvil07 CreditAttribution: marvil07 at Isovera for Pegasystems commentedI understand the value of tests, but IMHO delaying applying a know fix to a known bug for this long may not be the best strategy for a contributed module.
Core may be different because of the amount of contributions it receives.
Here a test only patch that should fail, and the complete patch.
Also, linking a related ticket for tests on entity_lookup plugin.
Comment #8
marvil07 CreditAttribution: marvil07 at Isovera for Pegasystems commentedA small extra change related to coding standards.
Comment #10
heddnThanks for your contributions, especially the tests.
Changes made on commit: