The while loop in _quiz_delete_question() that is used to build the $quizzes_to_update array will always add false as the last item in the array.

This causes the following error when the first db_update() query in quiz_update_max_score_properties() is run on a Postgres database with false as one of the $quizzes_to_update:

PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "" LINE 6: WHERE (vid IN ('')) ^: UPDATE quiz_node_properties SET max_score=max_score_for_random * number_of_random_questions + ( SELECT COALESCE(SUM(max_score), 0) FROM quiz_node_relationship qnr WHERE qnr.question_status = 1 AND parent_vid = quiz_node_properties.vid) WHERE (vid IN (:db_condition_placeholder_0)) ; Array ( [target] => default [return] => 2 [already_prepared] => 1 ) in quiz_update_max_score_properties() (line 2292 of /home/bend/src/drupal7/sites/all/modules/quiz/quiz.module).

This issue can be reproduced with a fresh install of the quiz module on a site running with a Postgres database by creating a multiple choice quiz question and then attempting to delete it.

Comments

ben.denham created an issue. See original summary.

ben.denham’s picture

Status: Active » Needs review
StatusFileSize
new612 bytes

Here is a patch that fixes this issue by ensuring the final value of false returned by $res->fetchField() is not added to the $quizzes_to_update array.

djdevin’s picture

Status: Needs review » Fixed

Great catch. Thanks!

  • djdevin committed ec07a75 on 7.x-5.x authored by ben.denham
    Issue #2560717 by ben.denham: Incorrect loop termination when buidling $...

Status: Fixed » Closed (fixed)

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