Broken Strongarm module installation with PHP 8.1

Created on 18 November 2023, about 1 year ago
Updated 21 November 2023, about 1 year ago

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

🐛 Bug report
Status

Closed: duplicate

Version

2.0

Component
Base 

Last updated about 6 hours ago

Created by

🇬🇧United Kingdom oily Greater London

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @oily
  • 🇬🇧United Kingdom oily Greater London
  • 🇬🇧United Kingdom oily Greater London
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    2,163 pass
  • @andrewfarquharson opened merge request.
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 7.4 & SQLite 3.27
    last update about 1 year ago
    2,159 pass
  • last update about 1 year ago
    2,163 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 7.4 & PostgreSQL 9.5
    last update about 1 year ago
    2,124 pass
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    2,163 pass
  • 🇬🇧United Kingdom oily Greater London
  • 🇬🇧United Kingdom oily Greater London
  • 🇬🇧United Kingdom oily Greater London
  • Status changed to Needs review about 1 year ago
  • 🇬🇧United Kingdom oily Greater London
  • 🇸🇰Slovakia poker10

    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.

  • 🇬🇧United Kingdom oily Greater London

    @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 doing what I am. The root cause I believe is D7 with PHP 8.1. The error does not seem to appear with earlier version. You fix might be better but not sure its worth the extra effort? Strongarm has been superseded in D8 onwards.

  • 🇸🇰Slovakia poker10

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

  • 🇬🇧United Kingdom oily Greater London

    @poker10 I disagree. Others may agree. Good luck.

  • Status changed to Closed: duplicate about 1 year ago
  • 🇬🇧United Kingdom oily Greater London
Production build 0.71.5 2024