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

ROLLBAR_ACCESS_TOKEN cannot be set programmatically #72

Closed
rkaiser0324 opened this issue Jan 24, 2019 · 2 comments
Closed

ROLLBAR_ACCESS_TOKEN cannot be set programmatically #72

rkaiser0324 opened this issue Jan 24, 2019 · 2 comments
Assignees

Comments

@rkaiser0324
Copy link

Might be related to, or a dupe of, #41. Looks like this is either a bug in the way the plugin uses the Rollbar PHP library.

In vendor\rollbar\rollbar\src\Config.php::setAccessToken() you have

      if (isset($_ENV['ROLLBAR_ACCESS_TOKEN']) && !isset($config['access_token'])) {
            $config['access_token'] = $_ENV['ROLLBAR_ACCESS_TOKEN'];
        }

but in practice, $config['access_token'] is always set by the plugin, although it might be "". Thus you're unable to use $_ENV to set the token.

You can change this to

      if (!empty($_ENV['ROLLBAR_ACCESS_TOKEN'])) {
            $config['access_token'] = $_ENV['ROLLBAR_ACCESS_TOKEN'];
        }

but it might be safer to change the logic upstream in the plugin. I would also note that a more common WordPress pattern is to define strings like these in wp-config.php, rather than using $_ENV, so having the plugin support something like

define('ROLLBAR_ACCESS_TOKEN', '...');

would be ideal.

@jessewgibbs
Copy link

@rkaiser0324 thanks for bringing this to our attention.

@ArturMoczulski can you investigate when you get a chance?

@ArturMoczulski
Copy link

ArturMoczulski commented Feb 5, 2019

This has been implemented in master and released in 2.4.10

The plugin should respect both ROLLBAR_ACCESS_TOKEN environment variable and a constant with the same name.

The docs have been updated: https://docs.rollbar.com/docs/wordpress#section-setting-the-access-token-in-your-source-code-or-server-configuration

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

3 participants