Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ its dependencies are managed by Composer.

You can install the plugin by running the following command in the root directory of your WordPress project:

```txt
```
composer require rollbar/rollbar-php-wordpress:^3.0
```

Expand All @@ -85,7 +85,7 @@ collisions if other plugins or your project use different versions of the same d
To install the plugin from wpackagist.org run the following steps command in the root directory of your WordPress
project:

```txt
```
composer require wpackagist-plugin/rollbar
```

Expand Down Expand Up @@ -150,7 +150,10 @@ using composer.

== Changelog ==

= Version 3.0.0 (pending)
= Version 3.1.0 (?) =
* Fixed settings values not being saved correctly when they match the default.

= Version 3.0.0 (October 17 2025) =
* Fixed CSRF vulnerability.
* Removed support for PHP 8.0 and below.
* Updated and improved the settings page.
Expand All @@ -168,10 +171,10 @@ using composer.
* Added `rollbar_telemetry_custom_handlers` filter to allow custom control over what is logged in telemetry messages.
* Added 'framework' details with the WordPress version to the item payload.

= Version 2.7.1 (September 13 2023)
= Version 2.7.1 (September 13 2023) =
* Fix issue that could lead to fatal error with some settings (https://github.com/rollbar/rollbar-php-wordpress/pull/120)

= Version 2.7.0 (September 11 2023)
= Version 2.7.0 (September 11 2023) =
* Updated PHP Dependencies including loading seperate dependencies for PHP7 and PHP8. (https://github.com/rollbar/rollbar-php-wordpress/pull/114)
* Updated node development dependencies (https://github.com/rollbar/rollbar-php-wordpress/pull/115)

Expand Down
1 change: 1 addition & 0 deletions src/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct(
readonly public array $options = [],
readonly public string $section = 'rollbar_wp_advanced',
readonly public array $inputArgs = [],
readonly public bool $alwaysSave = false,
) {
$this->input = $this->createInput();
}
Expand Down
19 changes: 15 additions & 4 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,28 @@ public static function settings(): array
type: SettingType::Boolean,
default: false,
section: 'rollbar_wp_general',
alwaysSave: true,
),
'server_side_access_token' => new Setting(
id: 'server_side_access_token',
type: SettingType::Text,
default: '',
section: 'rollbar_wp_general',
alwaysSave: true,
),
'js_logging_enabled' => new Setting(
id: 'js_logging_enabled',
type: SettingType::Boolean,
default: false,
section: 'rollbar_wp_general',
alwaysSave: true,
),
'client_side_access_token' => new Setting(
id: 'client_side_access_token',
type: SettingType::Text,
default: '',
section: 'rollbar_wp_general',
alwaysSave: true,
),
'environment' => new Setting(
id: 'environment',
Expand All @@ -108,6 +112,7 @@ public static function settings(): array
'precendence over the default value.</strong></p>',
default: 'production',
section: 'rollbar_wp_general',
alwaysSave: true,
),
'included_errno' => new Setting(
id: 'included_errno',
Expand All @@ -127,6 +132,7 @@ public static function settings(): array
E_ALL => 'Absolutely everything (E_ALL)',
],
section: 'rollbar_wp_general',
alwaysSave: true,
),
'agent_log_location' => new Setting(
id: 'agent_log_location',
Expand Down Expand Up @@ -450,6 +456,11 @@ public static function preUpdate(array $settings): array

// Don't store default values in the database, so future updates to default values in the SDK get propagated.
foreach ($settings as $setting_name => $setting_value) {
// Always save settings that are marked as alwaysSave.
$settingConfig = self::settings()[$setting_name] ?? null;
if (null !== $settingConfig && $settingConfig->alwaysSave) {
continue;
}
// Loose comparison to allow for boolean values to be set to 0 or 1 and integers to be strings, which is how
// they are posted via HTTP.
if ($setting_value == Plugin::getInstance()->settingsInstance()->getDefaultOption($setting_name)) {
Expand Down Expand Up @@ -501,15 +512,15 @@ public function set(string $name, mixed $value): void
*/
public function saveSettings(array $settings): void
{
$option = get_option('rollbar_wp');
$option = get_option(self::OPTIONS_KEY);

$option = array_merge($option, $settings);

foreach ($settings as $setting => $value) {
$this->settings[$setting] = $value;
}

update_option('rollbar_wp', $option);
update_option(self::OPTIONS_KEY, $option);
}

/**
Expand Down Expand Up @@ -678,8 +689,8 @@ public static function normalizeSettings(array $options): array
$options = array_intersect_key($options, array_flip(self::listOptions()));

foreach (self::settings() as $key => $setting) {
// 'access_token' and 'enabled' are different in WordPress plugin
// look for 'server_side_access_token' and 'php_logging_enabled' above
// 'access_token' and 'enabled' are different in the WordPress plugin look for 'server_side_access_token'
// and 'php_logging_enabled' above.
if (in_array($key, ['access_token', 'enabled'])) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions tests/SettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function testConstruct()
self::assertSame('Foo', $setting->label);
self::assertSame('Foo help text', $setting->helpText);
self::assertSame(1, $setting->default);
self::assertSame(false, $setting->alwaysSave);
}

public function testGetTitle(): void
Expand Down
10 changes: 9 additions & 1 deletion tests/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ public static function preUpdateProvider(): array
{
return [
[
'expected' => [],
'expected' => [
'php_logging_enabled' => false,
'js_logging_enabled' => false,
],
'data' => [
'allow_exec' => true,
'capture_error_stacktraces' => true,
Expand All @@ -210,6 +213,7 @@ public static function preUpdateProvider(): array
[
'expected' => [
'php_logging_enabled' => true,
'js_logging_enabled' => false,
'enabled' => true,
],
'data' => [
Expand All @@ -226,6 +230,8 @@ public static function preUpdateProvider(): array
[
'expected' => [
'allow_exec' => false,
'php_logging_enabled' => false,
'js_logging_enabled' => false,
],
'data' => [
'allow_exec' => false,
Expand All @@ -240,6 +246,8 @@ public static function preUpdateProvider(): array
[
'expected' => [
'use_error_reporting' => true,
'php_logging_enabled' => false,
'js_logging_enabled' => false,
],
'data' => [
'use_error_reporting' => true,
Expand Down