Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch the order of null coalescing for the sql_bindings config option #231

Merged
merged 1 commit into from
Apr 23, 2019
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
2 changes: 1 addition & 1 deletion src/Sentry/Laravel/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EventHandler
*/
public function __construct(array $config)
{
$this->recordSqlBindings = ($config['breadcrumbs']['sql_bindings'] ?? $config['breadcrumbs.sql_bindings'] ?? false) === true;
$this->recordSqlBindings = ($config['breadcrumbs.sql_bindings'] ?? $config['breadcrumbs']['sql_bindings'] ?? false) === true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Sentry\Laravel\Tests;

use Sentry\State\Hub;
use Illuminate\Config\Repository;

class SqlBindingsInBreadcrumbsWithOldConfigKeyDisabledTest extends SentryLaravelTestCase
{
protected function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);

$app['config']->set('sentry.dsn', 'http://publickey:secretkey@sentry.dev/123');

$config = $app['config']->all();

$config['sentry']['breadcrumbs.sql_bindings'] = false;

$app['config'] = new Repository($config);
}

public function testIsBound()
{
$this->assertTrue(app()->bound('sentry'));
$this->assertInstanceOf(Hub::class, app('sentry'));
}

/**
* @depends testIsBound
*/
public function testSqlBindingsAreRecordedWhenDisabledByOldConfigKey()
{
$this->assertFalse($this->app['config']->get('sentry')['breadcrumbs.sql_bindings']);

$this->dispatchLaravelEvent('illuminate.query', [
$query = 'SELECT * FROM breadcrumbs WHERE bindings = ?;',
$bindings = ['1'],
10,
'test',
]);

$breadcrumbs = $this->getScope(Hub::getCurrent())->getBreadcrumbs();

/** @var \Sentry\Breadcrumb $lastBreadcrumb */
$lastBreadcrumb = end($breadcrumbs);

$this->assertEquals($query, $lastBreadcrumb->getMessage());
$this->assertFalse(isset($lastBreadcrumb->getMetadata()['bindings']));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Sentry\State\Hub;
use Illuminate\Config\Repository;

class SqlBindingsInBreadcrumbsWithOldConfigKeyTest extends SentryLaravelTestCase
class SqlBindingsInBreadcrumbsWithOldConfigKeyEnabledTest extends SentryLaravelTestCase
{
protected function getEnvironmentSetUp($app)
{
Expand All @@ -17,8 +17,6 @@ protected function getEnvironmentSetUp($app)

$config['sentry']['breadcrumbs.sql_bindings'] = true;

unset($config['sentry']['breadcrumbs']);

$app['config'] = new Repository($config);
}

Expand Down