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)
Comments
Comment #2
fromme commentedComment #3
fromme commentedComment #4
mohit.bansal623 commentedAs 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.
Comment #7
stefanos.petrakisThank 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_...
Comment #8
mohit.bansal623 commented#7 works. Thanks for identifying this.
Comment #10
stefanos.petrakisGreat! This will also trigger a new release. Thank you both for helping with this.
Comment #11
stefanos.petrakisComment #13
stefanos.petrakis