Improve error handling during image type detection in \Drupal\ldap_user\Processor\DrupalUserProcessor::saveUserPicture()

Created on 16 January 2025, 20 days ago

Problem/Motivation

Our cron jobs started to fail with the error:

[error]  TypeError: image_type_to_extension(): Argument #1 ($image_type) must be of type int, bool given in image_type_to_extension() (line 605 of /app/web/modules/contrib/ldap/ldap_user/src/Processor/DrupalUserProcessor.php) #0 /app/web/modules/contrib/ldap/ldap_user/src/Processor/DrupalUserProcessor.php(605): image_type_to_extension()
#1 /app/web/modules/contrib/ldap/ldap_user/src/Processor/DrupalUserProcessor.php(561): Drupal\ldap_user\Processor\DrupalUserProcessor->saveUserPicture()

Turned out that something went wrong with the recent employee onboarding process and they had an invalid file stored as a user picture in the LDAP.

Debug Report

Not sure how to reproduce that, but if you will have an invalid data in the LDAP image attribute that will probably do.

Proposed resolution

Improve error handling in image type detection.

Remaining tasks

  • Code change
  • Review
  • Commit

User interface changes

None

API changes

None

Data model changes

None

📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇳🇿New Zealand RoSk0 Wellington

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024