Author Topic: [TRACKER 2198] Customer Review bug  (Read 3199 times)

DDPaul

  • Beginner
  • *
  • Posts: 28
[TRACKER 2198] Customer Review bug
« on: July 01, 2008, 18:07:41 pm »
I've run accross a bug when trying to write a product review on the flypage. The bug occurs when using IE7/VISTA with both javascript and cookies enabled. The sequence that duplicates the bug is:

1. logon to the shop using the vertuemart login module.
2. navigate to the product flypage to write a review.
3. select 0 stars for a review and enter a review text of less than 100 characters.
4. an error alert box pops up informing the user of the error. click okay and continue.
5. make sure 0 stars are selected and reenter some review text with a valid length. submit the review
6. the page is refreshed with an erroneous error message requesting the user to "rate the product to complete the review".
7. repeat step 5 and again you get the step 6 response.
8. try again, repeating step 5 except choose some stars rather than 0 stars.
9. a thank message is displayed but no review is displayed.
10. if you now try again to rate the product you cannot as the system somehow records that you have written a review but no review is displayed.


configuration: joomla! 1.5.3(cache off , SEF off);virtuemart1.1.0 stable (23/04/2008); Firefox 2.0.0.14 (using both javascript enabled and disabled); Internet Explorer 7.0.6001.18000;  Apache 2.2.8; MySQL 5.0.51a; PHP 5.2.5 installed on a localhost.


DDPaul

aravot

  • Peter
  • Moderator
  • Sr. Member
  • *
  • Posts: 2874
    • VirtueMart Extensions
Re: Customer Review bug
« Reply #1 on: July 01, 2008, 19:09:24 pm »
Thank you for step by step instruction, bug confirmed for the 1st part i.e 0 star, step 9 works for me I can see the review published.

DDPaul

  • Beginner
  • *
  • Posts: 28
Re: [TRACKER 2198] Customer Review bug
« Reply #2 on: July 02, 2008, 00:21:42 am »
I found the problem. In the file reviewform.tpl.php the javascript line
for (var i=0; i<form.user_rating.length; i++)
should be
for (var i=0; i<(form.user_rating.length+1); i++)

As for the rest, that was my fault for posting too soon without reflection.


DDPaul

  • Beginner
  • *
  • Posts: 28
Re: [TRACKER 2198] Customer Review bug
« Reply #4 on: July 02, 2008, 02:00:43 am »
I apologize, I screwed up. The javascript is okay.

 It's getting late but I couldn't quit until I had this problem completely figured this out. It seems that the problem was in the class file ps_reviews.php. The php empty function instead of the isset function was used to test the input. empty always returns true even when the variable is set and has a zero value.

The solution I used was to change the line
if( empty( $d["user_rating"] ) || intval( $d["user_rating"] ) < 0 || intval( $d["user_rating"] ) > 5) {

to

if( !isset( $d["user_rating"] ) || intval( $d["user_rating"] ) < 0 || intval( $d["user_rating"] ) > 5) {
in the class method process_review.

Again I appologize for posting too soon. Will try to do better in the future.

DDPaul