Issue Details (XML | Word | Printable)

Key: MDL-18227
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Eloy Lafuente (stronk7)
Reporter: Sean Keogh
Votes: 1
Watchers: 0
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Attempting to rate forum postings results in the message "Invalid Rate (568)"

Created: 12/Feb/09 09:33 PM   Updated: 05/May/09 07:28 PM
Return to search
Component/s: Forum
Affects Version/s: 1.7.7, 1.8.8
Fix Version/s: 1.7.7+, 1.8.9, 1.9.5

File Attachments: 1. Text File output_from_faulty_forum_screen.txt (76 kB)

Environment: Linux, Apache 2, PHP 5.2.6, MySQL 5

Database: MySQL
Participants: Eloy Lafuente (stronk7), Fernando Garcia, Martin Dougiamas, Petr Skoda and Sean Keogh
Security Level: None
QA Assignee: Petr Skoda
Difficulty: Easy
Resolved date: 04/May/09
Affected Branches: MOODLE_17_STABLE, MOODLE_18_STABLE
Fixed Branches: MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE


 Description  « Hide
Our client has a number of courses with forums in, and they rate posts in courses between certain dates.

Since our recent updates (in their case to 1.8.8) forum rating no longer works - instead it throws an error - "Invalid Rate (568)" - on the screen. Nothing shows up in the php error log, even at the highest levels of debugging.

This is using a simple 0 to 20 rating, no custom scales or anything like that.

I have tried switching rating off then on again, changing the numbers (0 to 10 for example), and switching off rating dates, but it makes no difference.

This is a major problem for our client, as they have just started a new teaching period with new students on new courses, and need this functionality urgently. It was working until the update. I am going to try an earlier version of rate.phop and see if it works...


Sean K

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Martin Dougiamas added a comment - 12/Feb/09 11:18 PM
Eloy can you check this please? I'm guessing it's the ajax rating.

Sean, can you try turning the ajax rating off? forum_ajaxrating


Sean Keogh added a comment - 12/Feb/09 11:24 PM
Hiya,

This is in 1.8.8 - as far as I can see there isn't an ajax rating option in forums - I certainly can't see it in the forum settings page. And ajax is turned off for the whole site in admin | miscellaneous.

The rating is just a drop-down list over on the lower right of the message box.

Sean K


Eloy Lafuente (stronk7) added a comment - 13/Feb/09 06:42 AM
Hi,

I guess it's some sort of problem with one new security check introduced in MDL-17365 (by me too). I tested it over 1.9 and HEAD and then backported to 1.8 and 1.7 (without conflicts).

Anyway... I'd suggest you, as immediate solution, to revert to mod/forum/rate.php version 1.22 (that was the one before I applied the security changes). That should fix the problem temporarily.

I'm going to test 1.8 and 1.7 and fix them in CVS ASAP. Will note about that here.

Ciao


Eloy Lafuente (stronk7) added a comment - 13/Feb/09 06:55 AM
Uhmm... strange. Just connected to my 1.8 test site and I discovered some test forums used recently to test ratings. I've tested that again, both with 0-100, 0-20 and custom scale... and it seems to work perfectly here, only getting the error if I try to send (by hacking the page) one invalid rate.

In fact, the error you posted above: "Invalid Rate (568)" means that somebody is trying to send one rate of 568 and that is obviously erroneous in one 0-20 scale.

Can you send the HTML output of the discussion being rated and causing the problem to see what values are in those menus internally? I'd expect 0-20 values, but not 568 at all (in fact that's why the new check was introduced, to prevent those invalid values to be processed).

Ciao


Sean Keogh added a comment - 13/Feb/09 07:30 PM
OK, I've attached the output of that screen as a text file.

Sean Keogh added a comment - 13/Feb/09 07:31 PM
This file is the output from the forum discussion screen, as requested by Eloy.

Eloy Lafuente (stronk7) added a comment - 13/Feb/09 07:58 PM
Thanks a lot Sean! Looking the page right now.

Eloy Lafuente (stronk7) added a comment - 13/Feb/09 08:09 PM
Aha, found it!

it seems that since some time ago the ratings form uses to send:

id = the forum id
forumid = the forum cmid
[array of rates]

but code in rate.php was trying to evaluate the forumid parameter as one more rate.

So, I've made a small fix that discards everything but the [array of rates] to be considered rates. Affected versions were 1.7 and 1.8. Changes are in CVS now.

One more question... old (wrong) behaviour could have been creating "fake" records in the forum_ratings table. Can you try this query in your server:

SELECT * from mdl_forum_ratings WHERE postid=0

Perhaps we'll need to do an upgrade step in the module to "clean" all those fake records (that don't cause any problem but their own existence).

Thanks a lot for the file, it helped to determine the problem (and also proved that the security check is working!).

Ciao


Fernando Garcia added a comment - 23/Mar/09 07:41 PM
The same problem affects me.

When I tried the query suggested, I find 134 records with post<>0 and 82 with post=0 with a 1.8.8 updated Moodle running since summer 2007 (not too much ratings, I know)

Perhaps i don't understand the fix, but my question is if some forums works and others don't, or all forum could fail this manner?. And if only some of them fail, what is the recommended way to fix it? Updating to 1.8.9 version? Or my Moodle is goint to create fakes records until I delete the old forums and create another ones?

Thanks in advance


Eloy Lafuente (stronk7) added a comment - 25/Mar/09 08:11 AM
Hi Fernando,

step 1 is to upgrade to latest 1.8.x (in your case) version available. That will stop creating new fake records completely. This is the important step to perform.

step 2 is to upgrade to 1.9.x because that version will be the one "cleaning" those 82 fake records from your table (but that isn't 100% necessary if you don't plan to upgrade to 1.9.x soon, those records won't cause any disruption to your system).

I'll introduce the cleaning along this week in Moodle 1.9.x. Still it isn't there (hence, this bug remains open)

ciao


Eloy Lafuente (stronk7) added a comment - 04/May/09 04:46 PM
Done,

the cleaning of fake records have been implemented in 19_STABLE and HEAD. Resolving as fixed. Ciao


Petr Skoda added a comment - 05/May/09 07:28 PM
thanks