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
7 changes: 7 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ public function buildPHPConfig()
} else if (isset($config[$setting]) && $config[$setting] === 'true') {
$config[$setting] = true;
}

// also handle 1 and 0 as booleans
else if (isset($config[$setting]) && $config[$setting] === '0') {
$config[$setting] = false;
} else if (isset($config[$setting]) && $config[$setting] === '1') {
$config[$setting] = true;
}
}

return $config;
Expand Down
16 changes: 16 additions & 0 deletions tests/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ public function testLoggingLevel(
}

}

/**
* Tests to ensure bools are properly converted from "1" and "0" strings
*
* @ticket https://github.com/rollbar/rollbar-php-wordpress/issues/119
*/
public function testSendMessageTraceBool(){
$plugin = $this->subject;

$plugin->setting( 'send_message_trace', '1' );
$plugin->setting( 'report_suppressed', '0' );
$data = $plugin->buildPHPConfig();

$this->assertTrue( $data['send_message_trace'] );
$this->assertFalse( $data['report_suppressed'] );
}

public static function loggingLevelTestDataProvider()
{
Expand Down