Remove calls to drupal_valid_test_ua() from production code

Created on 4 March 2025, about 1 month ago

Problem/Motivation

There are a bunch of places in the production code where we call drupal_valid_test_ua() to facilitate test-only flags and behavior. Convenient at the time, but it makes maintainers pretty sad, so maybe we can try to remove these calls and find cleaner ways to accomplish the same things.

๐Ÿ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

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

Comments & Activities

  • Issue created by @phenaproxima
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arunsahijpal

    Hi @phenaproxima,
    That makes senseโ€”mixing test-related logic into production code with drupal_valid_test_ua() can make the codebase harder to maintain.
    So I'm planning to Introduce a service to determine test mode (TestModeChecker), and will replace drupal_valid_test_ua() calls with service usage.

    Would it be a good solution?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    I don't think that would really solve the problem, to be honest; the idea is to remove any testing-related code from the production code. There are other approaches we can take, but they'll vary based on the specific use. In other words, we're going to need a few different approaches for this one.

    I'll take this on!

Production build 0.71.5 2024