Problem/Motivation
Page: admin/config/services/jsonapi
The above-mentioned admin page is not loading when config_readonly is active.
Steps to reproduce
To troubleshoot, need to enable readonly locally. Should be able to do this in a local settings file by adding the below code.
$settings['config_readonly'] = TRUE;
Visit admin/config/services/jsonapi it will throw you an error.
TypeError: strstr(): Argument #1 ($haystack) must be of type string, Drupal\Core\Form\ConfigTarget given in strstr() (line 167 of /code/web/modules/contrib/config_readonly/src/EventSubscriber/ReadOnlyFormSubscriber.php).
Proposed resolution
Replacing this code in line 166 from:
if (isset($config['#config_target']))
To
if (isset($config['#config_target']) && is_string($config['#config_target'])) and it is working fine.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
jon nunan commentedAm getting the same on the JSONAPI route, and a similar but slightly different error on REST endpoint settings.
e.g. admin/config/services/rest/resource/rest_menu_item/edit
gives
> Error: Cannot use object of type Drupal\Core\StringTranslation\TranslatableMarkup as array in Drupal\config_readonly\EventSubscriber\ReadOnlyFormSubscriber->getConfigTargetNames() (line 166 of modules/contrib/config_readonly/src/EventSubscriber/ReadOnlyFormSubscriber.php).
Comment #5
mvonfrie commentedI'm getting the exact same error on the admin page admin/reports/updates/settings.
Comment #6
fjgarlin commentedSame here too. I'm not sure whether that string should be empty or not, but at least the MR prevents the hard error.
Please review.
Comment #7
fjgarlin commentedGiven more info about the backtrace in case it's useful:
Comment #9
daniel.pernold commentedI have committed a patch that checks if the array key `#config_target` is of type `ConfigTarget` and if so, extracts the name from it. I think this is the proper approach since the buttons of the discussed forms then gets correctly disabled.
Comment #10
chandansha commentedI have tested MR 17. Now page accessible.
I move it to RTBC.
THANKS!!
Comment #11
pcate commented+1 RTBC. Patch resolves error on
/admin/config/services/jsonapipage.Comment #12
daniel.pernold commentedAnother issue has cropped up with the same source, this time with the RestUI module. I'm using this ticket to fix it here.
Patch in this issue fork:
https://git.drupalcode.org/issue/config_readonly-3469854/-/commit/12ac22...
Comment #13
daniel.pernold commentedHi guys, what about to merge this issue? It is tested very well from our side in many projects.
Comment #14
lisotton commentedI had the same with with Stage File Proxy and patch provided in the MR resolved the problem.
RTBC +1
Comment #15
daniel.pernold commented@Manoj_Selvan or any other maintainer: Tested this in a couple of projects over the last 7 months, no problems with the change in the MR encountered on our side. Seems very safe to merge.
Comment #16
guedressel commentedRTBC +1
Thanks @daniel.pernold 🙌
Comment #17
bdanin commentedThis is working, I wish it would make its way into a release!
Comment #18
trackleft2I am using the patch from the related issue, but attaching a static version of the merge request here instead of relying on the dynamic
.diffURL.This ensures the patch contents remain fixed and reviewable over time. The dynamic diff link can change if the merge request is updated, and since anyone with a Drupal.org account can modify it, including a static patch here avoids that risk and allows others to safely apply the same tested fix.
Fixes a WSOD caused by
config_readonlywhen accessing certain configuration forms (notably XML Sitemap bundle settings for me) while using a staged configuration workflow.