hi!
There is a missing $uid property that causes incorrect access
Scenario:
1 - Create a simple quiz with any number of questions, for example 1 multichoice.
2 - Do the quiz
3 - Go to my results: node/1/myresults/1
Notice: Undefined property: stdClass::$uid in QuizQuestion->viewCanRevealCorrect() (line 628 of
public function viewCanRevealCorrect() {
global $user;
// permission overrides the hook
if (user_access('view any quiz question correct response')
|| $user->uid == $this->node->uid) {
return TRUE;
}
$results = module_invoke_all('answers_access', $this->node);
$may_view_answers = in_array(TRUE, $results);
return $may_view_answers;
}
The problem is that the node is not loaded completely (because of performance reasons) and the uid is not beeing pulled from database so the if statement fails.
Attaching patch to solve it, please review!
Comments
Comment #2
gedur commentedComment #3
ultimikeThis could also be caused by a permissions issue - see https://www.drupal.org/node/2454273.
thanks,
-mike
Comment #5
djdevinThanks, this fixes the notice. I changed r.nid to n.nid, so that the current question owner is pulled instead of the revision's owner.
This isn't necessary in 7.x-5.x since we use Drupal 7 entity caching.