Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown error when a plugin license environment variable is an empty string #4604

Closed
rungta opened this issue Jul 18, 2019 · 3 comments
Closed

Comments

@rungta
Copy link

rungta commented Jul 18, 2019

Description

When I make use of environment variables to keep plugin license keys out of the project config, I’m getting an “Unknown Error” if the environment variable is set to an empty string (as intended in the dev & staging environments, where Craft is running in trial mode). E.g.

Screen Shot 2019-07-18 at 4 11 22 PM

Related issue: https://github.com/pixelandtonic/craftnet/issues/162

Steps to reproduce

  1. Install a paid plugin (e.g. Craft Dynamic Fields)
  2. Add an environment variable to its license field (e.g. $LICENSE_DYNAMIC_FIELDS)
  3. Set the value of the environment variable to an empty string in your .env (e.g. LICENSE_DYNAMIC_FIELDS="")

Additional info

  • Craft version: 3.2.2
  • PHP version: 7.1
@brandonkelly
Copy link
Member

I’m not able to reproduce this; I just get a “Your license key is invalid.” error below the license input, which is expected. That happens whether I’ve set the environment variable to an empty string or if I just haven’t even set it yet.

Try clearing out your storage/logs/ folder, then reproduce the error, then search storage/logs/web.log for [error]. Please post the full error details + stack trace. That should help explain what’s going on.

(as intended in the dev & staging environments, where Craft is running in trial mode)

You shouldn’t have any issues using the same plugin license keys across all of your environments, as long as the config/license.key file has the same Craft license key that the plugin licenses are associated with.

@rungta
Copy link
Author

rungta commented Jul 19, 2019

Here’s the stack trace:

2019-07-19 23:22:48 [-][1][-][error][craft\errors\InvalidLicenseKeyException] craft\errors\InvalidLicenseKeyException: The license key “” is invalid. in .../vendor/craftcms/cms/src/services/Plugins.php:1172
Stack trace:
#0 .../vendor/craftcms/cms/src/services/Plugins.php(1113): craft\services\Plugins->normalizePluginLicenseKey('')
craftcms/craftnet-legacy#1 .../vendor/craftcms/cms/src/services/Api.php(489): craft\services\Plugins->getPluginLicenseKey('craft-dynamic-f...')
craftcms/craftnet-legacy#2 .../vendor/craftcms/cms/src/services/Api.php(339): craft\services\Api->headers()
craftcms/craftnet-legacy#3 .../vendor/craftcms/cms/src/services/Api.php(70): craft\services\Api->request('GET', 'cms-licenses', Array)
craftcms/craftnet-legacy#4 .../vendor/craftcms/cms/src/controllers/AppController.php(431): craft\services\Api->getLicenseInfo(Array)
craftcms/craftnet-legacy#5 .../vendor/craftcms/cms/src/controllers/AppController.php(349): craft\controllers\AppController->_pluginLicenseInfo()
craftcms/craftnet-legacy#6 [internal function]: craft\controllers\AppController->actionGetPluginLicenseInfo()
craftcms/craftnet-legacy#7 .../vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
craftcms/craftnet-legacy#8 .../vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
craftcms/craftnet-legacy#9 .../vendor/craftcms/cms/src/web/Controller.php(187): yii\base\Controller->runAction('get-plugin-lice...', Array)
craftcms/craftnet-legacy#10 .../vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('get-plugin-lice...', Array)
craftcms/craftnet-legacy#11 .../vendor/craftcms/cms/src/web/Application.php(298): yii\base\Module->runAction('app/get-plugin-...', Array)
craftcms/craftnet-legacy#12 .../vendor/craftcms/cms/src/web/Application.php(565): craft\web\Application->runAction('app/get-plugin-...', Array)
craftcms/craftnet-legacy#13 .../vendor/craftcms/cms/src/web/Application.php(277): craft\web\Application->_processActionRequest(Object(craft\web\Request))
craftcms/craftnet-legacy#14 .../vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
craftcms/craftnet-legacy#15 .../web/index.php(21): yii\base\Application->run()
craftcms/craftnet-legacy#16 {main}

@brandonkelly
Copy link
Member

Thanks, able to reproduce this now. I think maybe yesterday I accidentally added $TEST_LICENSE_KEY="" to .env, instead of TEST_LICENSE_KEY="".

Just fixed for the next release. But again, you shouldn't need to set license key environment variables to empty strings in the first place :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants