Hello all,

I had a problem in my multilingual website that when someone vote on specific node, the translated one doesn't have the same vote, that was raised before in drupal 6.x but wasn't solved in drupal 7.x, so here is a patch that might solve this issue, but it needs review, kindly check it and report if it's working with you.

It's based on using the translated node's id when casting a vote (tnid) so instead of using the nid, it uses tnid.

Thanks in Advance!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adelka’s picture

@bingorabbit - I wanted to test it, but is the pach ok? I can see only two lines of code but there is no information about file, line etd.

PMZ’s picture

Something new about this issue and the proposed solution? Is the proposed patch safe?

Thanks for info!

(I am using the: 7.x-2.0-alpha2 version)

Mikel_And_Mendizabal’s picture

Any news on this?

I am trying this patch and the ones for D6, but nothing works....:(

Any ideas?

ibrahim.mohamed’s picture

FileSize
2.58 KB

Sorry for being late..Resubmitting the patch!

Status: Needs review » Needs work

The last submitted patch, fivestar.patch, failed testing.

ibrahim.mohamed’s picture

Status: Needs work » Needs review

#4: fivestar.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, fivestar.patch, failed testing.

Charlouze’s picture

Attached is your patch corrected to be appliable by git.

Charlouze’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, fivestar-1834256-use_tid_or_nid.patch, failed testing.

Darc_Nite’s picture

I looked over this patch and implemented in my site manually and i found three bugs in it (which i fixed as i went)

 function fivestar_custom_widget($form, &$form_state, $values, $settings) {
-  $form = array(
+    
+  $br_node = node_load($settings['content_id']);
+  $settings['content_id'] = $br_node->tnid ? $br_node->tnid : $settings['content_id'];

should be

 function fivestar_custom_widget($form, &$form_state, $values, $settings) {
-  $form = array(
+    
+  $br_node = node_load($form_state['settings']['content_id']);
+  $form_state['settings']['content_id'] = $br_node->tnid ? $br_node->tnid : $form_state['settings']['content_id'];

the same in fivestar_form_submit and fivestar_ajax_submit

oleg.medvedev’s picture

Issue summary: View changes
FileSize
2.62 KB
oleg.medvedev’s picture

Status: Needs work » Needs review
whiteph’s picture

Has anyone with a multilingual site tested the fix in #12? If someone can confirm it is working, I'll commit it to the 7.x-2.x dev branch.

mjanouch’s picture

Works for me.

le72’s picture

On module version 7.x-2.1 getting notice:

Notice: Undefined variable: id in fivestar_get_votes_multiple() (line 219 of [path_to_fivestar]/fivestar/fivestar.module). 

indeed

if (drupal_multilingual()) {
    $node = node_load($id);
    if (isset($node->tnid)) {
      $id = $node->tnid;
    }
  }

should be replaced with

  if (drupal_multilingual()) {
    foreach ($ids as &$id) {
      $node = node_load($id);
      if (!empty($node->tnid)) {
        $id = $node->tnid;
      }
    }
  }

$node->tnid is always set. It is 0 if no translation.

danitochilin’s picture

not work in version 7.x-2.1 fivestar

when change language get this error:
Notice: Undefined index: average em fivestar_expand() (linha 648 de /home/.../sites/all/modules/fivestar/fivestar.module).
Notice: Undefined index: count em fivestar_expand() (linha 649 de /home/.../sites/all/modules/fivestar/fivestar.module).
Notice: Undefined offset: 0 em fivestar_field_formatter_view() (linha 491 de /home/.../sites/all/modules/fivestar/includes/fivestar.field.inc).

adelka’s picture

Would be great to have a version for version 7.x-2.1

adriancid queued 4: fivestar.patch for re-testing.

adriancid queued fivestar.module.patch for re-testing.

The last submitted patch, 4: fivestar.patch, failed testing.

The last submitted patch, 8: fivestar-1834256-use_tid_or_nid.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 12: fivestar-multilingual-1834256-12.patch, failed testing.

adriancid’s picture

Version: 7.x-2.x-dev » 7.x-2.1
FileSize
2.03 KB

I created this patch for voting in each translation of the node when you use i18n.

adriancid’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 26: fivestar-multilingual_support-1834256-26.patch, failed testing.

silver157’s picture

Any updates for this problem?

adriancid’s picture

@silver157 I don't know why my pacth failed in the test. If you want test it in your site, it work for me

silver157’s picture

and i tested it and it works with me :)

Thanks a lot Adrian :)

adriancid’s picture

I created this patch for voting in each translation of the node when you use i18n. I make the patch again because it seems that before there was a error with the line numbers. So this is the same code of the patch #26

adriancid’s picture

Assigned: adriancid » Unassigned