In order for JSON API to work correctly, the UUID field needs to be added to the votingapi_result table. This issue is essentially a re-roll of the work done by sylus in https://www.drupal.org/project/votingapi/issues/2872435#comment-12131648. It was removed from that issue because it wasn't directly related to it.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | votingapi-uuid-2965603-8.patch | 5.64 KB | goz |
| #6 | rerolled-2965603-6.patch | 4.85 KB | Vidushi Mehta |
| #3 | votingapi-uuid-2965603-3-D8.patch | 4.81 KB | jeffdavidgordon |
| #2 | votingapi-uuid-2965603-2-D8.patch | 4.87 KB | jeffdavidgordon |
Issue fork votingapi-2965603
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:
- 2965603-vote-result-uuid
changes, plain diff MR !53
- 2965603-add-support-for
changes, plain diff MR !29
Comments
Comment #2
jeffdavidgordon commentedHere is the first patch to address this issue.
Comment #3
jeffdavidgordon commentedRe-rolling against alpha7.
Comment #4
pifagorComment #5
pifagorPatch Failed to Apply
Comment #6
Vidushi Mehta commentedRerolled again.
Comment #7
tr commentedPatch no longer applies and needs to be rerolled.
Comment #9
goz commentedI need this to make vote_result entities available with jsonapi.
Here is a patch update for last 8.3.x and Drupal 10.
UUID is a requirement to make entities available on JSONAPI. An issue on core deal with a better way to detect an entity has missing UUID #3090253: Detect when UUID is missing and provide better exception/error message when constructing a JSON:API payload but UUID will still be required.
Comment #11
tr commentedThis patch has some problems. For example:
This is not right because the parent ContentEntityBase creates the base field for uuid as long as the entity key is set. That code should not be duplicated here. Also see #3153550: Vote entity unnecessarily re-implements features provided by base class for similar problems with the Vote entity.
Both Vote and VoteResult were written early in D8 before a lot of functionality was moved into ContentEntityBase. So now they both need some major work. And it's important to do that work in a way that won't break existing sites. Because of that, this change should be done in the 4.0.x branch only and have update tests so that we can ensure the entity structure isn't being broken for people upgrading from 8.x-3.x.
Comment #12
goz commentedI agree. Entity should not duplicate base fields but extends and use ContentEntityBase.
However, while #3153550: Vote entity unnecessarily re-implements features provided by base class is not fixed, if someone needs uuid support, the current patch and issue add it. We cannot do better in this issue without big changes in the module
Comment #13
tr commentedComment #16
tr commentedI created a MR for the 4.0.x branch.
This will not be put into the 8.x-3.x branch.
Note that the tests fail (in both the new MR and the old MR) because the new uuid field is not being initialized. This would not happen if VoteResult simply inherited the uuid field from ContentEntityBase.
Like I said, instead of defining our own new base field, we should just add the uuid entity key and call
parent::baseFieldDefinitions();so that ContentEntityBase will define and handle the uuid field.This fix is needed before we can release 4.0.0.