Skip to content

[4.x]: .env variable normalization of float instead of string results in truncation #15533

@engram-design

Description

@engram-design

What happened?

Description

We have an issue where we want to store a Client ID for OAuth for Slack as an .env variable. This looks like: 2833563543.1341693581393.

The problem is that when this is parsed as an .env variable the value is truncated:

// .env
SLACK_CLIENT_ID="2833563543.1341693581393"

// php
App::parseEnv('$SLACK_CLIENT_ID');

// produces
2833563543.1342

It seems this is due to the normalization of variables, and it thinks that this is a float, where it's a string.

Could some more smarts be added to check if this should be an int/float by checking if the length of the source string and the target int/float are the same before assuming things?

Craft CMS version

4.11.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions