Ensure all validation results use translatable strings except when created from throwables

Created on 29 September 2022, over 1 year ago
Updated 26 January 2023, over 1 year ago

Problem/Motivation

More or less everywhere we take an array of $messages as a method argument, we pass it not only not only TranslatableMarkup[], in practice, but also string[] this seem to happen most in in tests. The other case where we do this is when add validation results from exceptions.

We don't add want developers to create validation results that are not translatable. The only time where this should happen is when validation results are being create from throwable. in that case they won't be translatable.

Proposed resolution

We should make it easy to make it obvious that all validation results should translatable exception when created from exceptions

  1. Add \Drupal\package_manager\Event\PreOperationStageEvent::addErrorFromThrowable
  2. Add \Drupal\package_manager\ValidationResult::createErrorFromThrowable
  3. Change `\Drupal\Tests\automatic_updates\Traits\ValidationTestTrait::createValidationResult` to use translatable strings
  4. Replaces all places where we send untranslatable to \Drupal\package_manager\ValidationResult::createError or \Drupal\package_manager\ValidationResult::createWarning, \Drupal\package_manager\Event\PreOperationStageEvent::addError or \Drupal\package_manager\Event\StatusCheckEvent::addWarning
  5. In places where we add validation results from throwable(exceptions mostly) use \Drupal\package_manager\Event\PreOperationStageEvent::addErrorFromThrowable

Remaining tasks

1,2,3 are done. 4 and 5 need to be done

πŸ“Œ Task
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States TravisCarden

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.69.0 2024