Problem/Motivation
The Content Access Simple module attempted to use the disableCheckboxes method from the ContentAccessRoleBasedFormTrait as a static callback in the Form API #process property.
This caused a fatal error:
TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, non-static method Drupal\content_access\Form\ContentAccessRoleBasedFormTrait::disableCheckboxes() cannot be called statically
As a result, forms using Content Access Simple failed to render, breaking node editing and related functionality.
This is because recent changes in content_access 2.1.0-rc3 prevent this from being called statically.
Steps to reproduce
- Enable Content Access (2.1.0-rc3) and Content Access Simple modules.
- Attempt to edit a node with Content Access Simple enabled.
- Observe the fatal error and broken form.
Proposed resolution
- Refactor Content Access Simple to use the trait ContentAccessRoleBasedFormTrait in its AccessManager class.
- Register the disableCheckboxes callback as [$this, 'disableCheckboxes'] from within an instance method, ensuring it is called in the correct object context.
- This allows the checkboxes to be properly disabled without causing a fatal error.
Issue fork content_access_simple-3586583
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3586583-fix-disableCheckboxes-static-call
changes, plain diff MR !2
Comments
Comment #3
joegl commentedThis is not gonna work; it causes serialization issues because the process callback should be static. Will look towards another solution, possibly even getting changes made in content_access.
See: #3570550
Comment #4
joegl commentedThis was resolved upstream in content_access (for now). Either way, this was not the correct solution and the issue was caused by an anti-pattern being introduced in content_access. Going to close this.
Comment #5
joegl commentedComment #8
joegl commentedContent Access related issue: https://www.drupal.org/project/content_access/issues/3570550
Merge request: https://git.drupalcode.org/project/content_access/-/merge_requests/30
This was already cut into the rc4 release so don't need to patch from merge request.