Filename casing leads to error on Linux

Created on 25 March 2021, over 4 years ago
Updated 28 April 2023, over 2 years ago

Problem/Motivation

Linux is filename case sensitive, and this causes an error on the settings form because of the difference between the specified class and the filename of the class. This makes the module impossible to use on Linux without fixing.

The error:

The website encountered an unexpected error. Please try again later.

InvalidArgumentException: Class "\Drupal\jsnlog\Form\JSNlogSettingsForm" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of core/lib/Drupal/Core/DependencyInjection/ClassResolver.php).
Drupal\Core\Controller\HtmlFormController->getFormObject(Object, '\Drupal\jsnlog\Form\JSNlogSettingsForm') (Line: 76)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
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: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
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: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Here's the cause:

Routing.yml has: \Drupal\jsnlog\Form\JSNlogSettingsForm
Filename is: src/Form/JSNLogSettingsForm.php
Method name is: JSNlogSettingsForm

Note the capital L in the filename.

Steps to reproduce

Run 1.0 or 1.x-dev on Linux. Go to the Settings form.

The problem is present in both.

Proposed resolution

Rename src/Form/JSNLogSettingsForm.php to src/Form/JSNlogSettingsForm.php or change the method name and routing.

The second solution is slightly better because it matches the name of the library.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Jeff Veit

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024