So I have decided to clean up a bunch of these error messages that I'm getting. They all see to be the results of code of the for
if ($array_name[$key_name]) .....
Where there array defaults to the an empty array so that you get an error message like
"Notice: Undefined index: business_page in nodeaccess_access() (line 91 of /home/cleanhip/public_html/fogeater.com/stanfordinn.com/drupal/sites/all/modules/nodeaccess/nodeaccess.module)."
When I tried going to the page with an anonymous user. The fix I have been using for these bugs, which I'm not sure is the best fix, is to replace
$array_name[$key_name]
With
array_key_exists($key_name, $array_name)
-Tristan
Comment | File | Size | Author |
---|---|---|---|
#8 | nodeaccess-undefined_index-1155706-8.patch | 703 bytes | vlad.pavlovic |
#6 | nodeaccess-undefined_index-1155706-6.patch | 830 bytes | drupal_jon |
#5 | nodeaccess-undefined_index-1155706-4.patch | 1.1 KB | weri |
Comments
Comment #1
Seph CreditAttribution: Seph commentedI am getting a similar error message that shows up on all of my pages.
Notice: Undefined index: page in nodeaccess_access() (line 91 of /home.../sites/all/modules/nodeaccess/nodeaccess.module).
Notice: Undefined index: webform in nodeaccess_access() (line 91 of /home.../sites/all/modules/nodeaccess/nodeaccess.module).
What do I need to do to clear it up?
The code from line 91 down is:
if ($node->nid && $allowed_types[$node->type] &&
(user_access('grant node permissions', $account) ||
(user_access('grant editable node permissions', $account) && node_access('update', $node, $account)) ||
(user_access('grant deletable node permissions', $account) && node_access('delete', $node, $account)) ||
(user_access('grant own node permissions', $account) && ($account->uid == $node->uid)))) {
return TRUE;
}
}
return FALSE;
}
Comment #2
Darkplek CreditAttribution: Darkplek commentedJust changing line 91 to read
if ($node->nid && array_key_exists($node->type, $allowed_types) &&
fixed the problem for me.
Hope that helps :)
Comment #3
windsurfitaly CreditAttribution: windsurfitaly commentedyes it works goo thanks a lot man
Comment #5
weri CreditAttribution: weri commentedPlease add this modification to the nodeaccess code.
Comment #6
drupal_jon CreditAttribution: drupal_jon commentedHere's a patch against the last dev release (2011-Feb-17).
Comment #7
holtzermann17 CreditAttribution: holtzermann17 commentedThanks, used the quick fix from #2 to get past an error.
Comment #8
vlad.pavlovic CreditAttribution: vlad.pavlovic commentedChanged to use isset instead. Patch attached, will push to dev when I complete some other additions as well.
Thanks all.
Comment #9
vlad.pavlovic CreditAttribution: vlad.pavlovic commentedFix pushed to dev.