after merging last quiz module version, my editors were unable to create any new question
i tracked back the error to quiz_question_node_access( .... in quiz_question.module

this function call in_array($node, $question_types) returns wrong at all times, $node should be replaced with $node->type

use patch in #2

Comments

sivaji_ganesh_jojodae’s picture

Status: Needs review » Fixed

Thanks amagdy. Commit 8424db5..2fe6ff8 should fix this. By hook_node_access() definition $node can be a node object or the machine name of the content type. Added $type = is_string($node) ? $node : $node->type; check to fix this.

amagdy’s picture

StatusFileSize
new1.31 KB

i learned something new from your replay, Thanks

your fix is great, but i got the permission denied again, tracing it i found that we use permissions that doesn't exist, may be it was changed from d6 and d7

'create quiz' => 'create quiz content'
'edit any quiz' => 'edit any quiz content'

sivaji_ganesh_jojodae’s picture

amagdy, I had some tough time as well with node permission testing i.e I got permission denied in unexpected cases where I expected to see grants. Later I figured it was registry cache problem. hook_node_access() outputs are cached it seems. Are you sure you cleared the registry before testing? [I did it with drush cc registry command]

Also the new permissions like 'create quiz content', 'edit any quiz content', etc. are inherited automatically from node module and check for the same is likely to happen in node module. Perhaps our checks are obsolete now. Simpletest is the smart way to test this. I will see if can write some code for this.

amagdy’s picture

I checked how permissions are written in database, there was a table 'role_perm' i guess, not on my dev machine

in this table the permission was used as i did in my latest patch

sarjeet.singh’s picture

Status: Fixed » Active

I faced same issue.

is submited this patch in 7.x.4.x-dev version?

sarjeet.singh’s picture

patch #2 is working fine.
thanks @amagdy

amagdy’s picture

Issue summary: View changes

fix is obsolete, we should use the next patch

freddura’s picture

I have experienced the same issue...

I am getting the following errors when trying to apply patch #2 to the latest dev release:

error: patch failed: question_types/quiz_question/quiz_question.module:94
error: question_types/quiz_question/quiz_question.module: patch does not apply

any ideas?

amagdy’s picture

Well, Quiz 7.4 is changing rapidly..

Patch #2 doesn't apply because the code was update since my last patch, unfortunately I can't produce a new patch now

I checked the code, and my guess is that,the bug lies in lines (104 & 108) in ($account->uid == $node->uid)

By hook_node_access() definition $node can be a node object or the machine name of the content type.

luciogodoy’s picture

Hi All,

I have a drupal 7 website, and i have downloaded quiz 7.x-4.x-dev and i m having issues when creating questions, i am getting permission denied, could you guys share some light on this issue pls?

Thanks

Lucio

falcon’s picture

Status: Active » Fixed

amagdys changes have been commited. Thanks!

sarjeet.singh’s picture

thanks @falcon

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

fixing typo

  • Commit 2fe6ff8 on 7.x-4.x, 7.x-5.x by sivaji:
    Fix #1446800 by sivaji- Access denied when trying to create any question...

  • Commit 2fe6ff8 on 7.x-4.x, 7.x-5.x, quiz-pages by sivaji:
    Fix #1446800 by sivaji- Access denied when trying to create any question...

  • Commit 2fe6ff8 on 7.x-4.x, 7.x-5.x, quiz-pages, 2269219 by sivaji:
    Fix #1446800 by sivaji- Access denied when trying to create any question...

  • Commit 2fe6ff8 on 7.x-4.x, 7.x-5.x, 2269219 by sivaji:
    Fix #1446800 by sivaji- Access denied when trying to create any question...