I'm using Fivestar rating as a core function of my site. Everything works - people can register, log in and rate what they want to rate but users are getting the following error message multiple times across many pages of the site:
Notice: Undefined property: stdClass::$uid in _fivestar_allow_vote() (line 1015 of /home/destin77/public_html/sites/all/modules/fivestar/fivestar.module).
Notice: Undefined property: stdClass::$uid in _fivestar_allow_vote() (line 1017 of /home/destin77/public_html/sites/all/modules/fivestar/fivestar.module).
Notice: Undefined property: stdClass::$uid in _fivestar_allow_vote() (line 1015 of /home/destin77/public_html/sites/all/modules/fivestar/fivestar.module).
Notice: Undefined property: stdClass::$uid in _fivestar_allow_vote() (line 1017 of /home/destin77/public_html/sites/all/modules/fivestar/fivestar.module).
This is the first site in Drupal I have ever built. It works. It looks good. But how do I get rid of this error message? It will turn users off - for sure. I have searched for it, and nothing comes up. What do I do?
Please, please help!
Comments
As always, look at the issue queue!
See https://www.drupal.org/node/430362
I did
This solution seems to be corrected 8 years ago, and I have a much newer version of FiveStar. I don't see it as an error that comes up in issues. What am I missing?
Which version do you have
Can't match the error to the Stable or Development release. How does your version of the function look like?
Version 7.x-2.2
My Fivestar is version 7.x-2.2 I don't think there's been an update for a while.
That is not an answer to my question
Doubt that it is that version: line 1015 is empty and there is no line 1017.
Correction:
1015
return $entity->uid != $user->uid;
My apologies
I'm new at Drupal - this is my first site - and I don't code. That version information is from the modules page on my admin. When I expand the Fivestar listing, it's what appears above the list of required modules and required by modules.
Can you explain in a bit more detail what information you need if that isn't it?
Many thanks
Asked for the code of the function, as below:
Suspect 1077 and 1079 are the lines reported. Both reference $entity->uid. Looks like $entity has no property uid, which probably means line 1075 doesn't provide an array with $entity_id as index. Unfortunately it doesn't test that and return true. As is done when the values are not set.
This is apart from the fact lines 1077 and 1078 are redundant. Those variables are not used.
Haven't tried the code, but think it should look like:
Only replaced the lines after the line with entity_load.
EDIT
Maybe
if (!isset($entity($entity_id))) {
is better.Turn off error reporting?
See https://www.drupal.org/node/1036982#comment-10220137
But of course, try also to find the reason for the warnings.
Select "Allow users to vote on their own content"
This removed the error for me.
I created a new fivestar field in my taxonomy vocabulary (i.e. "Restaurants"), that I am having users reference from a Review Your Restaurant node.
In the end, I want users to create a Review Your Restaurant node that references a term while rating that term. Upon a user submitting their restaurant review (using Entity Reference Term), the term ratings are averaged under each term.
So when I, the admin, go to the term page and see the average score 3.5 out of 5 stars (10 votes), i receive that same error. I have applied the fixes above with no luck. However, I noticed the error disappears if I edit the field and select: "Allow users to vote on their own content."