Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #2272. #2273

Merged

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Dec 6, 2023

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
Copy link
Member Author

drgrice1 commented Dec 6, 2023

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

@drgrice1 drgrice1 force-pushed the bugfix/jitar-forusers-no-problem-record branch from 6c6d061 to 7ec013c Compare December 6, 2023 11:40
@drgrice1 drgrice1 force-pushed the bugfix/jitar-forusers-no-problem-record branch from 7ec013c to fcde2d8 Compare December 17, 2023 00:39
Copy link
Member

@pstaabp pstaabp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes the issue.

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.
Remove the improper access of the direct hash keys in the database
records in the fieldHTML method.  Instead check that the record object
`can` access the fields.
@drgrice1 drgrice1 force-pushed the bugfix/jitar-forusers-no-problem-record branch from fcde2d8 to c70ae20 Compare January 6, 2024 17:17
@pstaabp pstaabp merged commit 218f485 into openwebwork:develop Jan 8, 2024
1 check passed
@drgrice1 drgrice1 deleted the bugfix/jitar-forusers-no-problem-record branch January 8, 2024 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants