Hi,

the drush vcalc function runs into an error:

Error: Call to undefined function votingapi_recalculate_results() in drush_votingapi_recalculate() (line 172 of /home/

Obviously the function votingapi_recalculate_results() does not exist.

To workaround the issue, I've made advantage of the

plugin.manager.votingapi.resultfunction service through which i can access the function recalculateResults.

I've changed the drush_votingapi_recalculate function (line 154) in votingapi.drush.inc the following way:

  foreach ($votes as $vote) {
    $manager = Drupal::service('plugin.manager.votingapi.resultfunction');
    $manager->recalculateResults($vote['entity_type'], $vote['entity_id'], 'vote');
  }

Comments

awroblewski created an issue. See original summary.

awroblewski’s picture

StatusFileSize
new563 bytes

added patch file

awroblewski’s picture

StatusFileSize
new1.53 KB

A new version of the fix.

vote_type is no longer hard coded and can be supplied as the third parameter to the vcalc drush function.
As well swaped console output, "rebuild all votes" is displayed when all votes are rebuild and for specific vote recalc, the appropriate message is displayed. Both outputs where merely in the wrong if else path.

This is no incremental fix for the one i provided yesterday, so it should be applied to the 8.x-3.x version.

thanks

socialnicheguru’s picture

Status: Active » Needs review
pifagor’s picture

Status: Needs review » Needs work

Patch Failed to Apply

shubham.prakash’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB

The patch in #3 seems correct to me, added reroll for it.

shubham.prakash’s picture

Version: 8.x-3.0-alpha2 » 8.x-3.x-dev
pifagor’s picture

StatusFileSize
new3.87 KB
andralex’s picture

Tested and worked for Drupal version 8.8.2, Drush 8.3.3-dev. But some minor issues found:

+++ b/votingapi.drush.inc
@@ -156,23 +156,24 @@ function _votingapi_cast_votes($etype, $eid, $timestamp = 0, $uids = [], $style
-    $message = t('Rebuilt voting results for @type votes.', ['@type' => $entity_type]);

I'd say that the message here should be unchanged.

+++ b/votingapi.drush.inc
@@ -156,23 +156,24 @@ function _votingapi_cast_votes($etype, $eid, $timestamp = 0, $uids = [], $style
+    $message = dt('Rebuilt voting results for @type votes.', ['@type' => $entity_type]);

The message here could be changed to 'Rebuilt voting results for @type id: @entity_id.'

andralex’s picture

StatusFileSize
new3.96 KB
new760 bytes

Here is an updated patch regarding to my last comment.

alex_optim’s picture

Status: Needs review » Reviewed & tested by the community

Good for me.

pifagor’s picture

Status: Reviewed & tested by the community » Needs work

Need to reroll

  • pifagor committed 162388e on 8.x-3.x
    Issue #2858130 by awroblewski, andralex, pifagor, shubham.prakash,...
pifagor’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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