Hello,
the situation is that I try to import fivestar votes on comments using migrate module.
I wrote fivestar handler and votes are stored fine except anonymous ones which have uid set as current user which performed migration.
It is because of wrong checking of uid by using empty() function.

$uid = empty($uid) ? $user->uid : $uid;

Following the PHP documentation, 0 is considered false by empty() so logged user uid is used for storing vote.

CommentFileSizeAuthor
#1 fivestar-anonymous-uid-1333414-1.patch619 byteszambrey

Comments

zambrey’s picture

Status: Active » Needs review
StatusFileSize
new619 bytes

This patch fixes this issue by using isset() function.

ericduran’s picture

Status: Needs review » Fixed
zambrey’s picture

Title: Wrong check of uid when casting votes programmatically » Casting votes programmatically

Thanks, I want to contribute my fivestar handler for Migrate module but it still needs some work.
I have three questions if you don't mind.

1. In db, fivestar field have two data columns: rating and target. Rating column is obvious but what is target used for? In my site target in all records have null value.

2. Currently there is no possibility to set timestamp for votes passed to votingAPI and in result all votes have current timestamp by default. I think that there should be a way to pass timestamp as a parameter. Will you accept such a feature? I can try to write patch for that.

3. one of the parameters of _fivestar_cast_vote() function is $result variable which is not used at all in this function. Can it be removed?

ericduran’s picture

Hey,

1. Target is used for when doing different axis voting, so example is I vote on a node, but I really want to target the user of that node. Is an advance feature not really documented yet.

2. Yes, I don't see why not. Feel free to just open another issue.

3. The 7.x branch is still being developed and we changed a lot of the code from 6.x while doing the upgrade so its possible that was just left there by mistake. Feel free to open a separate issue and we can fix that in that issue.

Thanks again.

zambrey’s picture

Thanks for your reply and sorry for delay.

I created issues for 2 & 3
#1342096: Allow to set timestamp of votes
#1342090: unused parameter in _fivestar_cast_vote() function

Regarding this target field. I'm using comments to rate nodes so shouldn't this target property be populated with node id or something?
Sorry for bothering you with that but I will need more info on that to write general fivestar field handler for Migrate module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.