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

Added checker for _convertPath if the path is file #500

Merged
merged 5 commits into from Oct 29, 2017
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
18 changes: 15 additions & 3 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ private static function _convertPath($value)
// we need app_path to have a trailing slash otherwise
// base path detection becomes complex if the same
// prefix is matched
if (substr($path, 0, 1) === DIRECTORY_SEPARATOR && substr($path, -1) !== DIRECTORY_SEPARATOR) {
$path = $path.DIRECTORY_SEPARATOR;
if ($path{0} === DIRECTORY_SEPARATOR && substr($path, -1) !== DIRECTORY_SEPARATOR) {
$path .= DIRECTORY_SEPARATOR;
}
return $path;
}
Expand All @@ -313,7 +313,19 @@ public function getExcludedAppPaths()

public function setExcludedAppPaths($value)
{
$this->excluded_app_paths = $value ? array_map(array($this, '_convertPath'), $value) : null;
if ($value) {
$excluded_app_paths = array();

// We should be able to exclude a php files
foreach ((array) $value as $path) {
$excluded_app_paths[] = substr($path, -4) !== '.php' ? self::_convertPath($path) : $path;
}
} else {
$excluded_app_paths = null;
}

$this->excluded_app_paths = $excluded_app_paths;

return $this;
}

Expand Down
6 changes: 3 additions & 3 deletions test/Raven/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1455,10 +1455,10 @@ public function testGettersAndSetters()
array('app_path', null, 'value', $property_method__convert_path->invoke($client, 'value')),
array('app_path', null, null, ),
array('app_path', null, false, null, ),
array('excluded_app_paths', null, array('value'),
array($property_method__convert_path->invoke($client, 'value'))),
array('excluded_app_paths', null, array(), null),
array('excluded_app_paths', null, null),
array('excluded_app_paths', null, array(), null),
array('excluded_app_paths', null, array(__FILE__), array(__FILE__)),
array('excluded_app_paths', null, array(__DIR__), array(__DIR__ . DIRECTORY_SEPARATOR)),
array('prefixes', null, array('value'), array($property_method__convert_path->invoke($client, 'value'))),
array('prefixes', null, array()),
array('send_callback', null, $callable),
Expand Down
10 changes: 8 additions & 2 deletions test/Raven/Tests/StacktraceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,21 @@ public function testInAppWithExclusion()
"line" => 3,
"function" => "include_once",
),
array(
"file" => dirname(__FILE__) . '/resources/foo/c.php',
"line" => 3,
"function" => "include_once",
)
);

$frames = Raven_Stacktrace::get_stack_info(
$stack, true, null, 0, null, dirname(__FILE__) . '/',
array(dirname(__FILE__) . '/resources/bar/'));
array(dirname(__FILE__) . '/resources/bar/', dirname(__FILE__) . '/resources/foo/c.php'));

// stack gets reversed
$this->assertEquals($frames[0]['in_app'], false);
$this->assertEquals($frames[1]['in_app'], true);
$this->assertEquals($frames[1]['in_app'], false);
$this->assertEquals($frames[2]['in_app'], true);
}

public function testBasePath()
Expand Down