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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mvlabat’s picture

Status: Active » Needs review
FileSize
1.23 KB

Created a patch adding entity uid.

mvlabat’s picture

FileSize
1.27 KB

Added db selection of vote and tag fields. They are also needed to calculate userpoints properly.

mvlabat’s picture

Bump.

torotil’s picture

In 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.

mvlabat’s picture

Thank 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?

torotil’s picture

I think, votingapi means that only entities with uid can be voted (nodes and comments), doesn't it?

I 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.

So if I post the patch that passes the whole entity, will you review it for accepting?

Yes, why not ;) I'm unable to do a lot of patch testing though at the moment.

mvlabat’s picture

I'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

DrupalQueue::get('VotingAPIOrphaned') 

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 :)

mvlabat’s picture

Bump.

mvlabat’s picture

Please, review my last changes and commit them if possible.
My further development of userpoints_votingapi is frozen until this patch is applied.

TR’s picture

Status: Needs review » Needs work
Issue tags: -userpoints_votingapi, -entity uid

@mvlabat: You assigned this to yourself - are you still planning to work on this?

Patch needs a re-roll - it no longer applies.

TR’s picture

Assigned: mvlabat » Unassigned