Skip to content

Intermittent error with getTestMode when the Test Mode setting is not described by an environment variable #15

Description

@chrispicyweb

Description

Reporting an intermittent error with getTestMode when the Test Mode setting is not described by an environment variable.

Seems like in some scenarios getTestMode returns null if $parse is true and the App::parseBooleanEnv($this->_testMode) line runs.

Gateway->createGateway() -> $gateway->setTestMode($this->getTestMode())

Error:

craft\commerce\eway\gateways\Gateway::getTestMode(): Return value must be of type string|bool, null returned

Suggestion

This feels like a bandaid, but maybe a fallback for parseBooleanEnv failure would patch this.

$testMode = $parse ? App::parseBooleanEnv($this->_testMode) : $this->_testMode;
return !is_null($testMode) ? $testMode : false;

Steps to reproduce

Hard to reproduce this one. It was noticed in production and seems to be intermittent. We did do a recent composer update, but I can't think of why that would affect this. Apologies for the lack of information here.

  1. Try to Pay
  2. Cry

Additional info

  • Craft version: 4.17.5

  • PHP version: 8.3.9

  • Database driver & version: MySQL 8.0.42

  • Plugins & versions:

    "craftcms/commerce": 4.10.2
    "craftcms/commerce-eway": 4.1.1
    "craftcms/contact-form": 3.1.0
    "craftcms/contact-form-honeypot": 2.1.0
    "craftcms/feed-me": 5.14.0
    "craftcms/redactor": 3.1.0
    "ether/seo": 4.2.4
    "mwikala/linode-s3": 2.0.2
    "sebastianlenz/linkfield": 2.1.5
    "spicyweb/craft-embedded-assets": 4.2.3
    "spicyweb/craft-neo": 4.4.7
    "ttempleton/craft-nocache": 3.1.0
    "verbb/tablemaker": 2.1.5
    "vlucas/phpdotenv": v5.6.3

Thanks!

Activity

  1. linear commented on Feb 26, 2026

    @linear
  2. lukeholder commented on Feb 26, 2026

    @lukeholder
    Member

    Thanks for reporting this. Will take a look and get back to you asap. Thanks!

  3. self-assigned this
    on Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions