Problem/Motivation
Running into the issue of a WSOD (with error) on add forms for forums.
The error is as follows
The website encountered an unexpected error. Please try again later.
Error: Call to undefined function acl_edit_form_get_user_list() in forum_access_form_taxonomy_term_forums_x_form_alter_after_build() (line 660 of modules/contrib/forum_access/forum_access.mNodule).
If I add this line in that function `module_load_include('inc', 'acl', 'acl.admin');`, then I get this error:
The website encountered an unexpected error. Please try again later.
TypeError: acl_edit_form_get_user_list(): Argument #1 ($form) must be of type array, null given, called in /app/web/modules/contrib/forum_access/forum_access.module on line 660 in acl_edit_form_get_user_list() (line 193 of modules/contrib/acl/acl.admin.inc).
That's because the moderator element of the form does not yet exist, if you check the function `_forum_access_forum_moderators_form` in forum_access.admin.inc, it requires a term id which is not yet generated on add forms.
Steps to reproduce
Using these modules:
- forum_access
- acl
- content_access (probably doesn't matter, but listing it anyway)
On a Drupal 9.5.10
Proposed resolution
It seems fixed by simply adding this piece of code to the `forum_access_form_taxonomy_term_forums_x_form_alter_after_build` function:
if (!isset($form['moderators'])) {
return $form;
}
module_load_include('inc', 'acl', 'acl.admin');
Remaining tasks
Review MR.
Apologies if this issue has been reported before, but I couldn't find any.
Comment | File | Size | Author |
---|---|---|---|
#6 | fa-moderator-form-3386451-6.patch | 2.11 KB | salvis |
Issue fork forum_access-3386451
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:
Comments
Comment #3
RandalVAdded a second module_load_include() to the MR, it was needed elsewhere too.
Now I haven't run into any other issues.
Comment #4
salvisThank you for your report and patches, @RandalV!
I agree, something is completely broken here! With just ACL and FA, your patch allows opening Forum|Add, but it still crashes when trying to save the new forum. Also, the Moderator element is (obviously) not present on the Forum|Add page. This is the real issue!
Ignoring the absence of the Moderator element is not the right approach — it must be there for us to use.
Here's a new patch, please test it.
Comment #6
salvisComment #8
salvisFailed because of not having any tests.
Comment #9
RandalVHi @Salvis,
Thanks for your reply and patch! You're right, ignoring the lack of the moderator element is not the way.
With your patch however, I'm still getting the following error when navigating to the 'Forum add'-form.
I haven't got the time to debug this right now though, I'm afraid.
Comment #10
leisurman CreditAttribution: leisurman commentedI see the same, TypeError: count as mentioned by @RandalV
Using Drupal core 9.5.11
Forum Access Version: 8.x-1.0
ACL Version: 8.x-1.0
I have tried both patch #4 and patch #6
Our production site is on PHP 7, my local environment is on PHP 8. The error occurs on both PHP versions.
Comment #11
leisurman CreditAttribution: leisurman commented@salvis. Update. Upgrading ACL module from 8.x-1.0 to 8.x-1.1, and using patch #6 fixes the error.
Comment #12
salvisThank you, @leisurman and @RandalV for testing!
I've pushed #3390466: Update ACL dependency and fix some other issues in composer.json and *.info.yml to require ACL 8.x-1.1, which should make #6 work according to @leisurman's and my own testing.
Comment #14
salvis