Problem/Motivation

Hi.
After installing the module (8.x-1.3) i go to config page /admin/config/media/file_upload_secure_validator and get the error:

The website encountered an unexpected error. Please try again later.
Error: Undefined class constant 'NO_HEADERS_KEY' in Drupal\file_upload_secure_validator\Form\SettingsForm->getConfigurationAsCsvString() (line 108 of modules\contrib\file_upload_secure_validator\src\Form\SettingsForm.php).
Drupal\file_upload_secure_validator\Form\SettingsForm->getConfigurationAsCsvString() (Line: 73)
Drupal\file_upload_secure_validator\Form\SettingsForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 532)
Drupal\Core\Form\FormBuilder->retrieveForm('file-upload-secure-validator-settings', Object) (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
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: 50)
Drupal\ban\BanMiddleware->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: 104)
Drupal\babyme_navigation_assistant\BabymeNavigationAssistantMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
CommentFileSizeAuthor
#4 3197971-4.patch938 bytesmohit.bansal623
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

shabanau created an issue. See original summary.

fromme’s picture

Title: Undefined class constant 'NO_HEADERS_KEY' » Errors on configuration page
fromme’s picture

Title: Errors on configuration page » Undefined class constant 'NO_HEADERS_KEY'
mohit.bansal623’s picture

Status: Active » Needs review
StatusFileSize
new938 bytes

As in CsvEncoder.php file, we have only the below constants defined, why are we using this constant NO_HEADERS_KEY.

I have removed this as this constant is not present in CsvEncoder.php file, only the below are defined.
const FORMAT = 'csv';
const DELIMITER_KEY = 'csv_delimiter';
const ENCLOSURE_KEY = 'csv_enclosure';
const ESCAPE_CHAR_KEY = 'csv_escape_char';
const KEY_SEPARATOR_KEY = 'csv_key_separator';
const HEADERS_KEY = 'csv_headers';

Please review this patch.

stefanos.petrakis made their first commit to this issue’s fork.

stefanos.petrakis’s picture

Thank you for bringing this to my attention, I was hoping this was fixed with b7afa93, however, I missed one important detail there.
I will not be accepting your patch, since this is something that is deliberately there and don't want to remove it.

The fix is quite simple, encolse the CsvEncoder::NO_HEADERS_KEY in quotes, then defined() can really check if the constant is defined.

It would be great if you can verify that the latest patch works:

https://git.drupalcode.org/project/file_upload_secure_validator/-/merge_...

mohit.bansal623’s picture

#7 works. Thanks for identifying this.

  • stefanos.petrakis committed 984a9e3 on 8.x-1.x
    Issue #3197971 by stefanos.petrakis, mohit.bansal623: Undefined class...
stefanos.petrakis’s picture

Status: Needs review » Fixed
Related issues: +#3186490: Undefined class constant 'NO_HEADERS_KEY'

Great! This will also trigger a new release. Thank you both for helping with this.

stefanos.petrakis’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

stefanos.petrakis’s picture