Bug 16179

Summary: Clicking Rate me button in OPAC without selecting rating produces error
Product: Koha Reporter: John Yorio <jyorio>
Component: OPACAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: bgkriegel, brendan, cbrannon, f.demians, jonathan.druart, julian.maurice
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 16210    
Bug Blocks:    
Attachments: Bug 16179: Do not crash if "rate me" is clicked and not rate selected
Bug 16179: Do not crash if "rate me" is clicked and not rate selected
[SIGNED-OFF] Bug 16179: Do not crash if "rate me" is clicked and not rate selected
[PASSED QA] Bug 16179: Do not crash if "rate me" is clicked and not rate selected

Description John Yorio 2016-03-31 16:16:04 UTC
When a patron clicks on Rate me button on the detail screen without selecting a rating option, the following error is produced:

Software error:

DBIx::Class::ResultSet::create(): Column 'rating_value' cannot be null at /usr/share/koha/lib/C4/Ratings.pm line 208

For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error

Related to this, patrons who are not logged in, can still click the Rate me button, but are unable to make a rating selection and will get the error message as a result.

Ideally, in either case, they would receive a more user-friendly message rather than the error above.

Steps to reproduce:
0) Do not log in
1) Search the catalog for a title
2) View one of the search results
3) Click on the Rate me button

OR

0) Log in
1) Search the catalog for a title
2) View one of the search results
3) Click on the Rate me button
Comment 1 Owen Leonard 2016-04-02 15:21:02 UTC
The first step in diagnosing this problem is to figure out why you see a "rate me" button in the first place. The star ratings JavaScript should hide that button automatically. That you see a "rate me" button indicates that there is a JavaScript error on the page which is interrupting execution.

Do you have any custom JavaScript in OPACUserJS?
Comment 2 Jonathan Druart 2016-04-04 13:35:16 UTC
Owen, I get the error when JS is disabled.
Comment 3 Jonathan Druart 2016-04-04 13:48:13 UTC Comment hidden (obsolete)
Comment 4 Bernardo Gonzalez Kriegel 2016-04-05 14:13:51 UTC
Hi,
disabling JavaScript gives an empty OPAC page (chrome/firefox),
or more properly a 'hidden' page.
This without patch.
Comment 5 Owen Leonard 2016-04-05 18:48:33 UTC
(In reply to Bernardo Gonzalez Kriegel from comment #4)
> Hi,
> disabling JavaScript gives an empty OPAC page (chrome/firefox),
> or more properly a 'hidden' page.

This issue now has a bug report: Bug 16210.
Comment 6 Christopher Brannon 2016-04-05 22:11:25 UTC
I find this impossible to test without bug 16210 addressed.
Comment 7 Mark Tompsett 2016-04-05 22:58:16 UTC Comment hidden (obsolete)
Comment 8 Owen Leonard 2016-04-07 14:13:26 UTC Comment hidden (obsolete)
Comment 9 Katrin Fischer 2016-04-14 05:45:07 UTC
Created attachment 50222 [details] [review]
[PASSED QA] Bug 16179: Do not crash if "rate me" is clicked and not rate selected

If JS is disabled and a user clicks on the "Rate me" button, Koha will
crashes with:
DBIx::Class::ResultSet::create(): Column 'rating_value' cannot be null
at /usr/share/koha/lib/C4/Ratings.pm line 208

To avoid that, opac-ratings.pl will check if a rate has been selected.

Test plan:
Disable JS
On a record detail page, click on the "Rate me" button

TESTED PLAN:
1) go to /cgi-bin/koha/opac-ratings.pl?biblionumber=1
   -- kaboom as above.
2) apply patch
3) refresh
   -- either login screen (don't know why)
   -- or if already logged in, detail page.
4) koha qa test tool

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>

I tested successfully by temporarily removing the modification made by
Bug 16210.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 10 Brendan Gallagher 2016-04-20 19:50:49 UTC
Pushed to Master - Should be in the May 2016 Release.  Thanks!
Comment 11 Julian Maurice 2016-04-21 08:14:39 UTC
Patch pushed to 3.22.x, will be in 3.22.6
Comment 12 Frédéric Demians 2016-04-27 15:32:16 UTC
Pushed to 3.22.x, will be in 3.20.11.