hi,

I upgraded to voting api 2.8 and had to disable voting rules as cron would not run any more.
Drush throws out this PHP error:

PHP Fatal error: Class name must be a valid object or a string in includes/common.inc on line 7679

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vloo’s picture

It seems that the author forgot to implement hook_entity_info()...

Use this code:

<?php
/**
 * Implements hook_entity_info().
 */
function voting_rules_entity_info() {
  $return = array(
    'voting_rules' => array(
      'label' => t('Voting rules'),
      'base table' => 'voting_rules',
      'uri callback' => 'voting_rules_uri',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'eeid',
      ),
      'bundles' => array(
        'voting_rules' => array(
          'label' => t('Voting rules'),
          'admin' => array(
            'path' => 'admin/structure/voting_rules',
            'access arguments' => array('administer voting rules'),
          ),
        ),
      ),
    ),
  );
  return $return;
}
?>

I added it to voting_rules.module and now it works fine :)

adam_b’s picture

FileSize
4.69 KB

vloo, thanks for your comment on #1810474: Ajax error with Advanced Poll - but I've tried your fix and I'm still getting the same error.

I've attached the updated voting_rules.module file, where I've added the code above from line 52 - could you check if I've got it right? (The .txt file extension is just so it can be uploaded here.)

many thanks.

vloo’s picture

Yep, that's the thing. Only difference between yours and mine is that I got it in the bottom, but this shouldn't matter...

It's version = "7.x-1.0-alpha1"
I got Voting API version = "7.x-2.9"
Drupal 7.16

Try disabling some modules in order to see if anything other is messing with the voting rules... I can't get any other idea why this is not working for you :/

mermemladeK’s picture

Same problem and version than adam_b.
Vloo: your solution is not working for me either. Do I have to wait some time?

adam_b’s picture

Tried moving that code to the end of voting.rules.modules, and I got a WSOD with the message:

Notice: Undefined index: schema_fields_sql in /homepages/31/d292789962/htdocs/theparentzone/includes/entity.inc on line 265
Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be an array, null given, called in /homepages/31/d292789962/htdocs/theparentzone/includes/entity.inc on line 284 and defined in /homepages/31/d292789962/htdocs/theparentzone/includes/database/select.inc on line 1300

Tried uninstalling the module and reinstalling with the new code, and it appeared to install in a working state, but with a warning message (repeated 3 times):
Warning: array_keys() [function.array-keys]: The first argument should be an array in drupal_schema_fields_sql() (line 6899 of /homepages/31/d292789962/htdocs/theparentzone/includes/common.inc).
As above, this didn't fix the 200 error.

Checked the Status report and found this:

The following tokens or token types are missing required name and/or description information:
$info['tokens']['vote_results']['count-vote-cache-id']
$info['tokens']['vote_results']['count-function']
$info['tokens']['vote_results']['average-vote-cache-id']
$info['tokens']['vote_results']['average-function']
$info['tokens']['vote_results']['sum-vote-cache-id']
$info['tokens']['vote_results']['sum-function']

but that didn't look very relevant and I couldn't find a way to edit the tokens short of editing code.

Tried removing all the modules except Advanced Poll, Voting API and Voting Rules - same 200 error.

Tried starting on a new site from scratch, using only the minimal modules needed to test this (advpoll, date, entity, rules, voting_rules, votingapi) and when I tried to enable the patched Voting Rules module, I got the same WSOD error as above.

So... no luck yet :(

mustername’s picture

thx vloo, works for me with
Rules 2.2
Voting API 2.9
and Drupal 7.16

I do get a warning 'array_keys() expects parameter 1 to be array, null given common.inc:6899' though.

mermemladeK’s picture

I solved it by disabling and enabling the Voting rules module.

bobrock’s picture

I solved in this way:

  1. disable voting rules module
  2. run cron via drush or web-interface
  3. enable voting rules module

Without cron run it didn't work for me

szantog’s picture

Status: Active » Needs review
FileSize
482 bytes

I'm sure, the _entity_info is not necessary. Why should have the voting rules own entity? It uses the rules api.

As I see, the votingapi makes changes (or could be a full new feature) when deleting orphaned votes. If this happens, the delete vote event is fired. But this orphaned deleting is a bulk operations, so doesn't contains the entity_type and entity_id, which are used in voting_rules_load_entity().

I'm not sure, this is the perfect solution, because when I fixed it my own, the orphaned votes was deleted, and never could catch this orphaned deleting process again. The fact, when the rule was fired by an orphaned deletion, the $entity_type and $entity_id was NULL.

szantog’s picture

@bobrock
Yes, this solves the issue temporary. When you run cron without voting_rules, the orphaned votes was deleted as well by votingapi. But the next time, when the votingapi will try delete these again, the error will get back.

andypost’s picture

Status: Needs review » Needs work

I think this should use empty() so no reason to load entities without type

andypost’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
530 bytes

second argument should be checked with is_null() because of UID=0

rodpal’s picture

@andypost
Rules 2.2
Voting API 2.9
and Drupal 7.16

I still get the ajax error:

Notice: Undefined index: form_build_id en ajax_get_form() (línea 320 de C:\xampp\htdocs\vepormas\includes\ajax.inc).

kappaluppa’s picture

#1 worked for me. But I also turned off voting rules, ran cron turned it back on. Still had the error. Added the info from #1 and now I don't get the error. Thanks vloo.

drupal 7.22
Advanced Poll 7.x-3.x-dev
Voting API 7.x-2.11
Voting Rules 7.x-1.0-alpha1
Rules 7.x-2.2

so far, so good...

cchoudhary’s picture

Issue summary: View changes

Tried all of above mentioned solutions, nothing worked for me, Still getting same error. can please someone help , need it urgent.

drupal 7.24
Advanced Poll 7.x-3.x-dev
Voting API 7.x-2.11
Voting Rules 7.x-1.0-alpha1
Rules 7.x-2.6