When a node is saved with a change in a "user reference" field, nodeaccess_delete_user_reference() function is called.

If the previous contents of the field is empty, then the function calls user_load_multiple by passing a parameter to "false".

On a site with many users, causes a "Fatal error: Allowed memory size of ...", because is loading a full list of users.

Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 99 bytes) in /var/www/mysitehtml/modules/field/field.attach.inc on line 696
Stack trace:
  1. {main}() /var/www/mysitehtml/index.php:0
  2. menu_execute_active_handler() /var/www/mysitehtml/index.php:21
  3. call_user_func_array:{/var/www/mysitehtml/includes/menu.inc:527}() /var/www/mysitehtml/includes/menu.inc:527
  4. page_manager_node_edit() /var/www/mysitehtml/includes/menu.inc:527
  5. ctools_context_handler_get_task_contexts() /var/www/mysitehtml/sites/all/modules/contrib/ctools/page_manager/plugins/tasks/node_edit.inc:92
  6. ctools_context_get_context_from_arguments() /var/www/mysitehtml/sites/all/modules/contrib/ctools/includes/context-task-handler.inc:333
  7. ctools_context_get_context_from_argument() /var/www/mysitehtml/sites/all/modules/contrib/ctools/includes/context.inc:859
  8. ctools_node_edit_context() /var/www/mysitehtml/sites/all/modules/contrib/ctools/includes/context.inc:803
  9. ctools_context_create() /var/www/mysitehtml/sites/all/modules/contrib/ctools/plugins/arguments/node_edit.inc:36
 10. ctools_context_create_node_edit_form() /var/www/mysitehtml/sites/all/modules/contrib/ctools/includes/context.inc:607
 11. drupal_build_form() /var/www/mysitehtml/sites/all/modules/contrib/ctools/plugins/contexts/node_edit_form.inc:70
 12. drupal_process_form() /var/www/mysitehtml/includes/form.inc:385
 13. form_execute_handlers() /var/www/mysitehtml/includes/form.inc:903
 14. node_form_submit() /var/www/mysitehtml/includes/form.inc:1519
 15. node_save() /var/www/mysitehtml/modules/node/node.pages.inc:460
 16. module_invoke_all() /var/www/mysitehtml/modules/node/node.module:1180
 17. call_user_func_array:{/var/www/mysitehtml/includes/module.inc:934}() /var/www/mysitehtml/includes/module.inc:934
 18. nodeaccess_node_update() /var/www/mysitehtml/includes/module.inc:934
 19. nodeaccess_delete_user_reference() /var/www/mysitehtml/sites/all/modules/contrib/nodeaccess/nodeaccess.module:699
 20. user_load_multiple() /var/www/mysitehtml/sites/all/modules/contrib/nodeaccess/nodeaccess.module:968
 21. entity_load() /var/www/mysitehtml/modules/user/user.module:291
 22. DrupalDefaultEntityController->load() /var/www/mysitehtml/includes/common.inc:7962
 23. UserController->attachLoad() /var/www/mysitehtml/includes/entity.inc:206
 24. DrupalDefaultEntityController->attachLoad() /var/www/mysitehtml/modules/user/user.module:337
 25. field_attach_load() /var/www/mysitehtml/includes/entity.inc:354

I add a validation (if) to check if "field_get_items()" is false.

    $user_uids = field_get_items('node', $node, $field_name);

    if($user_uids) {
      $user_references = user_load_multiple($user_uids);
      foreach ($user_references as $user) {
        unset($form_values['uid'][$user->uid]);
      }
    }

Comments

sir_gon created an issue. See original summary.

Scionar’s picture

StatusFileSize
new776 bytes

Previous patch didn't work. I created new one.

We had same issue with memory in this situation.

d.fisher’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: -

Drupal 7 security support has ended as of 5 January 2025.

We are doing some housekeeping on the nodeaccess issue queue and moving all Drupal 7 issues to "postponed (maintainer needs more info)". See https://www.drupal.org/project/nodeaccess/issues/3516593.

If this issue persists on the latest dev branch of nodeaccess (2.0.x-dev) then please feel free to comment and we will change the version against this issue. If we do not hear any feedback within 2 weeks (9th October 2025) we will go ahead and close this issue as outdated.

Thank you.

d.fisher’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

As per the above, as there has been no response we will now close this issue as outdated.

If this issue persists on the latest dev branch of nodeaccess (2.0.x-dev) then please feel free to update the version on this issue and reopen it.

Thank you.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.