Problem/Motivation

When a site is set to read only via readonlymode (https://www.drupal.org/project/readonlymode) the $form['actions'] array is unset to prevent submitting forms.

NodeFormAlter.php:187 attempts to add form validation to forms via $form['actions']. They have already been unset though by readonlymode, and so array_values() complains that:

TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 190 of modules/contrib/group_content_menu/src/NodeFormAlter.php).

Steps to reproduce

-Install readonlymode and group_content menu
-Enable read only mode
-Attempt to create a node in a group, as a user without the permission "Access all forms while in Read Only Mode"
-See error

Proposed resolution

-A quick sanity check of !empty($form['actions']) resolves the issue.

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:

Comments

jnicola created an issue. See original summary.

jnicola changed the visibility of the branch 3487080-nodeformalter.php-issue-when to hidden.

jnicola’s picture

Status: Active » Needs review

Okay got a merge request for it for anyone who may want this.

https://git.drupalcode.org/project/group_content_menu/-/merge_requests/43

Didn't investigate tests for this, but could reasonably write one I'm sure.

heddn’s picture

Status: Needs review » Needs work

Can we patch 3.x first? I'll backport from there. But group 1.x is on life support at the moment.

jnicola’s picture

Folks are welcome to do so, if the problem even exists there.

We're on the life support 1.x stuff until we migrate to group 2.x

heddn’s picture

There's an upgrade path to 3.x now, FWIW.

jnicola’s picture

Ugh, go figure I spent all spring making the switch to 2.x for one of our two big products, and now 3.x is ready!!!