Steps to reproduce (example from Simplytest.me below but also replicated locally):
Fresh install of Drupal 7.26
Install Fivestar 7.x-2.0-rc1 & Votingapi 7-2.11
Add a fivestar field with default settings to article

Error on node/add/article:
Fatal error: Class name must be a valid object or a string in /home/s91cd692d395d085/www/includes/common.inc on line 7837

Errors on admin/structure
Notice: Undefined index: entity_id in _fivestar_allow_vote() (line 978 of /home/s91cd692d395d085/www/sites/all/modules/fivestar/fivestar.module).
Notice: Undefined index: entity_type in _fivestar_allow_vote() (line 980 of /home/s91cd692d395d085/www/sites/all/modules/fivestar/fivestar.module).
Notice: Undefined index: controller class in entity_get_controller() (line 7836 of /home/s91cd692d395d085/www/includes/common.inc).

Comments

shi99’s picture

I also get the same errors.
I added a fivestar field to a profile2 profile and when I went to edit a users profile I got the errors

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

Notice: Undefined index: entity_id in _fivestar_allow_vote() (line 978 of ..../sites/all/modules/fivestar/fivestar.module).
Notice: Undefined index: entity_type in _fivestar_allow_vote() (line 980 of ..../sites/all/modules/fivestar/fivestar.module).
Notice: Undefined index: controller class in entity_get_controller() (line 7836 of ..../includes/common.inc).

The same setup with fivestar 7.x-2.0-beta1 does not raise this error for me

whiteph’s picture

Thanks for the feedback, and the clear description on how to reproduce the problem.

The only problem is that I can't reproduce the problem as described by @chris_h. I've added a new Fivestar field to Artlcle ok, then created a new Article instance and voted using the new widget.

Are you sure you ran the update script?

shi99’s picture

Hi whiteph,

Thanks for checking.

I found out in my set-up, that in the field settings for the fivestar field (e.g /admin/structure/types/manage/review/fields/field_rating), if you do not have "Allow users to vote on their own content." selected it breaks for me.
Once I have that option selected, the add and edit node forms work.

whiteph’s picture

@shi99 - thanks for the feedback, I'm glad it's working for you now. There are two features added in 7.x-2.0-rc1 which will cause things to break if the update script isn't run: Prohibit users from voting on their OWN nodes and Don't let user to change his vote or re-vote. There are two new field settings: "Allow users to re-vote on already voted content" and "Allow users to vote on their own content". The defaults are set so "YES" in both cases, so existing Fivestar users shouldn't get a surprise - but the update script must be run to set those default values. If update isn't run, the database won't have any values for those settings and bad things will happen. So, just to help me to determine if there's a bigger problem - did you run the update script before reporting the issue above?

@chris_h - did you run the update script?

shi99’s picture

@whiteph -

The issue happened for both a fresh install of the latest module and for an update from the previous beta.

Here are the steps I took
- Installed the latest fivestar (fivestar-7.x-2.0-rc1)
- Set it up with a field added to a profile2 profile
- I made customisations to the field and disabled the options allowing users to cancel vote, re-vote and vote for themselves
- When I edited a user account using that profile I would get the mentioned errors
- Removed field, disabled and uninstalled the fivestar module

- I installed the previous fivestar beta version (fivestar 7.x-2.0-beta1)
- Set it up with a field added to a profile2 profile
- I made customisations to the field (there was only one option if I remember correctly to allow users to cancel their vote. I disabled this option)
- When I edited a user account using that profile it opened fine
- I removed the field from profile and added it to user fields directly with the cancel vote option disabled (this is not important for the issue, just repeating the steps I made)
- Editing a user worked

- I downloaded the latest fivestar (fivestar-7.x-2.0-rc1)
- Ran the update.php. If I remember correctly, 3 updates ran.
- Went back to the fivestar field settings. By default, re-vote and vote for own content were enabled and cancel vote was still disabled.
- I disabled all options, edited a user account and I got the same errors.
- Just to confirm it is a WSOD and the fatal error is in my apache error log.

When I edit the fivestar field and enable "Allow users to vote on their own content." the error does not happen. Enabling or disabling the other two option does not effect the error.

Hopefully this will help. Thanks for looking into it.

capellic’s picture

While I was creating a screencast for another issue, I ran into this problem. And yes, it's related to those new checkbox fields that were added. You can see it in the screencast I created for #2212639: Votes on Comments do not aggregate to parent node. Thanks!

i.bajrai’s picture

I am experiencing the same issue, it is when I try to comment on content I have created.

Is some one writing the patch? I can try but not very good at patching!

whiteph’s picture

@shi99 - thanks for the detailed feedback. Ditto @capellic. @i.bajrai - I'll be writing the patch, though some work to do first to find the bug in the code.

Meanwhile, ticking the box to allow "Allow users to vote on their own content" should restore normal behaviour. Let me know if that's not the case.

The bug seems to be that a) when this flag isn't set, we get random/WSOD behaviour rather than gracefully displaying the widget in read-only mode; b) ensuring that the database has a valid setting for this flag for existing Fivestar users upgrading to rc1; c) ditto for new installs. Again, please let me know if this is wrong. It would also be helpful if anybody has observed other cases, and even when they've upgraded and it's working for them.

Depending how the debugging goes, I'll either create a patch or back out the change for this feature. Either way, I'll put out an rc2 version asap as rc1 is clearly broken.

whiteph’s picture

Priority: Major » Critical
chris_h’s picture

@whiteph I didn't run the update script, it was a fresh install.

I have just reinstalled, again a fresh install on simplytest.me. I can confirm the error goes away if Allow users to vote on their own content is checked. That field is not checked by default.

whiteph’s picture

Status: Active » Fixed

Please test latest 7.x-2.x-dev version, which contains the fix for this issue.

chris_h’s picture

Status: Fixed » Reviewed & tested by the community

I can confirm that removes both errors.

whiteph’s picture

Status: Reviewed & tested by the community » Fixed

Great, thanks for testing. I've moved the status back to "Fixed", so that the system can move it to "Closed (fixed)" after a couple of weeks of no further activity. If anyone still sees the problem they can set it to "Needs work", which is an "Active" state.

Status: Fixed » Closed (fixed)

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