Admin Page `admin/config/services/jsonapi` is not loading in test environment

Created on 23 August 2024, 5 months ago

Problem/Motivation

Page: admin/config/services/jsonapi

The above-mentioned admin Page is not loading in test Environment.

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 through 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

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia manoj selvan

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

Merge Requests

Comments & Activities

  • Issue created by @manoj selvan
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia jon nunan

    Am 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).

  • First commit to issue fork.
  • Merge request !17Fixed Admin Page issue โ†’ (Open) created by Unnamed author
  • Pipeline finished with Failed
    5 months ago
    Total: 891s
    #267916
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria mvonfrie

    I'm getting the exact same error on the admin page admin/reports/updates/settings.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

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

  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    Given more info about the backtrace in case it's useful:

    https://mysite.ddev/admin/config/services/jsonapi
    
    Message	TypeError: strstr(): Argument #1 ($haystack) must be of type string, Drupal\Core\Form\ConfigTarget given in strstr() (line 167 of /app/web/modules/contrib/config_readonly/src/EventSubscriber/ReadOnlyFormSubscriber.php).
    
    Severity	Error
    
    Backtrace	
    #0 /app/web/modules/contrib/config_readonly/src/EventSubscriber/ReadOnlyFormSubscriber.php(167): strstr()
    #1 /app/web/modules/contrib/config_readonly/src/EventSubscriber/ReadOnlyFormSubscriber.php(82): Drupal\config_readonly\EventSubscriber\ReadOnlyFormSubscriber->getConfigTargetNames()
    #2 [internal function]: Drupal\config_readonly\EventSubscriber\ReadOnlyFormSubscriber->onFormAlter()
    #3 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
    #4 /app/web/modules/contrib/config_readonly/config_readonly.module(21): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
    #5 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(552): config_readonly_form_alter()
    #6 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(834): Drupal\Core\Extension\ModuleHandler->alter()
    ...
    
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria daniel.pernold

    daniel.pernold โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria daniel.pernold

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

  • Pipeline finished with Failed
    3 months ago
    Total: 189s
    #328916
  • Pipeline finished with Success
    3 months ago
    Total: 189s
    #328925
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chandansha

    I have tested MR 17. Now page accessible.
    I move it to RTBC.
    THANKS!!

  • Pipeline finished with Success
    3 months ago
    Total: 306s
    #328944
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States pcate

    +1 RTBC. Patch resolves error on /admin/config/services/jsonapi page.

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria daniel.pernold

    Another issue has cropped up with the same source, this time with the RestUI module. I'm using this ticket to fix it here.

    Error: Cannot use object of type Drupal\Core\StringTranslation\TranslatableMarkup as array in Drupal\config_readonly\EventSubscriber\ReadOnlyFormSubscriber->getConfigTargetNames() (line 167 of modules/contrib/config_readonly/src/EventSubscriber/ReadOnlyFormSubscriber.php).
    
    Drupal\config_readonly\EventSubscriber\ReadOnlyFormSubscriber->onFormAlter(Object, 'config_readonly_form_event', Object)
    call_user_func(Array, Object, 'config_readonly_form_event', Object) (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'config_readonly_form_event') (Line: 21)
    config_readonly_form_alter(Array, Object, 'restui') (Line: 552)
    Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'restui') (Line: 834)
    Drupal\Core\Form\FormBuilder->prepareForm('restui', Array, Object) (Line: 285)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Patch in this issue fork:

    https://git.drupalcode.org/issue/config_readonly-3469854/-/commit/12ac22...

  • Pipeline finished with Success
    about 1 month ago
    Total: 195s
    #371243
Production build 0.71.5 2024