Upload of custom logo or wallpaper file fails due to maxlength form setting

Created on 11 January 2023, over 1 year ago
Updated 26 January 2023, over 1 year ago

Problem/Motivation

As an admin user I like to upload custom logo or wallpapers for the login screen at /admin/config/system/configuration/gin-login

Unfortunately trying so results in a fatal php error

TypeError: mb_strlen(): Argument #1 ($string) must be of type string, array given in mb_strlen() (line 333 of /var/www/html/web/core/lib/Drupal/Core/Form/FormValidator.php).

This is caused by the `#maxlength` setting in web/modules/contrib/gin_login/src/Form/GinLoginConfigurationForm.php

    $form['logo']['settings']['logo_upload'] = [
      '#type' => 'file',
      '#title' => t('Upload image'),
      //'#maxlength' => 40,
      '#description' => t("If you don't have direct file access to the server, use this field to upload your logo."),
      '#upload_validators' => [
        'file_validate_extensions' => [
          'png gif jpg jpeg apng webp avif svg',
        ],
      ],
    ];

Steps to reproduce

  • as admin user goto /admin/config/system/configuration/gin-login
  • upload a file to custom logo / wallpaper

Proposed resolution

Simply remove maxlength or replace with proper file upload limitations.

Remaining tasks

Resolve the error in the form array in GinLoginConfigurationForm.

User interface changes

None required, however I recommend adding file constraints. Especially considering that logos and wallpaper have size limitations.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany rvolk Frankfurt

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