openwebwork / webwork2

Course management front end for WeBWorK
http://webwork.maa.org/wiki/Main_Page
Other
143 stars 165 forks source link

Fix issue #2272. #2273

Closed drgrice1 closed 8 months ago

drgrice1 commented 9 months ago

Make sure that the $userRecord that is passed to the fieldHTML method in ProblemSetDetail.pm exists before trying to access it.

Note the actual error occurs for the counts_parent_grade column of the problem record which is the only problem record field that is of the "choose" type (which is why this does not occur for non JITAR sets). The earlier checks that the $userRecord exists are needed as the hacked method of accessing the data directly via the hash key rather than using the accessor turns the undefined value into a hash reference if that is done. Then the check if the $userRecord exists in the "choose" case later will fail because it will exist.

I don't know how long this bug has existed, but I know it goes back to at least WeBWorK 2.17 (I suspect it goes back considerably further though). The fieldHTML method in general needs a rewrite. There is to much hackery in use there. The comment on lines 855-857 is about part of what is causing this problem. That comment dates back to 2007, and the problem it refers to goes back further.

drgrice1 commented 9 months ago

I upgraded this to a more proper fix and removed the direct access to the hash keys of the database record.