Skip to content

Commit

Permalink
Merge pull request #112 from rollbar/next/2.6.4
Browse files Browse the repository at this point in the history
Release 2.6.4
  • Loading branch information
danielmorell authored Jun 21, 2022
2 parents 6c33742 + f4b40de commit 0b547c3
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 41 deletions.
4 changes: 2 additions & 2 deletions public/js/RollbarWordpressSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@
if (php_config.php_logging_enabled) {
logThroughPhp(php_config);
} else {
failNotice("Skipped testing PHP logging since it is disabled.");
successNotice("Skipped testing PHP logging since it is disabled.");
}

if (js_logging_enabled) {
logThroughJs(client_side_access_token, environment, logging_level);
} else {
failNotice("Skipped testing JS logging since it is disabled.");
successNotice("Skipped testing JS logging since it is disabled.");
}

});
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: arturmoczulski
Tags: rollbar, full stack, error, tracking, error tracking, error reporting, reporting, debug
Requires at least: 3.5.1
Tested up to: 5.8.4
Stable tag: 2.6.3
Stable tag: 2.6.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -105,6 +105,12 @@ Yes. It's actually the recommended method of installation.

== Changelog ==

= Version 2.6.4 (June 13th 2022) =
* Updated admin test results to show a skipped test as a success (https://github.com/rollbar/rollbar-php-wordpress/pull/110)
* Fixed new session being created on every request (https://github.com/rollbar/rollbar-php-wordpress/pull/111)
* Added search for WP_ENV as a constant or the environment (https://github.com/rollbar/rollbar-php-wordpress/pull/108)
* Added a link to settings from the plugins page (https://github.com/rollbar/rollbar-php-wordpress/pull/109)

= Version 2.6.3 (April 18th 2022) =
* Update the tested WP versions

Expand Down Expand Up @@ -215,6 +221,9 @@ Yes. It's actually the recommended method of installation.

== Upgrade Notice ==

= Version 2.6.4 (June 13th 2022) =
Updated admin test results to show a skipped test as a success. Fixed new session being created on every request. Added search for WP_ENV as a constant or the environment. Added a link to settings from the plugins page.

= Version 2.6.3 (April 18th 2022) =
* Update the tested WP versions

Expand Down
2 changes: 1 addition & 1 deletion rollbar-php-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Rollbar
* Plugin URI: https://wordpress.org/plugins/rollbar
* Description: Rollbar full-stack error tracking for WordPress
* Version: 2.6.3
* Version: 2.6.4
* Author: Rollbar
* Author URI: https://rollbar.com
* Text Domain: rollbar
Expand Down
2 changes: 1 addition & 1 deletion src/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function instance()

public function environment()
{
return getenv('WP_ENV') ?: null;
return \Rollbar\Wordpress\Plugin::getEnvironment();
}

public function root()
Expand Down
9 changes: 7 additions & 2 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Plugin {

const VERSION = "2.6.2";
const VERSION = "2.6.4";

private $config;

Expand Down Expand Up @@ -52,6 +52,11 @@ public function configure(array $config) {
private function initSettings() {
Settings::init();
}

public static function getEnvironment()
{
return ( getenv('WP_ENV') ?: ( defined( 'WP_ENV' ) ? WP_ENV : null ) );
}

/**
* Fetch settings provided in Admin -> Tools -> Rollbar
Expand All @@ -68,7 +73,7 @@ private function fetchSettings() {

if (!isset($options['environment']) || empty($options['environment'])) {

if ($wpEnv = getenv('WP_ENV')) {
if ($wpEnv = $this->getEnvironment()) {
$options['environment'] = $wpEnv;
}

Expand Down
56 changes: 23 additions & 33 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function instance()
public static function init() {
$instance = self::instance();
\add_action('admin_menu', array(&$instance, 'addAdminMenu'));
\add_filter('plugin_action_links_'.basename(dirname(__DIR__)).'/rollbar-php-wordpress.php', array(&$instance, 'addAdminMenuLink'));
\add_action('admin_init', array(&$instance, 'addSettings'));
\add_action('admin_enqueue_scripts', function($hook) {

Expand Down Expand Up @@ -59,28 +60,6 @@ public static function init() {
Plugin::VERSION
);

\wp_register_script(
'AceEditor',
\plugin_dir_url(__FILE__)."../public/js/ace-builds/src-min-noconflict/ace.js",
array('jquery'),
Plugin::VERSION
);

\wp_localize_script(
'AceEditor',
'AceEditorLocalized',
array(
'plugin_url' => \plugin_dir_url(__FILE__) . "../",
)
);

\wp_enqueue_script(
"AceEditor",
\plugin_dir_url(__FILE__)."../public/js/ace-builds/src-min-noconflict/ace.js",
array("jquery"),
Plugin::VERSION
);

\wp_register_style(
'RollbarWordpressSettings',
\plugin_dir_url(__FILE__)."../public/css/RollbarWordpressSettings.css",
Expand All @@ -89,20 +68,11 @@ public static function init() {
);
\wp_enqueue_style('RollbarWordpressSettings');
});

\add_action('init', array(get_called_class(), 'registerSession'));

\add_action('admin_post_rollbar_wp_restore_defaults', array(get_called_class(), 'restoreDefaultsAction'));

\add_action('pre_update_option_rollbar_wp', array(get_called_class(), 'preUpdate'));
}

public static function registerSession()
{
if( ! session_id() && ! defined( 'DOING_CRON' ) ) {
session_start();
}
}

function addAdminMenu()
{
Expand All @@ -116,6 +86,15 @@ function addAdminMenu()
);
}

function addAdminMenuLink($links)
{
$args = array('page' => 'rollbar_wp');

$links['settings'] = '<a href="'.admin_url( 'options-general.php?'.http_build_query( $args ) ).'">'.__('Settings', 'rollbar').'</a>';

return $links;
}

function addSettings()
{
\register_setting(
Expand Down Expand Up @@ -372,6 +351,13 @@ public static function flashRedirect($type, $message)

public static function flashMessage($type, $message)
{
// This is only designed to run in the admin for the main HTML request.
// If there is no session at this point something has gone terribly
// wrong, and we should bail out.
if( ! is_admin() || ! session_id() || wp_doing_cron() ) {
return;
}

$_SESSION['rollbar_wp_flash_message'] = array(
"type" => $type,
"message" => $message
Expand All @@ -397,14 +383,18 @@ public static function preUpdate($settings)
try {
Plugin::instance()->enableMustUsePlugin();
} catch (\Exception $exception) {
self::flashMessage('error', 'Failed enabling the Must-Use plugin.');
add_action('admin_notices', function () {
echo '<div class="error notice"><p><strong>Error:</strong> failed to enable the Rollbar Must-Use plugin.</p></div>';
});
$settings['enable_must_use_plugin'] = false;
}
} else {
try {
Plugin::instance()->disableMustUsePlugin();
} catch (\Exception $exception) {
self::flashMessage('error', 'Failed disabling the Must-Use plugin.');
add_action('admin_notices', function () {
echo '<div class="error notice"><p><strong>Error:</strong> failed to disable the Rollbar Must-Use plugin.</p></div>';
});
$settings['enable_must_use_plugin'] = true;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/UI.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ public static function status($settings)

public static function environmentSettingNote()
{
$env = \Rollbar\Wordpress\Plugin::getEnvironment();

$output =
'<p><code>WP_ENV</code> environment variable: <code> ' . getenv('WP_ENV') . ' </code></p>' .
'<p><code>WP_ENV</code> environment variable: <code>' . $env . '</code></p>' .
'<p><small><strong>Rollbar for Wordpress honors the WP_ENV environment variable.</strong> ' .
'If the <code>environment</code> setting is not specified here, it will take ' .
'precendence over the default value.</strong></small></p>';
Expand Down

0 comments on commit 0b547c3

Please sign in to comment.