Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/WeBWorK/ContentGenerator/ProblemSets.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ sub can ($c, $arg) {
my $text = DEFAULT_COURSE_INFO_TXT;
eval { $text = readFile($course_info_path) } if -f $course_info_path;

return $c->authz->hasPermissions($c->param('user'), 'access_instructor_tools')
# Note that the user parameter must be obtained in scalar context. In list context the param method
# returns the empty list when the parameter is not set, and that would silently remove the argument
# from the hasPermissions call below, making it croak about being given too few arguments.
my $user = $c->param('user');

return $c->authz->hasPermissions($user, 'access_instructor_tools')
Comment on lines +33 to +38

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you can demonstrate that this pull request is actually needed (I have done extensive testing, and I don't see any way that the can('info') calls can ever occur for this module without authentication, and so I doubt it is.), then this should be changed to

Suggested change
# Note that the user parameter must be obtained in scalar context. In list context the param method
# returns the empty list when the parameter is not set, and that would silently remove the argument
# from the hasPermissions call below, making it croak about being given too few arguments.
my $user = $c->param('user');
return $c->authz->hasPermissions($user, 'access_instructor_tools')
return $c->authz->hasPermissions(scalar $c->param('user'), 'access_instructor_tools')

Adding scalar does the same thing with a much smaller footprint, and the lengthy comment is not needed.

|| $text ne DEFAULT_COURSE_INFO_TXT;
}

Expand Down