Problem/Motivation

When you install the latest stable versions of the Drupal 7 features, strongarm modules and ctools as a dependency in the latest Drupal 7 version you find the strongarm module's configuration page is broken. Broken strongarm configuration page

There is an error reported in dblog to be at line 6723 of the core /includes/common.inc file.

Steps to reproduce

Install the features, the strongarm and the ctools modules into a git cloned Drupal 7 site, checked out at branch 7.x or download the latest Drupal 7 version (currently 7.98). Visit the strongarm module's configuration page at /admin/config/development/strongarm. The page is broken. Visit /admin/reports/dblog and you will find a typeerror error. Recent log messages

Error message details

This was tested using features 7.x-2.15, strongarm 7.x-2.0 and chaos tools 7.x-1.21.

Proposed resolution

Fix the error at line 6723 of the core common.inc file. Test the fix: after installing the required modules, create a test feature and select some variables from the 'strongarm' category. Then generate the test feature module and then enable it using e.g. 'drush pm-enable [the-module's-name]'.

Remaining tasks

Test the fix against the latest Drupal 7 version using PHP 8.1 and then re-test with PHP 7.4. Strongarm configuration page displaying correctly

Issue fork drupal-3402571

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

andrew.farquharson created an issue. See original summary.

oily’s picture

Issue summary: View changes
oily’s picture

Issue summary: View changes

oily’s picture

Issue summary: View changes
oily’s picture

oily’s picture

Issue summary: View changes
oily’s picture

Status: Active » Needs review
poker10’s picture

Project: Drupal core » Strongarm
Version: 7.x-dev » 7.x-2.x-dev
Component: base system » Code

This is a problem in Strongarm module in theme_strongarm_admin_form:

  foreach (element_children($form['name']) as $name) {
    $row = array();
    $row[] = isset($form['revert'][$name]) ? drupal_render($form['revert'][$name]) : '';
    $row[] = drupal_render($form['name'][$name]);
    $row[] = drupal_render($form['storage'][$name]);
    $row[] = drupal_render($form['value'][$name]);
    $rows[] = $row;
  }

$form['name'] is NULL.

Drupal core cannot "babysit" broken code, this needs to be fixed in that module. Thanks.

oily’s picture

@poker10 Hmm. I will look into this. I believe I have made the configuration form work when it was broken. I am not sure that following strict principles to prevent 'hiding' problems is necessary and thought I was being pragmatic! D7 has limited lifespan and I need to use it in production. I am sharing my own pragmmatic fixes as there may be others in the same predicament: using D7.x, PHP 8.1 and needing/ wanting to use Strongarm. The root cause I believe is D7 with PHP 8.1. The error does not seem to appear with earlier PHP versions. Your fix might be better but not sure its worth the extra effort? Strongarm has been superseded in D8 onwards anyway. Do you think PHP needs patching?

poker10’s picture

@andrew.farquharson Thanks for working on this and for your efforts. This was not a problem on earlier PHP versions because TypeErrors were only warnings before and therefore the page was displayed/working (though there were warnings in watchdog as well).

We cannot fix something, that is not broken in Drupal core. The function element_children expects in the first parameter an array (https://api.drupal.org/api/drupal/includes%21common.inc/function/element...). If some module passes NULL or other invalid value, it is not a responsibility of Drupal core to handle this. Modules are responsible when working with Drupal core APIs. So this can be fixed easily on Strongarm side checking the value before passing it to the element_children. Code in Drupal core works as intended.

oily’s picture

@poker10 I disagree. Others may agree. I will try your fix in strongarm.

oily’s picture

Status: Needs review » Closed (duplicate)