diff --git a/lib/Raven/Client.php b/lib/Raven/Client.php index 5b37844d9..ea579147c 100644 --- a/lib/Raven/Client.php +++ b/lib/Raven/Client.php @@ -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; } @@ -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; } diff --git a/test/Raven/Tests/ClientTest.php b/test/Raven/Tests/ClientTest.php index 5bea1321e..efdeddf26 100644 --- a/test/Raven/Tests/ClientTest.php +++ b/test/Raven/Tests/ClientTest.php @@ -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), diff --git a/test/Raven/Tests/StacktraceTest.php b/test/Raven/Tests/StacktraceTest.php index ed7b9f793..63b593e7b 100644 --- a/test/Raven/Tests/StacktraceTest.php +++ b/test/Raven/Tests/StacktraceTest.php @@ -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()