Skip to content

Commit 0b547c3

Browse files
authored
Merge pull request #112 from rollbar/next/2.6.4
Release 2.6.4
2 parents 6c33742 + f4b40de commit 0b547c3

File tree

7 files changed

+47
-41
lines changed

7 files changed

+47
-41
lines changed

public/js/RollbarWordpressSettings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@
195195
if (php_config.php_logging_enabled) {
196196
logThroughPhp(php_config);
197197
} else {
198-
failNotice("Skipped testing PHP logging since it is disabled.");
198+
successNotice("Skipped testing PHP logging since it is disabled.");
199199
}
200200

201201
if (js_logging_enabled) {
202202
logThroughJs(client_side_access_token, environment, logging_level);
203203
} else {
204-
failNotice("Skipped testing JS logging since it is disabled.");
204+
successNotice("Skipped testing JS logging since it is disabled.");
205205
}
206206

207207
});

readme.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: arturmoczulski
33
Tags: rollbar, full stack, error, tracking, error tracking, error reporting, reporting, debug
44
Requires at least: 3.5.1
55
Tested up to: 5.8.4
6-
Stable tag: 2.6.3
6+
Stable tag: 2.6.4
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

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

106106
== Changelog ==
107107

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

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

216222
== Upgrade Notice ==
217223

224+
= Version 2.6.4 (June 13th 2022) =
225+
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.
226+
218227
= Version 2.6.3 (April 18th 2022) =
219228
* Update the tested WP versions
220229

rollbar-php-wordpress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Rollbar
44
* Plugin URI: https://wordpress.org/plugins/rollbar
55
* Description: Rollbar full-stack error tracking for WordPress
6-
* Version: 2.6.3
6+
* Version: 2.6.4
77
* Author: Rollbar
88
* Author URI: https://rollbar.com
99
* Text Domain: rollbar

src/Defaults.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static function instance()
1919

2020
public function environment()
2121
{
22-
return getenv('WP_ENV') ?: null;
22+
return \Rollbar\Wordpress\Plugin::getEnvironment();
2323
}
2424

2525
public function root()

src/Plugin.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class Plugin {
1111

12-
const VERSION = "2.6.2";
12+
const VERSION = "2.6.4";
1313

1414
private $config;
1515

@@ -52,6 +52,11 @@ public function configure(array $config) {
5252
private function initSettings() {
5353
Settings::init();
5454
}
55+
56+
public static function getEnvironment()
57+
{
58+
return ( getenv('WP_ENV') ?: ( defined( 'WP_ENV' ) ? WP_ENV : null ) );
59+
}
5560

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

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

71-
if ($wpEnv = getenv('WP_ENV')) {
76+
if ($wpEnv = $this->getEnvironment()) {
7277
$options['environment'] = $wpEnv;
7378
}
7479

src/Settings.php

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static function instance()
3030
public static function init() {
3131
$instance = self::instance();
3232
\add_action('admin_menu', array(&$instance, 'addAdminMenu'));
33+
\add_filter('plugin_action_links_'.basename(dirname(__DIR__)).'/rollbar-php-wordpress.php', array(&$instance, 'addAdminMenuLink'));
3334
\add_action('admin_init', array(&$instance, 'addSettings'));
3435
\add_action('admin_enqueue_scripts', function($hook) {
3536

@@ -59,28 +60,6 @@ public static function init() {
5960
Plugin::VERSION
6061
);
6162

62-
\wp_register_script(
63-
'AceEditor',
64-
\plugin_dir_url(__FILE__)."../public/js/ace-builds/src-min-noconflict/ace.js",
65-
array('jquery'),
66-
Plugin::VERSION
67-
);
68-
69-
\wp_localize_script(
70-
'AceEditor',
71-
'AceEditorLocalized',
72-
array(
73-
'plugin_url' => \plugin_dir_url(__FILE__) . "../",
74-
)
75-
);
76-
77-
\wp_enqueue_script(
78-
"AceEditor",
79-
\plugin_dir_url(__FILE__)."../public/js/ace-builds/src-min-noconflict/ace.js",
80-
array("jquery"),
81-
Plugin::VERSION
82-
);
83-
8463
\wp_register_style(
8564
'RollbarWordpressSettings',
8665
\plugin_dir_url(__FILE__)."../public/css/RollbarWordpressSettings.css",
@@ -89,20 +68,11 @@ public static function init() {
8968
);
9069
\wp_enqueue_style('RollbarWordpressSettings');
9170
});
92-
93-
\add_action('init', array(get_called_class(), 'registerSession'));
9471

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

9774
\add_action('pre_update_option_rollbar_wp', array(get_called_class(), 'preUpdate'));
9875
}
99-
100-
public static function registerSession()
101-
{
102-
if( ! session_id() && ! defined( 'DOING_CRON' ) ) {
103-
session_start();
104-
}
105-
}
10676

10777
function addAdminMenu()
10878
{
@@ -116,6 +86,15 @@ function addAdminMenu()
11686
);
11787
}
11888

89+
function addAdminMenuLink($links)
90+
{
91+
$args = array('page' => 'rollbar_wp');
92+
93+
$links['settings'] = '<a href="'.admin_url( 'options-general.php?'.http_build_query( $args ) ).'">'.__('Settings', 'rollbar').'</a>';
94+
95+
return $links;
96+
}
97+
11998
function addSettings()
12099
{
121100
\register_setting(
@@ -372,6 +351,13 @@ public static function flashRedirect($type, $message)
372351

373352
public static function flashMessage($type, $message)
374353
{
354+
// This is only designed to run in the admin for the main HTML request.
355+
// If there is no session at this point something has gone terribly
356+
// wrong, and we should bail out.
357+
if( ! is_admin() || ! session_id() || wp_doing_cron() ) {
358+
return;
359+
}
360+
375361
$_SESSION['rollbar_wp_flash_message'] = array(
376362
"type" => $type,
377363
"message" => $message
@@ -397,14 +383,18 @@ public static function preUpdate($settings)
397383
try {
398384
Plugin::instance()->enableMustUsePlugin();
399385
} catch (\Exception $exception) {
400-
self::flashMessage('error', 'Failed enabling the Must-Use plugin.');
386+
add_action('admin_notices', function () {
387+
echo '<div class="error notice"><p><strong>Error:</strong> failed to enable the Rollbar Must-Use plugin.</p></div>';
388+
});
401389
$settings['enable_must_use_plugin'] = false;
402390
}
403391
} else {
404392
try {
405393
Plugin::instance()->disableMustUsePlugin();
406394
} catch (\Exception $exception) {
407-
self::flashMessage('error', 'Failed disabling the Must-Use plugin.');
395+
add_action('admin_notices', function () {
396+
echo '<div class="error notice"><p><strong>Error:</strong> failed to disable the Rollbar Must-Use plugin.</p></div>';
397+
});
408398
$settings['enable_must_use_plugin'] = true;
409399
}
410400
}

src/UI.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ public static function status($settings)
220220

221221
public static function environmentSettingNote()
222222
{
223+
$env = \Rollbar\Wordpress\Plugin::getEnvironment();
224+
223225
$output =
224-
'<p><code>WP_ENV</code> environment variable: <code> ' . getenv('WP_ENV') . ' </code></p>' .
226+
'<p><code>WP_ENV</code> environment variable: <code>' . $env . '</code></p>' .
225227
'<p><small><strong>Rollbar for Wordpress honors the WP_ENV environment variable.</strong> ' .
226228
'If the <code>environment</code> setting is not specified here, it will take ' .
227229
'precendence over the default value.</strong></small></p>';

0 commit comments

Comments
 (0)