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.
Greetings.
I'm writing a port of userpoints_votingapi module for D7. I have to get an author of deleted entity in order to create a userpoints transaction that will return the points he got or lost (for being voted) to original state. After the entity was deleted I can't get uid of it if only I don't pass it to $votes array in "_votingapi_delete_votes_by_entity" function.
Here I'll post a patch soon.
Comment | File | Size | Author |
---|---|---|---|
#7 | votingapi-adds-entity-uid-2394177-2.patch | 2.08 KB | mvlabat |
Comments
Comment #1
mvlabat CreditAttribution: mvlabat commentedCreated a patch adding entity uid.
Comment #2
mvlabat CreditAttribution: mvlabat commentedAdded db selection of vote and tag fields. They are also needed to calculate userpoints properly.
Comment #3
mvlabat CreditAttribution: mvlabat commentedBump.
Comment #4
torotil CreditAttribution: torotil at more onion commentedIn general entities don't have a uid field. So I think this doesn't make a lot of sense to be implemented in votingapi.
EDIT: maybe passing the entity instead would.
Comment #5
mvlabat CreditAttribution: mvlabat commentedThank you for your answer.
I think, votingapi means that only entities with uid can be voted (nodes and comments), doesn't it? So it would be safe to get that property.
And that makes sence, because the usecase is actually found. Though I can't imagine the usecase where the whole entity should be passed, but let it be.
So if I post the patch that passes the whole entity, will you review it for accepting?
Comment #6
torotil CreditAttribution: torotil at more onion commentedI don't see a point where votingapi requires the voted upon entity to have a user-relation. Do you? I think it should work with any entity - although the most common uses are nodes and comments.
Yes, why not ;) I'm unable to do a lot of patch testing though at the moment.
Comment #7
mvlabat CreditAttribution: mvlabat commentedI'll go though my corrections.)
1. - $id = array($ids[0]);
We don't use an array of ids. The function returns only one entity_id with its vid and bundle, so there is no sense to be it as an array. Also in the functions to delete cache and votes you use "->condition('entity_id', $entity_ids)" which wasn't correct (we should use 'IN' operator then).
2. _votingapi_delete_votes_by_entity($entity_id, $type, $entity = NULL)
It may seem that we have excess $entity_id, but I decieded to retain it in order to save compability with function "_votingapi_cron_delete_orphaned", so passing $entity is still optional. I couldn't get calling
to return any value of testing purposes, so I left it alone.
Hope that's all okay so you'll accept my patch.)
Thank you :)
Comment #8
mvlabat CreditAttribution: mvlabat as a volunteer commentedBump.
Comment #9
mvlabat CreditAttribution: mvlabat as a volunteer commentedPlease, review my last changes and commit them if possible.
My further development of userpoints_votingapi is frozen until this patch is applied.
Comment #10
TR CreditAttribution: TR commented@mvlabat: You assigned this to yourself - are you still planning to work on this?
Patch needs a re-roll - it no longer applies.
Comment #11
TR CreditAttribution: TR commented