diff --git a/wp-content/plugins/getsentry-client/composer.json b/wp-content/plugins/getsentry-client/composer.json deleted file mode 100644 index afa0101..0000000 --- a/wp-content/plugins/getsentry-client/composer.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "ryanbagwell/wordpress-sentry", - "description": "A plugin that sends error messages to the Sentry error logging system.", - "license": "GPLv2 or later", - "authors": [ - { - "name": "Ryan Bagwell", - "email": "ryan@ryanbagwell.com" - } - ], - "require": { - "raven/raven": "0.10.0" - } -} diff --git a/wp-content/plugins/getsentry-client/raven/.gitignore b/wp-content/plugins/getsentry-client/raven/.gitignore new file mode 100644 index 0000000..25fe3e9 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/.gitignore @@ -0,0 +1,6 @@ +*.lock +package.xml +/vendor +.idea +.php_cs.cache +docs/_build diff --git a/wp-content/plugins/getsentry-client/raven/.gitmodules b/wp-content/plugins/getsentry-client/raven/.gitmodules new file mode 100644 index 0000000..1e6464a --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/.gitmodules @@ -0,0 +1,3 @@ +[submodule "docs/_sentryext"] + path = docs/_sentryext + url = https://github.com/getsentry/sentry-doc-support diff --git a/wp-content/plugins/getsentry-client/raven/.php_cs b/wp-content/plugins/getsentry-client/raven/.php_cs new file mode 100644 index 0000000..790c396 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/.php_cs @@ -0,0 +1,12 @@ +in(__DIR__) +; + +return Symfony\CS\Config\Config::create() + ->setUsingCache(true) + ->setUsingLinter(true) + ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->finder($finder) +; diff --git a/wp-content/plugins/getsentry-client/raven/.travis.yml b/wp-content/plugins/getsentry-client/raven/.travis.yml new file mode 100644 index 0000000..8182db2 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/.travis.yml @@ -0,0 +1,30 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm + +matrix: + allow_failures: + - php: hhvm + - php: 7.0 + fast_finish: true + +sudo: false + +cache: + directories: + - $HOME/.composer/cache + +before_install: + - composer self-update + +install: travis_retry composer install --no-interaction --prefer-source + +script: + - vendor/bin/php-cs-fixer fix --config-file=.php_cs --verbose --diff --dry-run + - vendor/bin/phpunit diff --git a/wp-content/plugins/getsentry-client/raven/bin/raven b/wp-content/plugins/getsentry-client/raven/bin/sentry old mode 100644 new mode 100755 similarity index 90% rename from wp-content/plugins/getsentry-client/raven/bin/raven rename to wp-content/plugins/getsentry-client/raven/bin/sentry index 4de2519..fddc0a8 --- a/wp-content/plugins/getsentry-client/raven/bin/raven +++ b/wp-content/plugins/getsentry-client/raven/bin/sentry @@ -1,4 +1,4 @@ -#!/usr/bin/php +#!/usr/bin/env php true, 'curl_method' => 'sync', + 'app_path' => realpath(__DIR__ . '/..'), + 'base_path' => realpath(__DIR__ . '/..'), )); $config = get_object_vars($client); - $required_keys = array('servers', 'project', 'public_key', 'secret_key'); + $required_keys = array('server', 'project', 'public_key', 'secret_key'); echo "Client configuration:\n"; foreach ($required_keys as $key) { diff --git a/wp-content/plugins/getsentry-client/raven/lib/Raven/Breadcrumbs.php b/wp-content/plugins/getsentry-client/raven/lib/Raven/Breadcrumbs.php new file mode 100644 index 0000000..a07e900 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/lib/Raven/Breadcrumbs.php @@ -0,0 +1,61 @@ +count = 0; + $this->pos = 0; + $this->size = $size; + $this->buffer = array(); + } + + public function record($crumb) + { + if (empty($crumb['timestamp'])) { + $crumb['timestamp'] = microtime(true); + } + $this->buffer[$this->pos] = $crumb; + $this->pos = ($this->pos + 1) % $this->size; + $this->count++; + } + + public function fetch() + { + $results = array(); + for ($i = 0; $i <= ($this->size - 1); $i++) { + $node = @$this->buffer[($this->pos + $i) % $this->size]; + + if (isset($node)) { + $results[] = $node; + } + } + return $results; + } + + public function is_empty() + { + return $this->count === 0; + } + + public function to_json() + { + return array( + 'values' => $this->fetch(), + ); + } +} diff --git a/wp-content/plugins/getsentry-client/raven/lib/Raven/Breadcrumbs/MonologHandler.php b/wp-content/plugins/getsentry-client/raven/lib/Raven/Breadcrumbs/MonologHandler.php new file mode 100644 index 0000000..2f58116 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/lib/Raven/Breadcrumbs/MonologHandler.php @@ -0,0 +1,94 @@ + Raven_Client::DEBUG, + Logger::INFO => Raven_Client::INFO, + Logger::NOTICE => Raven_Client::INFO, + Logger::WARNING => Raven_Client::WARNING, + Logger::ERROR => Raven_Client::ERROR, + Logger::CRITICAL => Raven_Client::FATAL, + Logger::ALERT => Raven_Client::FATAL, + Logger::EMERGENCY => Raven_Client::FATAL, + ); + + private $excMatch = '/^exception \'([^\']+)\' with message \'(.+)\' in .+$/s'; + + /** + * @var Raven_Client the client object that sends the message to the server + */ + protected $ravenClient; + + /** + * @param Raven_Client $ravenClient + * @param int $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(Raven_Client $ravenClient, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + + $this->ravenClient = $ravenClient; + } + + protected function parseException($message) + { + if (!preg_match($this->excMatch, $message, $matches)) { + return; + } + + return array($matches[1], $matches[2]); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + // sentry uses the 'nobreadcrumb' attribute to skip reporting + if (!empty($record['context']['nobreadcrumb'])) { + return; + } + + if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { + $exc = $record['context']['exception']; + $crumb = array( + 'type' => 'error', + 'level' => $this->logLevels[$record['level']], + 'category' => $record['channel'], + 'data' => array( + 'type' => get_class($exc), + 'value' => $exc->getMessage(), + ), + ); + } else { + // TODO(dcramer): parse exceptions out of messages and format as above + if ($error = $this->parseException($record['message'])) { + $crumb = array( + 'type' => 'error', + 'level' => $this->logLevels[$record['level']], + 'category' => $record['channel'], + 'data' => array( + 'type' => $error[0], + 'value' => $error[1], + ), + ); + } else { + $crumb = array( + 'level' => $this->logLevels[$record['level']], + 'category' => $record['channel'], + 'message' => $record['message'], + ); + } + } + + $this->ravenClient->breadcrumbs->record($crumb); + } +} diff --git a/wp-content/plugins/getsentry-client/raven/lib/Raven/ReprSerializer.php b/wp-content/plugins/getsentry-client/raven/lib/Raven/ReprSerializer.php new file mode 100644 index 0000000..579b53b --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/lib/Raven/ReprSerializer.php @@ -0,0 +1,47 @@ + -./lib/Raven/ - \ No newline at end of file + diff --git a/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/Breadcrumbs/MonologTest.php b/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/Breadcrumbs/MonologTest.php new file mode 100644 index 0000000..f536985 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/Breadcrumbs/MonologTest.php @@ -0,0 +1,68 @@ +run(Object(Illuminate\Http\Request)) +#3 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(5053): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) +#4 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(715): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) +#5 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(696): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request)) +#6 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(7825): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true) +#7 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(8432): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true) +#8 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(8379): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true) +#9 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(11123): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true) +#10 /sentry-laravel/examples/laravel-4.2/bootstrap/compiled.php(657): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request)) +#11 /sentry-laravel/examples/laravel-4.2/public/index.php(49): Illuminate\Foundation\Application->run() +#12 /sentry-laravel/examples/laravel-4.2/server.php(19): require_once('/Users/dcramer/...') +#13 {main} +EOF; + } + + public function testSimple() + { + $client = new \Raven_Client(); + $handler = new \Raven_Breadcrumbs_MonologHandler($client); + + $logger = new Monolog\Logger('sentry'); + $logger->pushHandler($handler); + $logger->addWarning('Foo'); + + $crumbs = $client->breadcrumbs->fetch(); + $this->assertEquals(count($crumbs), 1); + $this->assertEquals($crumbs[0]['message'], 'Foo'); + $this->assertEquals($crumbs[0]['category'], 'sentry'); + $this->assertEquals($crumbs[0]['level'], 'warning'); + } + + public function testErrorInMessage() + { + $client = new \Raven_Client(); + $handler = new \Raven_Breadcrumbs_MonologHandler($client); + + $logger = new Monolog\Logger('sentry'); + $logger->pushHandler($handler); + $logger->addError($this->getSampleErrorMessage()); + + $crumbs = $client->breadcrumbs->fetch(); + $this->assertEquals(count($crumbs), 1); + $this->assertEquals($crumbs[0]['data']['type'], 'Exception'); + $this->assertEquals($crumbs[0]['data']['value'], 'An unhandled exception'); + $this->assertEquals($crumbs[0]['category'], 'sentry'); + $this->assertEquals($crumbs[0]['level'], 'error'); + } +} diff --git a/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/BreadcrumbsTest.php b/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/BreadcrumbsTest.php new file mode 100644 index 0000000..5046459 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/BreadcrumbsTest.php @@ -0,0 +1,38 @@ +record(array('message' => $i)); + } + + $results = $breadcrumbs->fetch(); + + $this->assertEquals(count($results), 10); + for ($i = 1; $i <= 10; $i++) { + $this->assertEquals($results[$i - 1]['message'], $i); + } + } + + public function testJson() + { + $breadcrumbs = new Raven_Breadcrumbs(1); + $breadcrumbs->record(array('message' => 'test')); + $json = $breadcrumbs->to_json(); + + $this->assertEquals(count($json['values']), 1); + $this->assertEquals($json['values'][0]['message'], 'test'); + } +} diff --git a/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/ReprSerializerTest.php b/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/ReprSerializerTest.php new file mode 100644 index 0000000..dc8ed52 --- /dev/null +++ b/wp-content/plugins/getsentry-client/raven/test/Raven/Tests/ReprSerializerTest.php @@ -0,0 +1,79 @@ +serialize($input); + $this->assertEquals(array('1', '2', '3'), $result); + } + + public function testObjectsAreStrings() + { + $serializer = new Raven_ReprSerializer(); + $input = new Raven_StacktraceTestObject(); + $result = $serializer->serialize($input); + $this->assertEquals('Object Raven_StacktraceTestObject', $result); + } + + public function testIntsAreInts() + { + $serializer = new Raven_ReprSerializer(); + $input = 1; + $result = $serializer->serialize($input); + $this->assertTrue(is_string($result)); + $this->assertEquals(1, $result); + } + + public function testFloats() + { + $serializer = new Raven_ReprSerializer(); + $input = 1.5; + $result = $serializer->serialize($input); + $this->assertTrue(is_string($result)); + $this->assertEquals('1.5', $result); + } + + public function testBooleans() + { + $serializer = new Raven_ReprSerializer(); + $input = true; + $result = $serializer->serialize($input); + $this->assertTrue(is_string($result)); + $this->assertEquals('true', $result); + + $input = false; + $result = $serializer->serialize($input); + $this->assertTrue(is_string($result)); + $this->assertEquals('false', $result); + } + + public function testNull() + { + $serializer = new Raven_ReprSerializer(); + $input = null; + $result = $serializer->serialize($input); + $this->assertTrue(is_string($result)); + $this->assertEquals('null', $result); + } + + public function testRecursionMaxDepth() + { + $serializer = new Raven_ReprSerializer(); + $input = array(); + $input[] = &$input; + $result = $serializer->serialize($input, 3); + $this->assertEquals(array(array(array('Array of length 1'))), $result); + } +} diff --git a/wp-content/plugins/getsentry-client/readme.txt b/wp-content/plugins/getsentry-client/readme.txt index 9e4d791..64a175c 100644 --- a/wp-content/plugins/getsentry-client/readme.txt +++ b/wp-content/plugins/getsentry-client/readme.txt @@ -30,11 +30,11 @@ To report bugs and get help, see the [official github repository](https://github = 1.2 = -Adding the ability to access the Raven client directly to send custom error messages to sentry. Merge PR from @wk8. +* Adding the ability to access the Raven client directly to send custom error messages to sentry. Merge PR from @wk8. = 1.1 = -Upgrade raven php client to v0.15.0 +* Upgrade raven php client to v0.15.0 = 1.0 = @@ -63,6 +63,8 @@ Upgrade raven php client to v0.15.0 == Contributors == vbartusevicius (https://github.com/vbartusevicius) +wk8 (https://github.com/wk8) +