Skip to content

ROLLBAR_ACCESS_TOKEN cannot be set programmatically #72

@rkaiser0324

Description

@rkaiser0324

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions