This function is trying to access some index that may not exist.

For example:
if ($data['unused'] && isset($data['referenced']))

I've made a patch trying to solve this.

Comments

danielb’s picture

something weird about that patch, I think you patched it against your own previous code

I'd prefer not to use the initialize function and just put !empty() or isset() in the right spots

aheredia’s picture

The problem is that isset or !empy only checks but does not initialize the indexes that must be passed to

nodeaccess_nodereference_add_grant(
                    $grants,
                    'nodeaccess_nodereference_' . $operation,
                    $nid,
                    $data['priority'],
                    $data['referenced'][$operation]
                  );

And the call to this function should be done to apply NANR

Is that correct? or i'm wrong

danielb’s picture

it can be handled inline with a ternary statement

danielb’s picture

how about this?

aheredia’s picture

Ok i'll try to do it that way

danielb’s picture

or i guess technically if we're passing an empty array() into those.. they won't do anything? so we could just wrap the whole call in an if-statement

johnv’s picture

How about this change in nodeaccess_nodereference_add_grant():

   // Add the grants needed, so as not to override previous iterations.
-  if (isset($settings['view']) && $settings['view']) {
+  if (!empty($settings['view'])) {
     $grants[$key]['grant_view'] = 1;
   }
-  if (isset($settings['update']) && $settings['update']) {
+  if (!empty($settings['update'])) {
     $grants[$key]['grant_update'] = 1;
   }
-  if (isset($settings['delete']) && $settings['delete']) {
+  if (!empty($settings['delete'])) {
     $grants[$key]['grant_delete'] = 1;
   }

The error in if ($data['unused'] && isset($data['referenced'])) can be prevented in my comment-to-be in #1619636: Cumulative settings improvements and fixes.

danielb’s picture

You mean in addition to the other changes?
I presume the issue is the function call.

johnv’s picture

IMO, OP's error will not occur with the new 'minified' variable from the new version.
However, you will only get this data-structure when you change, save, change-back, save-again. Which is undoable.
Or apply the hook_N_update() function in the other issue.

aheredia’s picture

I think patch #4 works and is a good aproach.

I don't understand #6. Do you mean an if statement to call or not to call nodeaccess_nodereference_add_grant function ???. This function should be always called.

danielb’s picture

If the 4th param $settings is empty that function effectively does nothing. It just sets a dummy grant with 0 for everything, which is meaningless.

danielb’s picture

Also I think your comment #2 is wrong, $data['referenced'][$operation] is always going to be there if that bit of code is run, since the iterations of the foreach are based on the keys of the array, so I won't do anything about that.

danielb’s picture

danielb’s picture

nope, this one

danielb’s picture

Status: Active » Fixed

i've committed that, i guess we can go from there if there is a prob, till then marking as fixed

Status: Fixed » Closed (fixed)

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