There is a way to get the old "sum" value before save ? I need to calculate something and i need both the old and new sum values.

Something like (sum before vote was 8 , sum after vote is 9).

I tried using hook_votingapi_results_alter() but the $vote_results contains only the new data.
I have tried to receive the old data by making querys in votingapi_cache table but with no success. Maybe the data was already gone at that point.

function module_name_votingapi_results_alter(&$vote_results, $content_type, $content_id) {

  // get new data
  -  $vote_results provide the new data. All good.



  // get the old data
  -  query to votingapi_cache return nothing all the time
  -  tried using votingapi_select_single_result_value() but again it doesn't return anything


 }

Is this posible ?

Thank you.

EDIT:
solved using vote up/down api

Comments

istryker’s picture

@Necropsique Curious how you solved it with Vote up/down module. Can you explain.

istryker’s picture

Title: get old sum value before save ? » Need to get old sum before new vote is set
Version: 7.x-2.6 » 7.x-2.x-dev
Component: Miscellaneous » Code
Category: support » feature
Status: Active » Fixed

Closing this issue in favor of #1269614: Add pre-save or pre-set hook before data is store to database. With the preset hook you can grab the sum before the vote is save. This might not solve every scenario, but will solve most.

Marking as fixed

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

solved using vote up/down api