Hi,

Yesterday after updating my Drupal 7 installation to the latest release 7.x-2.3 I started getting this error in my website for every single page with fivestar ratings.

Notice: Undefined index: rating in _fivestar_field_property_values() (line 822 of /home/thespani/public_html/sites/all/modules/fivestar/includes/fivestar.field.inc).

After reverting to 7.x-2.2 issue dissapeared.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

valery86 created an issue. See original summary.

TR’s picture

Status: Active » Postponed (maintainer needs more info)

Probably has something to do with #1256572: Integrate with Entity API - that change was made 3.5 years ago though, and there have been no other reports of a problem since ...

valery86’s picture

Hi TR,

Thanks a lot for the answer

Yes I do have the Entity API installed in my website, but not sure how can I help out to troubleshoot, any idea or suggestion?

TR’s picture

I suspect this is just poor design - it seems like there is no default rating value and that is set to NULL by default, which IMO is really wrong and needs to be corrected. But I don't personally have the time to look into that and create a proper fix. I don't know why this wasn't noticed and fixed three years ago, and none of the people involved with that contribute to this module anymore ...

This patch should avoid the PHP Notice. I never saw that Notice so I don't know what conditions are necessary to reproduce it, so I don't have a way to test that this patch actually works. If it does, then all it does is avoid the issue rather than correcting missing default value, but apparently the rest of the code is kludged together to always do an isset() to check for the missing value so everything should still work.

If you can test this and confirm it fixes the problem for you, then that would be helpful.

valery86’s picture

Just tested in my test environment and works perfectly! No error is displayed after applying your patch

Thanks a lot for your quick and effective support!!

One question, do you know whether this patch will be included in the next 7.x release?

TR’s picture

Status: Postponed (maintainer needs more info) » Active

Yes, a fix to this issue will be in the next release, but that may not be for a while.

7.x-2.2 was released 4 years ago and we were long overdue for a new release. 7.x-2.3 was released just last week. If there are a number of issues like this that need correcting, I will probably make a new D7 release in about 6 months - we need to allow time for people to upgrade then get experience/find problems with 7.x-2.3, then allow time to fix any problems like this that arise.

But if there are no significant issues I plan on just refreshing the D7 version about once a year from now on, or whenever anything important changes.

valery86’s picture

Ok I fully understand you, it's absolutelly reasonable.

Thanks a lot again for your quick and great support.

valery86’s picture

Hi TR,

Unfortunately I had to revert to 2.2 version since Google Webmasters reported that the Schemaorg for the Review Snippets was not correct. After checking the issue is that with the 2.3 the values Rating Count and Rating Value of the AggregageRating appear as empty values.

After reverting to 2.2 the values are correct.

For the 2.3 the schemaorg generated looks like this:

"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": " ",
"ratingCount": " ",
"bestRating": "5",
"worstRating": "1"

The point is that I'm not sure whether this is related to the patch of this thread or is a general issue of the 2.3 version. Do you know if the patch could impact in this? If has nothing to do I'll move this issue to the general queue of fivestar issues.

thanks!

TR’s picture

@valery86: Please open a new issue for #8.

oxy86’s picture

Hi, this affects me too after upgrading to Drupal 7.72, fivestar 2.3, votingapi 7.x-2.15 - entity 7.x-1.9.
The patch in #4 fixed the warnings, yet ratingValue is missing as in valery86's case - I will monitor #3152661.
Thanks!

Damn-Deal-Done’s picture

I just had this same issue and patch in #4 worked for me.

  • TR committed a70107f on 7.x-2.x
    Issue #3151638 by TR: Undefined index: rating in...
TR’s picture

Version: 7.x-2.3 » 7.x-2.x-dev
Status: Active » Fixed

As I said in #4, I would really prefer a proper fix with a test case for this, rather than just hiding the error as is done in the patch.

However, since D7 is nearing its end-of-life and because there has been no community interest in this over the past four years, I'm going to just go ahead and commit #4.

This isn't an issue that affects the D8 version of Fivestar, because in D8 we properly define a default value for the user_rating.

Committed #4.

Status: Fixed » Closed (fixed)

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