craftcms / craftcms/cms

[5.x]: Cannot use env vars for plugin licenses

Open
#18,186 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

When trying to store env variables in the plugin licenses, craft seems to just revert them back to the plain text value whenever we run project config apply.

Happy to send a video over to an email for evidence, though this has been reported internally as being really sporadic.

Update:
I have actually just noticed, it looks like something is writing to my .env file? If I use $license as the env var in the CMS, it then adds that env var to the file. Though I would've thought if the env var already exists and the license key is set to use it in the project config, it wouldn't matter.

Steps to reproduce
  1. Save an env variable in a plugin license
  2. Craft shows that there are pending project config changes
  3. Run pc/apply
  4. Plugin license now shows plain text key instead of env var
Expected behavior
Actual behavior
Craft CMS version

5.7.0

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with a plugin license, an existing environment variable in .env, and pc/apply. Trace how project config apply reads and writes the license value and .env; done means the configured environment-variable reference remains intact after applying project config instead of becoming plaintext.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.