- 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.
- ๐ฆ๐น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 10:49am 4 November 2024 - ๐ฆ๐น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.
- ๐ฎ๐ณIndia chandansha
I have tested MR 17. Now page accessible.
I move it to RTBC.
THANKS!! - ๐บ๐ธ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...