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.

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RandalV created an issue. See original summary.

RandalV’s picture

Added a second module_load_include() to the MR, it was needed elsewhere too.

Now I haven't run into any other issues.

salvis’s picture

Priority: Normal » Major
FileSize
1.55 KB

Thank 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.

Status: Needs review » Needs work

The last submitted patch, 4: fa-moderator-form-3386451-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

salvis’s picture

Status: Needs work » Needs review
FileSize
2.11 KB

Status: Needs review » Needs work

The last submitted patch, 6: fa-moderator-form-3386451-6.patch, failed testing. View results

salvis’s picture

Status: Needs work » Needs review

Failed because of not having any tests.

RandalV’s picture

Status: Needs review » Needs work

Hi @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.

The website encountered an unexpected error. Please try again later.
TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in _acl_edit_form_after_build() (line 126 of modules/contrib/acl/acl.admin.inc).
_acl_edit_form_after_build(Array, Object)
call_user_func_array('_acl_edit_form_after_build', Array) (Line: 1083)
Drupal\Core\Form\FormBuilder->doBuildForm('taxonomy_term_forums_forum_form', Array, Object) (Line: 1075)
Drupal\Core\Form\FormBuilder->doBuildForm('taxonomy_term_forums_forum_form', Array, Object) (Line: 1075)
Drupal\Core\Form\FormBuilder->doBuildForm('taxonomy_term_forums_forum_form', Array, Object) (Line: 579)
Drupal\Core\Form\FormBuilder->processForm('taxonomy_term_forums_forum_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object, 'forum') (Line: 259)
Drupal\forum\Controller\ForumController->addForum()
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
leisurman’s picture

I 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.

leisurman’s picture

@salvis. Update. Upgrading ACL module from 8.x-1.0 to 8.x-1.1, and using patch #6 fixes the error.

salvis’s picture

Status: Needs work » Reviewed & tested by the community

Thank 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.

  • salvis committed 20156522 on 8.x-1.x
    Issue #3386451 by salvis: Fix moderator element doesn't exist on Add...
salvis’s picture

Title: Moderator element doesn't exist on add forms, causes error » Moderator element doesn't exist on Add forms, causes error
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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