Undefined array key 0 in SwitchthemeManager>getItem()

Created on 16 April 2023, over 1 year ago
Updated 24 August 2023, over 1 year ago

Problem/Motivation

I get this error on /admin/switch_theme/edit
drupal 9.5.7

Warning: Undefined array key 0 in Drupal\switch_theme\SwitchthemeManager->getItem() (line 73 of modules/contrib/switch_theme/src/SwitchthemeManager.php).
Drupal\switch_theme\SwitchthemeManager->getItem(NULL) (Line: 112)
Drupal\switch_theme\Form\EditForm->buildForm(Array, Object, NULL)
call_user_func_array(Array, Array) (Line: 534)
Drupal\Core\Form\FormBuilder->retrieveForm('switch_theme', Object) (Line: 281)
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: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->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: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Install module end go to /admin/switch_theme/edit

🐛 Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

🇮🇹Italy trickfun

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

Comments & Activities

  • Issue created by @trickfun
  • Assigned to racol
  • 🇫🇷France racol

    Hi,

    Working on it !

    Pleasure

  • Status changed to Postponed: needs info over 1 year ago
  • 🇫🇷France racol

    Hi,

    I installed a fresh install of Drupal 9.5.7 on an Apache server and I can't reproduce your issue.

    Step by step debugging:

    1. Download Drupal 9.5.7
    2. Configure virtualhost & MariaDB
    3. Install Drupal 9.5.7
    4. Front & Back are up
    5. Install Switch Theme 1.0.0
    6. Create the article "switch theme test 9.5.7" with the url alias "/switchtheme-test"
    7. Create a new switch theme in "/admin/switch_theme/edit" named "switchtheme-test" for role "Anonymous", Theme "stark" & URI Pattern "#^/switchtheme-test#"
    8. Clear caches
    9. Go to "/switchtheme-test", the theme stark is used, go to home, the default front theme is used

    My own configuration:

    • WEB Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/8.2.0
    • DB Server: MariaDB 10.4.27-MariaDB
    • PHP Version: 8.2.0
    • What is your configuration please ?

      I had some pictures, if you have any question, just let me know !

      Pleasure

  • 🇫🇷France racol

    Hi,

    my bad, the release 1.0.0 is not the last one, 1.1.0 is. I updated it on the drupal module page.

    So, you just need to desinstall the current switch theme module & take the release 1.1.0 (via composer or manually) & install it.

    Sorry for this inconvenience !

    Pleasure

  • 🇮🇹Italy trickfun

    Thank you racol,
    The error occurred with 1.1 version.

  • 🇫🇷France racol

    Hi,

    mh, I think you haven't get the good version of the module if you have the exact same error.

    Step by step debugging:

    1. Download Oracle Virtual Machine
    2. Install Linux Mint Cinnamon 64 on it
    3. Install LAMP (PHP version 8.0.0 & Mysql & Composer) - I believed PHP version was the problem, it seems to be wrong
    4. Download Drupal 9.5.7
    5. Configure virtualhost & Mysql
    6. Install Drupal 9.5.7
    7. Front & Back are up
    8. Install Switch Theme 1.1.0 via composer (composer require 'drupal/switch_theme:^1.1')
    9. Create the article "switch theme test 9.5.7" with the url alias "/switchtheme-test"
    10. Create a new switch theme in "/admin/switch_theme/edit" named "switchtheme-test" for role "Anonymous", Theme "stark" & URI Pattern "#^/switchtheme-test#"
    11. Clear caches
    12. Go to "/switchtheme-test", the theme stark is used, go to home, the default front theme is used

    Everything works for me (on APACHE & NGINX), can you please share to me your configuration ? (WEB server & version, DB server & version, PHP version & OS ?

    Thank you in advance !

    Pleasure

  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024