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
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
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | strongarm-configuration-page-working-after-fix.png | 74.51 KB | oily |
| typeerror-strongarm-install-detail.png | 58.8 KB | oily | |
| typeerror-on-strongarm-install.png | 58.79 KB | oily | |
| broken-strongarm-install.png | 35.45 KB | oily |
Issue fork drupal-3402571
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:
- 3402571-broken-strongarm-module
changes, plain diff MR !5460
Comments
Comment #2
oily commentedComment #3
oily commentedComment #5
oily commentedComment #6
oily commentedComment #7
oily commentedComment #8
oily commentedComment #9
poker10 commentedThis is a problem in
Strongarmmodule intheme_strongarm_admin_form:$form['name']is NULL.Drupal core cannot "babysit" broken code, this needs to be fixed in that module. Thanks.
Comment #10
oily commented@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?
Comment #11
poker10 commented@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_childrenexpects 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 onStrongarmside checking the value before passing it to theelement_children. Code in Drupal core works as intended.Comment #12
oily commented@poker10 I disagree. Others may agree. I will try your fix in strongarm.
Comment #13
oily commented