Changeset 1418133
- Timestamp:
- 05/16/2016 08:30:17 PM (10 years ago)
- Location:
- getsentry-client/trunk
- Files:
-
- 19 edited
-
raven/AUTHORS (modified) (1 diff)
-
raven/CHANGES (modified) (1 diff)
-
raven/LICENSE (modified) (1 diff)
-
raven/Makefile (modified) (1 diff)
-
raven/README.rst (modified) (6 diffs)
-
raven/composer.json (modified) (3 diffs)
-
raven/lib/Raven/Client.php (modified) (43 diffs)
-
raven/lib/Raven/Compat.php (modified) (1 diff)
-
raven/lib/Raven/CurlHandler.php (modified) (4 diffs)
-
raven/lib/Raven/ErrorHandler.php (modified) (6 diffs)
-
raven/lib/Raven/SanitizeDataProcessor.php (modified) (4 diffs)
-
raven/lib/Raven/Serializer.php (modified) (2 diffs)
-
raven/lib/Raven/Stacktrace.php (modified) (9 diffs)
-
raven/test/Raven/Tests/ClientTest.php (modified) (25 diffs)
-
raven/test/Raven/Tests/ErrorHandlerTest.php (modified) (5 diffs)
-
raven/test/Raven/Tests/SanitizeDataProcessorTest.php (modified) (9 diffs)
-
raven/test/Raven/Tests/SerializerTest.php (modified) (3 diffs)
-
raven/test/Raven/Tests/StacktraceTest.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
getsentry-client/trunk/raven/AUTHORS
r1098247 r1418133 1 The Raven PHP clientwas originally written by Michael van Tellingen1 The Sentry PHP SDK was originally written by Michael van Tellingen 2 2 and is maintained by the Sentry Team. 3 3 4 http://github.com/getsentry/ raven-php/contributors4 http://github.com/getsentry/sentry-php/contributors -
getsentry-client/trunk/raven/CHANGES
r1098363 r1418133 1 0.15.0 2 ------ 3 4 - Fixed some cases where serialization wouldn't happen. 5 - Added sdk attribute. 6 7 0.14.0 8 ------ 9 10 - Added ``prefixes`` option for stripping absolute paths. 11 - Removed ``abs_path`` from stacktraces. 12 - Added ``app_path`` to specify application root for resolving ``in_app` on frames. 13 - Moved Laravel support to ``sentry-laravel`` project. 14 - Fixed duplicate stack computation. 15 - Added ``dsn`` option to ease configuration. 16 - Fixed an issue with the curl async transport. 17 - Improved serialization of values. 18 19 0.13.0 20 ------ 21 22 - Updated API to use new style interfaces. 23 - Remove session cookie in default processor. 24 - Expand docs for Laravel, Symfony2, and Monolog. 25 - Default error types can now be set as part of ErrorHandler configuration. 26 27 0.12.1 28 ------ 29 30 - Dont send empty values for various context. 31 32 0.12.0 33 ------ 34 35 - Bumped protocol version to 6. 36 - Fixed an issue with the async curl handler (GH-216). 37 - Removed UDP transport. 38 39 0.11.0 40 ------ 41 42 - New configuration parameter: 'release' 43 - New configuration parameter: 'message_limit' 44 - New configuration parameter: 'curl_ssl_version' 45 - New configuration parameter: 'curl_ipv4' 46 - New configuration parameter: 'verify_ssl' 47 - Updated remote endpoint to use modern project-based path. 48 - Expanded default sanitizer support to include 'auth_pw' attribute. 49 1 50 0.10.0 2 51 ------ -
getsentry-client/trunk/raven/LICENSE
r1098247 r1418133 8 8 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 9 10 3. Neither the name of the Raven nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.10 3. Neither the name of the Raven, Sentry, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 11 12 12 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -
getsentry-client/trunk/raven/Makefile
r1098247 r1418133 1 1 .PHONY: test 2 2 3 develop: 3 develop: update-submodules 4 4 composer install --dev 5 5 make setup-git 6 6 7 test: 7 update-submodules: 8 git submodule init 9 git submodule update 10 11 cs: 12 vendor/bin/php-cs-fixer fix --config-file=.php_cs --verbose --diff 13 14 cs-dry-run: 15 vendor/bin/php-cs-fixer fix --config-file=.php_cs --verbose --diff --dry-run 16 17 test: cs-dry-run 8 18 vendor/bin/phpunit 9 19 -
getsentry-client/trunk/raven/README.rst
r1098363 r1418133 1 raven-php2 ========= 3 4 .. image:: https://secure.travis-ci.org/getsentry/ raven-php.png?branch=master5 :target: http://travis-ci.org/getsentry/ raven-php6 7 8 raven-php is a PHP client for `Sentry <http://aboutsentry.com/>`_.1 sentry-php 2 ========== 3 4 .. image:: https://secure.travis-ci.org/getsentry/sentry-php.png?branch=master 5 :target: http://travis-ci.org/getsentry/sentry-php 6 7 8 The official PHP SDK for `Sentry <https://getsentry.com/>`_. 9 9 10 10 .. code-block:: php … … 48 48 dependencies, you can add Raven with it. 49 49 50 .. code-block:: json 51 52 { 53 "require": { 54 "raven/raven": "$VERSION" 55 } 56 } 57 58 (replace ``$VERSION`` with one of the available versions on `Packagist <https://packagist.org/packages/raven/raven>`_) 50 :: 51 52 $ composer require sentry/sentry:$VERSION 53 54 (replace ``$VERSION`` with one of the available versions on `Packagist <https://packagist.org/packages/sentry/sentry>`_) 59 55 or to get the latest version off the master branch: 60 56 61 .. code-block:: json 62 63 { 64 "require": { 65 "raven/raven": "dev-master" 66 } 67 } 57 :: 58 59 $ composer require sentry/sentry:dev-master 68 60 69 61 Note that using unstable versions is not recommended and should be avoided. Also 70 62 you should define a maximum version, e.g. by doing ``>=0.6,<1.0`` or ``~0.6``. 71 63 64 Alternatively, use the ``^`` operator for specifying a version, e.g., 65 66 :: 67 68 $ composer require sentry/sentry:^0.11.0 69 72 70 Composer will take care of the autoloading for you, so if you require the 73 71 ``vendor/autoload.php``, you're good to go. … … 81 79 :: 82 80 83 $ git clone git://github.com/getsentry/ raven-php.git81 $ git clone git://github.com/getsentry/sentry-php.git 84 82 85 83 And including it using the autoloader: … … 98 96 .. code-block:: bash 99 97 100 $ bin/ raventest https://public:secret@app.getsentry.com/198 $ bin/sentry test https://public:secret@app.getsentry.com/1 101 99 Client configuration: 102 -> server s: [https://sentry.example.com/api/store/]100 -> server: [https://sentry.example.com/api/store/] 103 101 -> project: 1 104 102 -> public_key: public … … 263 261 :: 264 262 265 $ bin/phpunit263 $ vendor/bin/phpunit 266 264 267 265 … … 270 268 --------- 271 269 272 * `Bug Tracker <http://github.com/getsentry/ raven-php/issues>`_273 * `Code <http://github.com/getsentry/ raven-php>`_270 * `Bug Tracker <http://github.com/getsentry/sentry-php/issues>`_ 271 * `Code <http://github.com/getsentry/sentry-php>`_ 274 272 * `Mailing List <https://groups.google.com/group/getsentry>`_ 275 273 * `IRC <irc://irc.freenode.net/sentry>`_ (irc.freenode.net, #sentry) -
getsentry-client/trunk/raven/composer.json
r1098247 r1418133 1 1 { 2 "name": " raven/raven",2 "name": "sentry/sentry", 3 3 "type": "library", 4 4 "description": "A PHP client for Sentry (http://getsentry.com)", 5 5 "keywords": ["log", "logging"], 6 6 "homepage": "http://getsentry.com", 7 "license": "BSD ",7 "license": "BSD-3-Clause", 8 8 "authors": [ 9 9 { … … 13 13 ], 14 14 "require-dev": { 15 "phpunit/phpunit": "3.7.*" 15 "fabpot/php-cs-fixer": "^1.8.0", 16 "phpunit/phpunit": "^4.6.6" 16 17 }, 17 18 "require": { 18 "php": ">=5.2.4" 19 "php": ">=5.2.4", 20 "ext-curl": "*", 21 "monolog/monolog": "*" 19 22 }, 20 23 "bin": [ 21 "bin/ raven"24 "bin/sentry" 22 25 ], 23 "config": {24 "bin-dir": "bin"25 },26 26 "autoload": { 27 27 "psr-0" : { … … 31 31 "extra": { 32 32 "branch-alias": { 33 "dev-master": "0. 8.x-dev"33 "dev-master": "0.17.x-dev" 34 34 } 35 35 } -
getsentry-client/trunk/raven/lib/Raven/Client.php
r1098363 r1418133 17 17 class Raven_Client 18 18 { 19 const VERSION = '0.1 0.0';20 const PROTOCOL = ' 5';19 const VERSION = '0.17.0'; 20 const PROTOCOL = '6'; 21 21 22 22 const DEBUG = 'debug'; … … 29 29 const MESSAGE_LIMIT = 1024; 30 30 31 var$severity_map;32 var$extra_data;33 34 var$store_errors_for_bulk_send = false;31 public $severity_map; 32 public $extra_data; 33 34 public $store_errors_for_bulk_send = false; 35 35 36 36 public function __construct($options_or_dsn=null, $options=array()) 37 37 { 38 if (is_null($options_or_dsn) && !empty($_SERVER['SENTRY_DSN'])) { 39 // Read from environment 40 $options_or_dsn = $_SERVER['SENTRY_DSN']; 41 } 42 if (!is_array($options_or_dsn)) { 43 if (!empty($options_or_dsn)) { 44 // Must be a valid DSN 45 $options_or_dsn = self::parseDSN($options_or_dsn); 46 } else { 47 $options_or_dsn = array(); 48 } 49 } 50 $options = array_merge($options_or_dsn, $options); 38 if (is_array($options_or_dsn)) { 39 $options = array_merge($options_or_dsn, $options); 40 } 41 42 if (!is_array($options_or_dsn) && !empty($options_or_dsn)) { 43 $dsn = $options_or_dsn; 44 } elseif (!empty($_SERVER['SENTRY_DSN'])) { 45 $dsn = @$_SERVER['SENTRY_DSN']; 46 } elseif (!empty($options['dsn'])) { 47 $dsn = $options['dsn']; 48 } else { 49 $dsn = null; 50 } 51 52 if (!empty($dsn)) { 53 $options = array_merge($options, self::parseDSN($dsn)); 54 } 51 55 52 56 $this->logger = Raven_Util::get($options, 'logger', 'php'); 53 $this->server s = Raven_Util::get($options, 'servers');57 $this->server = Raven_Util::get($options, 'server'); 54 58 $this->secret_key = Raven_Util::get($options, 'secret_key'); 55 59 $this->public_key = Raven_Util::get($options, 'public_key'); … … 59 63 $this->site = Raven_Util::get($options, 'site', $this->_server_variable('SERVER_NAME')); 60 64 $this->tags = Raven_Util::get($options, 'tags', array()); 65 $this->release = Raven_Util::get($options, 'release', null); 66 $this->environment = Raven_Util::get($options, 'environment', null); 61 67 $this->trace = (bool) Raven_Util::get($options, 'trace', true); 62 68 $this->timeout = Raven_Util::get($options, 'timeout', 2); 63 69 $this->message_limit = Raven_Util::get($options, 'message_limit', self::MESSAGE_LIMIT); 64 70 $this->exclude = Raven_Util::get($options, 'exclude', array()); 65 $this->severity_map = NULL;71 $this->severity_map = null; 66 72 $this->shift_vars = (bool) Raven_Util::get($options, 'shift_vars', true); 67 73 $this->http_proxy = Raven_Util::get($options, 'http_proxy'); … … 71 77 $this->curl_path = Raven_Util::get($options, 'curl_path', 'curl'); 72 78 $this->curl_ipv4 = Raven_util::get($options, 'curl_ipv4', true); 73 $this->ca_cert = Raven_util::get($options, 'ca_cert', $this->get_default_ca_cert()); 74 $this->curl_ssl_version = Raven_Util::get($options, 'curl_ssl_version'); 79 $this->ca_cert = Raven_Util::get($options, 'ca_cert', $this->get_default_ca_cert()); 80 $this->verify_ssl = Raven_Util::get($options, 'verify_ssl', true); 81 $this->curl_ssl_version = Raven_Util::get($options, 'curl_ssl_version'); 82 $this->trust_x_forwarded_proto = Raven_Util::get($options, 'trust_x_forwarded_proto'); 83 // a list of prefixes used to coerce absolute paths into relative 84 $this->prefixes = Raven_Util::get($options, 'prefixes', null); 85 // app path is used to determine if code is part of your application 86 $this->app_path = Raven_Util::get($options, 'app_path', null); 75 87 76 88 $this->processors = $this->setProcessorsFromOptions($options); 77 89 78 90 $this->_lasterror = null; 91 $this->_last_event_id = null; 79 92 $this->_user = null; 80 93 $this->context = new Raven_Context(); 94 $this->breadcrumbs = new Raven_Breadcrumbs(); 95 $this->sdk = Raven_Util::get($options, 'sdk', array( 96 'name' => 'sentry-php', 97 'version' => self::VERSION, 98 )); 81 99 82 100 if ($this->curl_method == 'async') { … … 99 117 * @return array 100 118 */ 101 public function setProcessorsFromOptions($options){ 119 public function setProcessorsFromOptions($options) 120 { 102 121 $processors = array(); 103 122 foreach (Raven_util::get($options, 'processors', self::getDefaultProcessors()) as $processor) { 104 123 $new_processor = new $processor($this); 105 124 106 if ( isset($options['processorOptions']) && is_array($options['processorOptions']) ){107 if ( isset($options['processorOptions'][$processor]) && method_exists($processor, 'setProcessorOptions') ){125 if (isset($options['processorOptions']) && is_array($options['processorOptions'])) { 126 if (isset($options['processorOptions'][$processor]) && method_exists($processor, 'setProcessorOptions')) { 108 127 $new_processor->setProcessorOptions($options['processorOptions'][$processor]); 109 128 } … … 124 143 $url = parse_url($dsn); 125 144 $scheme = (isset($url['scheme']) ? $url['scheme'] : ''); 126 if (!in_array($scheme, array('http', 'https' , 'udp'))) {145 if (!in_array($scheme, array('http', 'https'))) { 127 146 throw new InvalidArgumentException('Unsupported Sentry DSN scheme: ' . (!empty($scheme) ? $scheme : '<not set>')); 128 147 } … … 150 169 151 170 return array( 152 'server s' => array(sprintf('%s://%s%s/api/store/', $scheme, $netloc, $path)),171 'server' => sprintf('%s://%s%s/api/%s/store/', $scheme, $netloc, $path, $project), 153 172 'project' => $project, 154 173 'public_key' => $username, … … 204 223 if ($level_or_options === null) { 205 224 $data = array(); 206 } else if (!is_array($level_or_options)) {225 } elseif (!is_array($level_or_options)) { 207 226 $data = array( 208 227 'level' => $level_or_options, … … 255 274 ); 256 275 257 /**' sentry.interfaces.Exception'276 /**'exception' 258 277 * Exception::getTrace doesn't store the point at where the exception 259 278 * was thrown, so we have to stuff it in ourselves. Ugh. … … 274 293 $exc_data['stacktrace'] = array( 275 294 'frames' => Raven_Stacktrace::get_stack_info( 276 $trace, $this->trace, $this->shift_vars, $vars, $this->message_limit 295 $trace, $this->trace, $this->shift_vars, $vars, $this->message_limit, $this->prefixes, 296 $this->app_path 277 297 ), 278 298 ); 279 299 280 300 $exceptions[] = $exc_data; 281 282 301 } while ($has_chained_exceptions && $exc = $exc->getPrevious()); 283 302 284 303 $data['message'] = $message; 285 $data[' sentry.interfaces.Exception'] = array(304 $data['exception'] = array( 286 305 'values' => array_reverse($exceptions), 287 306 ); … … 320 339 } 321 340 341 /** 342 * Return the last captured event's ID or null if none available. 343 */ 344 public function getLastEventID() 345 { 346 return $this->_last_event_id; 347 } 348 322 349 protected function is_http_request() 323 350 { … … 331 358 foreach ($_SERVER as $key => $value) { 332 359 if (0 === strpos($key, 'HTTP_')) { 333 if (in_array($key, array('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'))) {334 continue;335 }336 360 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))))] = $value; 337 } elseif (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH')) ) {361 } elseif (in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH')) && $value !== '') { 338 362 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $key))))] = $value; 339 363 } else { … … 364 388 365 389 return array( 366 ' sentry.interfaces.Http' => $result,390 'request' => $result, 367 391 ); 368 392 } … … 383 407 } 384 408 return array( 385 ' sentry.interfaces.User' => $user,409 'user' => $user, 386 410 ); 387 411 } … … 401 425 'tags' => $this->tags, 402 426 'platform' => 'php', 403 ); 404 } 405 406 public function capture($data, $stack, $vars = null) 407 { 408 if (!isset($data['timestamp'])) $data['timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); 409 if (!isset($data['level'])) $data['level'] = self::ERROR; 410 if (!isset($data['tags'])) $data['tags'] = array(); 411 if (!isset($data['extra'])) $data['extra'] = array(); 412 if (!isset($data['event_id'])) $data['event_id'] = $this->uuid4(); 427 'sdk' => $this->sdk, 428 ); 429 } 430 431 public function capture($data, $stack = null, $vars = null) 432 { 433 if (!isset($data['timestamp'])) { 434 $data['timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); 435 } 436 if (!isset($data['level'])) { 437 $data['level'] = self::ERROR; 438 } 439 if (!isset($data['tags'])) { 440 $data['tags'] = array(); 441 } 442 if (!isset($data['extra'])) { 443 $data['extra'] = array(); 444 } 445 if (!isset($data['event_id'])) { 446 $data['event_id'] = $this->uuid4(); 447 } 413 448 414 449 if (isset($data['message'])) { … … 423 458 424 459 $data = array_merge($this->get_user_data(), $data); 460 461 if ($this->release) { 462 $data['release'] = $this->release; 463 } 464 if ($this->environment) { 465 $data['environment'] = $this->environment; 466 } 425 467 426 468 $data['tags'] = array_merge( … … 434 476 $data['extra']); 435 477 436 if ((!$stack && $this->auto_log_stacks) || $stack === True) { 478 if (empty($data['extra'])) { 479 unset($data['extra']); 480 } else { 481 $data['extra'] = $data['extra']; 482 } 483 484 if (empty($data['tags'])) { 485 unset($data['tags']); 486 } else { 487 $data['tags'] = $data['tags']; 488 } 489 if (!empty($data['user'])) { 490 $data['user'] = $data['user']; 491 } 492 if (!empty($data['request'])) { 493 $data['request'] = $data['request']; 494 } 495 496 if (!$this->breadcrumbs->is_empty()) { 497 $data['breadcrumbs'] = $this->breadcrumbs->fetch(); 498 } 499 500 if ((!$stack && $this->auto_log_stacks) || $stack === true) { 437 501 $stack = debug_backtrace(); 438 502 … … 447 511 } 448 512 449 if (!isset($data['s entry.interfaces.Stacktrace'])) {450 $data['s entry.interfaces.Stacktrace'] = array(513 if (!isset($data['stacktrace']) && !isset($data['exception'])) { 514 $data['stacktrace'] = array( 451 515 'frames' => Raven_Stacktrace::get_stack_info( 452 $stack, $this->trace, $this->shift_vars, $vars, $this->message_limit 516 $stack, $this->trace, $this->shift_vars, $vars, $this->message_limit, 517 $this->prefixes, $this->app_path 453 518 ), 454 519 ); … … 459 524 $this->process($data); 460 525 461 if (!$this->store_errors_for_bulk_send){526 if (!$this->store_errors_for_bulk_send) { 462 527 $this->send($data); 463 } else{464 if (empty($this->error_data)){528 } else { 529 if (empty($this->error_data)) { 465 530 $this->error_data = array(); 466 531 } … … 468 533 } 469 534 535 $this->_last_event_id = $data['event_id']; 536 470 537 return $data['event_id']; 471 538 } … … 473 540 public function sanitize(&$data) 474 541 { 475 // manually trigger autoloading, as it's not done in some edge cases due to PHP bugs (see #60149)476 if (!class_exists('Raven_Serializer')) {477 spl_autoload_call('Raven_Serializer');478 }479 480 $data = Raven_Serializer::serialize($data);481 542 } 482 543 … … 493 554 } 494 555 495 public function sendUnsentErrors(){ 496 if(!empty($this->error_data)){ 497 foreach($this->error_data as $data){ 556 public function sendUnsentErrors() 557 { 558 if (!empty($this->error_data)) { 559 foreach ($this->error_data as $data) { 498 560 $this->send($data); 499 561 } 500 562 unset($this->error_data); 501 563 } 502 if ($this->store_errors_for_bulk_send){564 if ($this->store_errors_for_bulk_send) { 503 565 //in case an error occurs after this is called, on shutdown, send any new errors. 504 566 $this->store_errors_for_bulk_send = !defined('RAVEN_CLIENT_END_REACHED'); … … 507 569 508 570 /** 509 * Wrapper to handle encoding and sending data to all defined Sentry servers571 * Wrapper to handle encoding and sending data to the Sentry API server. 510 572 * 511 573 * @param array $data Associative array of data to log … … 518 580 } 519 581 520 if (!$this->server s) {582 if (!$this->server) { 521 583 return; 522 584 } … … 529 591 $message = base64_encode($message); // PHP's builtin curl_* function are happy without this, but the exec method requires it 530 592 531 foreach ($this->servers as $url) { 532 $client_string = 'raven-php/' . self::VERSION; 533 $timestamp = microtime(true); 534 $headers = array( 535 'User-Agent' => $client_string, 536 'X-Sentry-Auth' => $this->get_auth_header( 537 $timestamp, $client_string, $this->public_key, 538 $this->secret_key), 539 'Content-Type' => 'application/octet-stream' 540 ); 541 542 $this->send_remote($url, $message, $headers); 543 } 593 $client_string = 'sentry-php/' . self::VERSION; 594 $timestamp = microtime(true); 595 $headers = array( 596 'User-Agent' => $client_string, 597 'X-Sentry-Auth' => $this->get_auth_header( 598 $timestamp, $client_string, $this->public_key, 599 $this->secret_key), 600 'Content-Type' => 'application/octet-stream' 601 ); 602 603 $this->send_remote($this->server, $message, $headers); 544 604 } 545 605 … … 555 615 $parts = parse_url($url); 556 616 $parts['netloc'] = $parts['host'].(isset($parts['port']) ? ':'.$parts['port'] : null); 557 558 if ($parts['scheme'] === 'udp') { 559 $this->send_udp($parts['netloc'], $data, $headers['X-Sentry-Auth']); 560 } 561 else { 562 $this->send_http($url, $data, $headers); 563 } 564 } 565 566 /** 567 * Send data to Sentry via udp socket 568 * 569 * @param string $netloc host:port || host 570 * @param array $data Associative array of data to log 571 * @param array $headers Associative array of headers 572 */ 573 private function send_udp($netloc, $data, $headers) 574 { 575 list($host, $port) = explode(':', $netloc); 576 $raw_data = $headers."\n\n".$data; 577 578 $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 579 socket_sendto($sock, $raw_data, strlen($raw_data), 0, $host, $port); 580 socket_close($sock); 581 } 582 583 protected function get_default_ca_cert() { 617 $this->send_http($url, $data, $headers); 618 } 619 620 protected function get_default_ca_cert() 621 { 584 622 return dirname(__FILE__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'cacert.pem'; 585 623 } … … 590 628 CURLOPT_VERBOSE => false, 591 629 CURLOPT_SSL_VERIFYHOST => 2, 592 CURLOPT_SSL_VERIFYPEER => true,630 CURLOPT_SSL_VERIFYPEER => $this->verify_ssl, 593 631 CURLOPT_CAINFO => $this->ca_cert, 594 CURLOPT_USERAGENT => ' raven-php/' . self::VERSION,632 CURLOPT_USERAGENT => 'sentry-php/' . self::VERSION, 595 633 ); 596 634 if ($this->http_proxy) { … … 598 636 } 599 637 if ($this->curl_ssl_version) { 600 $options[CURLOPT_SSLVERSION] = $this->curl_ssl_version;638 $options[CURLOPT_SSLVERSION] = $this->curl_ssl_version; 601 639 } 602 640 if ($this->curl_ipv4) { … … 606 644 // MS is available in curl >= 7.16.2 607 645 $timeout = max(1, ceil(1000 * $this->timeout)); 646 647 // some versions of PHP 5.3 don't have this defined correctly 648 if (!defined('CURLOPT_CONNECTTIMEOUT_MS')) { 649 //see http://stackoverflow.com/questions/9062798/php-curl-timeout-is-not-working/9063006#9063006 650 define('CURLOPT_CONNECTTIMEOUT_MS', 156); 651 } 652 608 653 $options[CURLOPT_CONNECTTIMEOUT_MS] = $timeout; 609 654 $options[CURLOPT_TIMEOUT_MS] = $timeout; … … 643 688 * @return bool 644 689 */ 645 private function send_http_asynchronous_curl_exec($url, $data, $headers) { 690 private function send_http_asynchronous_curl_exec($url, $data, $headers) 691 { 646 692 // TODO(dcramer): support ca_cert 647 693 $cmd = $this->curl_path.' -X POST '; … … 652 698 $cmd .= '\''. $url .'\' '; 653 699 $cmd .= '-m 5 '; // 5 second timeout for the whole process (connect + send) 700 if (!$this->verify_ssl) { 701 $cmd .= '-k '; 702 } 654 703 $cmd .= '> /dev/null 2>&1 &'; // ensure exec returns immediately while curl runs in the background 655 704 … … 673 722 array_push($new_headers, $key .': '. $value); 674 723 } 724 // XXX(dcramer): Prevent 100-continue response form server (Fixes GH-216) 725 $new_headers[] = 'Expect:'; 675 726 676 727 $curl = curl_init($url); … … 745 796 $uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', 746 797 // 32 bits for "time_low" 747 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff),798 mt_rand(0, 0xffff), mt_rand(0, 0xffff), 748 799 749 800 // 16 bits for "time_mid" 750 mt_rand( 0, 0xffff),801 mt_rand(0, 0xffff), 751 802 752 803 // 16 bits for "time_hi_and_version", 753 804 // four most significant bits holds version number 4 754 mt_rand( 0, 0x0fff) | 0x4000,805 mt_rand(0, 0x0fff) | 0x4000, 755 806 756 807 // 16 bits, 8 bits for "clk_seq_hi_res", 757 808 // 8 bits for "clk_seq_low", 758 809 // two most significant bits holds zero and one for variant DCE1.1 759 mt_rand( 0, 0x3fff) | 0x8000,810 mt_rand(0, 0x3fff) | 0x8000, 760 811 761 812 // 48 bits for "node" 762 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff)813 mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) 763 814 ); 764 815 … … 771 822 * @return string|null 772 823 */ 773 pr ivatefunction get_current_url()824 protected function get_current_url() 774 825 { 775 826 // When running from commandline the REQUEST_URI is missing. … … 778 829 } 779 830 780 $schema = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' 781 || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; 782 783 return $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 831 // HTTP_HOST is a client-supplied header that is optional in HTTP 1.0 832 $host = (!empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] 833 : (!empty($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] 834 : (!empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''))); 835 836 $httpS = $this->isHttps() ? 's' : ''; 837 return "http{$httpS}://{$host}{$_SERVER['REQUEST_URI']}"; 838 } 839 840 /** 841 * Was the current request made over https? 842 * 843 * @return bool 844 */ 845 protected function isHttps() 846 { 847 if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { 848 return true; 849 } 850 851 if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { 852 return true; 853 } 854 855 if (!empty($this->trust_x_forwarded_proto) && 856 !empty($_SERVER['X-FORWARDED-PROTO']) && 857 $_SERVER['X-FORWARDED-PROTO'] === 'https') { 858 return true; 859 } 860 861 return false; 784 862 } 785 863 … … 805 883 * @return string Sentry log level group 806 884 */ 807 public function translateSeverity($severity) { 885 public function translateSeverity($severity) 886 { 808 887 if (is_array($this->severity_map) && isset($this->severity_map[$severity])) { 809 888 return $this->severity_map[$severity]; … … 825 904 } 826 905 if (version_compare(PHP_VERSION, '5.3.0', '>=')) { 827 switch ($severity) {906 switch ($severity) { 828 907 case E_DEPRECATED: return Raven_Client::WARN; 829 908 case E_USER_DEPRECATED: return Raven_Client::WARN; … … 839 918 * @param array $map 840 919 */ 841 public function registerSeverityMap($map) { 920 public function registerSeverityMap($map) 921 { 842 922 $this->severity_map = $map; 843 923 } … … 850 930 * @param array $data Additional user data 851 931 */ 852 public function set_user_data($id, $email=null, $data=array()) { 853 $this->user_context(array_merge(array( 854 'id' => $id, 855 'email' => $email, 856 ), $data)); 932 public function set_user_data($id, $email=null, $data=array()) 933 { 934 $user = array('id' => $id); 935 if (isset($email)) { 936 $user['email'] = $email; 937 } 938 $this->user_context(array_merge($user, $data)); 857 939 } 858 940 … … 862 944 * @param array $data Associative array of user data 863 945 */ 864 public function user_context($data) { 946 public function user_context($data) 947 { 865 948 $this->context->user = $data; 866 949 } … … 871 954 * @param array $data Associative array of tags 872 955 */ 873 public function tags_context($data) { 956 public function tags_context($data) 957 { 874 958 $this->context->tags = array_merge($this->context->tags, $data); 875 959 } … … 880 964 * @param array $data Associative array of extra data 881 965 */ 882 public function extra_context($data) { 966 public function extra_context($data) 967 { 883 968 $this->context->extra = array_merge($this->context->extra, $data); 884 969 } … … 887 972 * @param array $processors 888 973 */ 889 public function setProcessors(array $processors){ 974 public function setProcessors(array $processors) 975 { 890 976 $this->processors = $processors; 891 977 } -
getsentry-client/trunk/raven/lib/Raven/Compat.php
r1098247 r1418133 12 12 class Raven_Compat 13 13 { 14 15 14 public static function gethostname() 16 15 { -
getsentry-client/trunk/raven/lib/Raven/CurlHandler.php
r1098363 r1418133 46 46 array_push($new_headers, $key .': '. $value); 47 47 } 48 // XXX(dcramer): Prevent 100-continue response form server (Fixes GH-216) 49 $new_headers[] = 'Expect:'; 48 50 49 51 curl_setopt($ch, CURLOPT_HTTPHEADER, $new_headers); … … 70 72 public function join($timeout=null) 71 73 { 72 if (!isset($timeout)) {73 $timeout = $this->join_timeout;74 }74 if (!isset($timeout)) { 75 $timeout = $this->join_timeout; 76 } 75 77 $start = time(); 76 78 do { … … 80 82 } 81 83 usleep(10000); 82 } while ($timeout !== 0 && time() - $start >$timeout);84 } while ($timeout !== 0 && time() - $start < $timeout); 83 85 } 84 86 … … 95 97 $mrc = curl_multi_exec($this->multi_handle, $active); 96 98 } while ($mrc == CURLM_CALL_MULTI_PERFORM); 97 } 98 else { 99 } else { 99 100 return; 100 101 } -
getsentry-client/trunk/raven/lib/Raven/ErrorHandler.php
r1098247 r1418133 22 22 */ 23 23 24 // TODO(dcramer): deprecate default error types in favor of runtime configuration 25 // unless a reason can be determined that making them dynamic is better. They 26 // currently are not used outside of the fatal handler. 24 27 class Raven_ErrorHandler 25 28 { … … 30 33 private $reservedMemory; 31 34 private $send_errors_last = false; 32 private $error_types = -1; 33 34 public function __construct($client, $send_errors_last = false) 35 36 /** 37 * @var array 38 * Error types which should be processed by the handler. 39 * A 'null' value implies "whatever error_reporting is at time of error". 40 */ 41 private $error_types = null; 42 43 /** 44 * @deprecated 45 * @var array 46 * Error types that can be processed by the handler 47 */ 48 private $validErrorTypes = array( 49 E_ERROR, 50 E_WARNING, 51 E_PARSE, 52 E_NOTICE, 53 E_CORE_ERROR, 54 E_CORE_WARNING, 55 E_COMPILE_ERROR, 56 E_COMPILE_WARNING, 57 E_USER_ERROR, 58 E_USER_WARNING, 59 E_USER_NOTICE, 60 E_STRICT, 61 E_RECOVERABLE_ERROR, 62 E_DEPRECATED, 63 E_USER_DEPRECATED, 64 ); 65 66 /** 67 * @deprecated 68 * @var array 69 * The default Error types that are always processed by the handler. Can be set during construction. 70 */ 71 private $defaultErrorTypes = array( 72 E_ERROR, 73 E_PARSE, 74 E_CORE_ERROR, 75 E_CORE_WARNING, 76 E_COMPILE_ERROR, 77 E_COMPILE_WARNING, 78 E_STRICT, 79 ); 80 81 public function __construct($client, $send_errors_last = false, $default_error_types = null, 82 $error_types = null) 35 83 { 36 84 $this->client = $client; 85 if ($default_error_types !== null) { 86 $this->defaultErrorTypes = $default_error_types; 87 } 88 $this->error_types = $error_types; 37 89 register_shutdown_function(array($this, 'detectShutdown')); 38 90 if ($send_errors_last) { … … 54 106 public function handleError($code, $message, $file = '', $line = 0, $context=array()) 55 107 { 56 if ($this->error_types & $code & error_reporting()) { 57 $e = new ErrorException($message, 0, $code, $file, $line); 58 $this->handleException($e, true, $context); 59 } 60 61 if ($this->call_existing_error_handler && $this->old_error_handler) { 62 call_user_func($this->old_error_handler, $code, $message, $file, $line, $context); 63 } 108 if (error_reporting() !== 0) { 109 $error_types = $this->error_types; 110 if ($error_types === null) { 111 $error_types = error_reporting(); 112 } 113 if ($error_types & $code) { 114 $e = new ErrorException($message, 0, $code, $file, $line); 115 $this->handleException($e, true, $context); 116 } 117 } 118 if ($this->call_existing_error_handler) { 119 if ($this->old_error_handler !== null) { 120 return call_user_func($this->old_error_handler, $code, $message, $file, $line, $context); 121 } else { 122 return false; 123 } 124 } 125 } 126 127 /** 128 * Nothing by default, use it in child classes for catching other types of errors 129 * Only constants from $this->validErrorTypes can be used 130 * 131 * @deprecated 132 * @return array 133 */ 134 135 protected function getAdditionalErrorTypesToProcess() 136 { 137 return array(); 138 } 139 140 /** 141 * @deprecated 142 * @return array 143 */ 144 private function getErrorTypesToProcess() 145 { 146 $additionalErrorTypes = array_intersect($this->getAdditionalErrorTypesToProcess(), $this->validErrorTypes); 147 // array_unique so bitwise "or" operation wouldn't fail if some error type gets repeated 148 return array_unique(array_merge($this->defaultErrorTypes, $additionalErrorTypes)); 64 149 } 65 150 … … 72 157 unset($this->reservedMemory); 73 158 74 $errors = E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_STRICT; 159 $errors = 0; 160 foreach ($this->getErrorTypesToProcess() as $errorType) { 161 $errors |= $errorType; 162 } 75 163 76 164 if ($lastError['type'] & $errors) { … … 87 175 $this->old_exception_handler = set_exception_handler(array($this, 'handleException')); 88 176 $this->call_existing_exception_handler = $call_existing_exception_handler; 89 } 90 91 public function registerErrorHandler($call_existing_error_handler = true, $error_types = -1) 92 { 93 $this->error_types = $error_types; 94 $this->old_error_handler = set_error_handler(array($this, 'handleError'), error_reporting()); 177 return $this; 178 } 179 180 /** 181 * Register a handler which will intercept standard PHP errors and report them to the 182 * associated Sentry client. 183 * 184 * @return array 185 */ 186 // 187 public function registerErrorHandler($call_existing_error_handler = true, $error_types = null) 188 { 189 if ($error_types !== null) { 190 $this->error_types = $error_types; 191 } 192 $this->old_error_handler = set_error_handler(array($this, 'handleError'), E_ALL); 95 193 $this->call_existing_error_handler = $call_existing_error_handler; 194 return $this; 96 195 } 97 196 … … 101 200 102 201 $this->reservedMemory = str_repeat('x', 1024 * $reservedMemorySize); 103 } 104 105 public function detectShutdown() { 202 return $this; 203 } 204 205 public function detectShutdown() 206 { 106 207 if (!defined('RAVEN_CLIENT_END_REACHED')) { 107 208 define('RAVEN_CLIENT_END_REACHED', true); -
getsentry-client/trunk/raven/lib/Raven/SanitizeDataProcessor.php
r1098363 r1418133 9 9 { 10 10 const MASK = '********'; 11 const FIELDS_RE = '/(authorization|password|passwd|secret|password_confirmation|card_number )/i';11 const FIELDS_RE = '/(authorization|password|passwd|secret|password_confirmation|card_number|auth_pw)/i'; 12 12 const VALUES_RE = '/^(?:\d[ -]*?){13,16}$/'; 13 13 … … 20 20 $this->client = $client; 21 21 $this->fields_re = self::FIELDS_RE; 22 $this->values_re = self::VALUES_RE; 22 $this->values_re = self::VALUES_RE; 23 $this->session_cookie_name = ini_get('session.name'); 23 24 } 24 25 … … 28 29 * @param array $options Associative array of processor options 29 30 */ 30 public function setProcessorOptions(array $options){ 31 if( isset($options['fields_re']) ){ 31 public function setProcessorOptions(array $options) 32 { 33 if (isset($options['fields_re'])) { 32 34 $this->fields_re = $options['fields_re']; 33 35 } 34 36 35 if ( isset($options['values_re']) ){37 if (isset($options['values_re'])) { 36 38 $this->values_re = $options['values_re']; 37 39 } … … 63 65 } 64 66 67 public function sanitizeHttp(&$data) 68 { 69 if (empty($data['request'])) { 70 return; 71 } 72 $http = &$data['request']; 73 if (empty($http['cookies'])) { 74 return; 75 } 76 77 $cookies = &$http['cookies']; 78 if (!empty($cookies[$this->session_cookie_name])) { 79 $cookies[$this->session_cookie_name] = self::MASK; 80 } 81 } 82 65 83 public function process(&$data) 66 84 { 67 85 array_walk_recursive($data, array($this, 'sanitize')); 86 $this->sanitizeHttp($data); 68 87 } 69 88 -
getsentry-client/trunk/raven/lib/Raven/Serializer.php
r1098247 r1418133 31 31 * sanitization and encoding. 32 32 */ 33 public static function serialize($value, $max_depth=9, $_depth=0)33 public function serialize($value, $max_depth=3, $_depth=0) 34 34 { 35 35 if (is_object($value) || is_resource($value)) { 36 return self::serializeValue($value);36 return $this->serializeValue($value); 37 37 } elseif ($_depth < $max_depth && is_array($value)) { 38 38 $new = array(); 39 39 foreach ($value as $k => $v) { 40 $new[ self::serializeValue($k)] = self::serialize($v, $max_depth, $_depth + 1);40 $new[$this->serializeValue($k)] = $this->serialize($v, $max_depth, $_depth + 1); 41 41 } 42 42 43 43 return $new; 44 44 } else { 45 return self::serializeValue($value);45 return $this->serializeValue($value); 46 46 } 47 47 } 48 48 49 p ublic staticfunction serializeValue($value)49 protected function serializeValue($value) 50 50 { 51 if ($value === null) { 52 return 'null'; 53 } elseif ($value === false) { 54 return 'false'; 55 } elseif ($value === true) { 56 return 'true'; 57 } elseif (is_float($value) && (int) $value == $value) { 58 return $value.'.0'; 51 if (is_null($value) || is_bool($value) || is_float($value) || is_integer($value)) { 52 return $value; 59 53 } elseif (is_object($value) || gettype($value) == 'object') { 60 54 return 'Object '.get_class($value); … … 63 57 } elseif (is_array($value)) { 64 58 return 'Array of length ' . count($value); 65 } elseif (is_integer($value)) {66 return (integer) $value;67 59 } else { 68 60 $value = (string) $value; 69 61 70 62 if (function_exists('mb_convert_encoding')) { 71 $value = mb_convert_encoding($value, 'UTF-8', ' UTF-8');63 $value = mb_convert_encoding($value, 'UTF-8', 'auto'); 72 64 } 73 65 -
getsentry-client/trunk/raven/lib/Raven/Stacktrace.php
r1098363 r1418133 15 15 16 16 public static function get_stack_info($frames, $trace = false, $shiftvars = true, $errcontext = null, 17 $frame_var_limit = Raven_Client::MESSAGE_LIMIT) 17 $frame_var_limit = Raven_Client::MESSAGE_LIMIT, $strip_prefixes = null, 18 $app_path = null) 18 19 { 19 20 /** … … 54 55 $context = self::read_source_file($frame['file'], $frame['line']); 55 56 $abs_path = $frame['file']; 56 $filename = basename($frame['file']); 57 } 58 59 $module = $filename; 57 } 58 59 // strip base path if present 60 $context['filename'] = self::strip_prefixes($context['filename'], $strip_prefixes); 61 62 $module = basename($abs_path); 60 63 if (isset($nextframe['class'])) { 61 64 $module .= ':' . $nextframe['class']; … … 77 80 } 78 81 79 $frame = array( 80 'abs_path' => $abs_path, 82 $data = array( 83 // abs_path isn't overly useful, wastes space, and exposes 84 // filesystem internals 85 // 'abs_path' => $abs_path, 81 86 'filename' => $context['filename'], 82 87 'lineno' => (int) $context['lineno'], … … 87 92 'post_context' => $context['suffix'], 88 93 ); 94 95 // detect in_app based on app path 96 if ($app_path) { 97 $data['in_app'] = (bool)(substr($abs_path, 0, strlen($app_path)) === $app_path); 98 } 99 89 100 // dont set this as an empty array as PHP will treat it as a numeric array 90 101 // instead of a mapping which goes against the defined Sentry spec 91 102 if (!empty($vars)) { 103 $serializer = new Raven_ReprSerializer(); 104 $cleanVars = array(); 92 105 foreach ($vars as $key => $value) { 106 $value = $serializer->serialize($value); 93 107 if (is_string($value) || is_numeric($value)) { 94 $vars[$key] = substr($value, 0, $frame_var_limit); 108 $cleanVars[$key] = substr($value, 0, $frame_var_limit); 109 } else { 110 $cleanVars[$key] = $value; 95 111 } 96 112 } 97 $ frame['vars'] = $vars;98 } 99 100 $result[] = $ frame;113 $data['vars'] = $cleanVars; 114 } 115 116 $result[] = $data; 101 117 } 102 118 … … 117 133 } 118 134 return $args; 119 120 135 } 121 136 … … 150 165 } 151 166 } 152 if (isset($frame['class'])) { 153 if (method_exists($frame['class'], $frame['function'])) { 154 $reflection = new ReflectionMethod($frame['class'], $frame['function']); 155 } elseif ($frame['type'] === '::') { 156 $reflection = new ReflectionMethod($frame['class'], '__callStatic'); 157 } else { 158 $reflection = new ReflectionMethod($frame['class'], '__call'); 159 } 160 } else { 161 $reflection = new ReflectionFunction($frame['function']); 167 try { 168 if (isset($frame['class'])) { 169 if (method_exists($frame['class'], $frame['function'])) { 170 $reflection = new ReflectionMethod($frame['class'], $frame['function']); 171 } elseif ($frame['type'] === '::') { 172 $reflection = new ReflectionMethod($frame['class'], '__callStatic'); 173 } else { 174 $reflection = new ReflectionMethod($frame['class'], '__call'); 175 } 176 } else { 177 $reflection = new ReflectionFunction($frame['function']); 178 } 179 } catch (ReflectionException $e) { 180 return array(); 162 181 } 163 182 … … 169 188 // Assign the argument by the parameter name 170 189 if (is_array($arg)) { 171 foreach ($arg as $key => $value) { 172 if (is_string($value) || is_numeric($value)) { 173 $arg[$key] = substr($value, 0, $frame_arg_limit); 190 foreach ($arg as $key => $value) { 191 if (is_string($value) || is_numeric($value)) { 192 $arg[$key] = substr($value, 0, $frame_arg_limit); 193 } 174 194 } 175 }176 195 } 177 196 $args[$params[$i]->name] = $arg; … … 184 203 185 204 return $args; 205 } 206 207 private static function strip_prefixes($filename, $prefixes) 208 { 209 if ($prefixes === null) { 210 return; 211 } 212 foreach ($prefixes as $prefix) { 213 if (substr($filename, 0, strlen($prefix)) === $prefix) { 214 return substr($filename, strlen($prefix) + 1); 215 } 216 } 217 return $filename; 186 218 } 187 219 … … 240 272 } 241 273 $file->next(); 242 }274 } 243 275 } catch (RuntimeException $exc) { 244 276 return $frame; -
getsentry-client/trunk/raven/test/Raven/Tests/ClientTest.php
r1098363 r1418133 42 42 return parent::get_user_data(); 43 43 } 44 45 /** 46 * Expose the current url method to test it 47 * 48 * @return string 49 */ 50 public function test_get_current_url() 51 { 52 return $this->get_current_url(); 53 } 44 54 } 45 55 … … 73 83 74 84 $this->assertEquals($result['project'], 1); 75 $this->assertEquals($result['server s'], array('http://example.com/api/store/'));85 $this->assertEquals($result['server'], 'http://example.com/api/1/store/'); 76 86 $this->assertEquals($result['public_key'], 'public'); 77 87 $this->assertEquals($result['secret_key'], 'secret'); … … 83 93 84 94 $this->assertEquals($result['project'], 1); 85 $this->assertEquals($result['server s'], array('https://example.com/api/store/'));95 $this->assertEquals($result['server'], 'https://example.com/api/1/store/'); 86 96 $this->assertEquals($result['public_key'], 'public'); 87 97 $this->assertEquals($result['secret_key'], 'secret'); … … 93 103 94 104 $this->assertEquals($result['project'], 1); 95 $this->assertEquals($result['server s'], array('http://example.com/app/api/store/'));105 $this->assertEquals($result['server'], 'http://example.com/app/api/1/store/'); 96 106 $this->assertEquals($result['public_key'], 'public'); 97 107 $this->assertEquals($result['secret_key'], 'secret'); … … 103 113 104 114 $this->assertEquals($result['project'], 1); 105 $this->assertEquals($result['server s'], array('http://example.com:9000/app/api/store/'));115 $this->assertEquals($result['server'], 'http://example.com:9000/app/api/1/store/'); 106 116 $this->assertEquals($result['public_key'], 'public'); 107 117 $this->assertEquals($result['secret_key'], 'secret'); … … 158 168 159 169 $this->assertEquals($client->project, 1); 160 $this->assertEquals($client->server s, array('http://example.com/api/store/'));170 $this->assertEquals($client->server, 'http://example.com/api/1/store/'); 161 171 $this->assertEquals($client->public_key, 'public'); 162 172 $this->assertEquals($client->secret_key, 'secret'); … … 170 180 171 181 $this->assertEquals($client->project, 1); 172 $this->assertEquals($client->server s, array('http://example.com/api/store/'));182 $this->assertEquals($client->server, 'http://example.com/api/1/store/'); 173 183 $this->assertEquals($client->public_key, 'public'); 174 184 $this->assertEquals($client->secret_key, 'secret'); … … 179 189 { 180 190 $client = new Raven_Client(array( 181 'servers' => array('http://example.com/api/store/'), 182 )); 183 184 $this->assertEquals($client->servers, array('http://example.com/api/store/')); 191 'server' => 'http://example.com/api/1/store/', 192 'project' => 1, 193 )); 194 195 $this->assertEquals($client->server, 'http://example.com/api/1/store/'); 196 } 197 198 199 public function testDsnInOptionsFirstArg() 200 { 201 $client = new Raven_Client(array( 202 'dsn' => 'http://public:secret@example.com/1', 203 )); 204 205 $this->assertEquals($client->project, 1); 206 $this->assertEquals($client->server, 'http://example.com/api/1/store/'); 207 $this->assertEquals($client->public_key, 'public'); 208 $this->assertEquals($client->secret_key, 'secret'); 209 } 210 211 public function testDsnInOptionsSecondArg() 212 { 213 $client = new Raven_Client(null, array( 214 'dsn' => 'http://public:secret@example.com/1', 215 )); 216 217 $this->assertEquals($client->project, 1); 218 $this->assertEquals($client->server, 'http://example.com/api/1/store/'); 219 $this->assertEquals($client->public_key, 'public'); 220 $this->assertEquals($client->secret_key, 'secret'); 185 221 } 186 222 … … 188 224 { 189 225 $client = new Raven_Client(array( 190 'servers' => array('http://example.com/api/store/'), 226 'server' => 'http://example.com/api/1/store/', 227 'project' => 1, 191 228 ), array( 192 229 'site' => 'foo', 193 230 )); 194 231 195 $this->assertEquals($client->server s, array('http://example.com/api/store/'));232 $this->assertEquals($client->server, 'http://example.com/api/1/store/'); 196 233 $this->assertEquals($client->site, 'foo'); 197 234 } … … 206 243 $event = array_pop($events); 207 244 $this->assertEquals($event['extra']['foo'], 'bar'); 245 } 246 247 public function testEmptyExtraData() 248 { 249 $client = new Dummy_Raven_Client(array('extra' => array())); 250 251 $client->captureMessage('Test Message %s', array('foo')); 252 $events = $client->getSentEvents(); 253 $this->assertEquals(count($events), 1); 254 $event = array_pop($events); 255 $this->assertEquals(array_key_exists('extra', $event), false); 208 256 } 209 257 … … 281 329 $event = array_pop($events); 282 330 283 $exc = $event[' sentry.interfaces.Exception'];331 $exc = $event['exception']; 284 332 $this->assertEquals(count($exc['values']), 1); 285 333 $this->assertEquals($exc['values'][0]['value'], 'Foo bar'); … … 314 362 $event = array_pop($events); 315 363 316 $exc = $event[' sentry.interfaces.Exception'];364 $exc = $event['exception']; 317 365 $this->assertEquals(count($exc['values']), 2); 318 366 $this->assertEquals($exc['values'][0]['value'], 'Foo bar'); 319 367 $this->assertEquals($exc['values'][1]['value'], 'Child exc'); 320 321 } 322 323 public function testCaptureExceptionDifferentLevelsInChainedExceptionsBug(){368 } 369 370 public function testCaptureExceptionDifferentLevelsInChainedExceptionsBug() 371 { 324 372 if (version_compare(PHP_VERSION, '5.3.0', '<')) { 325 373 $this->markTestSkipped('PHP 5.3 required for chained exceptions.'); … … 417 465 } 418 466 419 public function testGetDefaultData() { 467 public function testGetDefaultData() 468 { 420 469 $client = new Dummy_Raven_Client(); 421 470 $expected = array( … … 426 475 'logger' => $client->logger, 427 476 'tags' => $client->tags, 477 'sdk' => array( 478 'name' => 'sentry-php', 479 'version' => $client::VERSION, 480 ), 428 481 ); 429 482 $this->assertEquals($expected, $client->get_default_data()); … … 443 496 'HTTP_ACCEPT_CHARSET' => 'utf-8', 444 497 'HTTP_COOKIE' => 'cupcake: strawberry', 445 'HTTP_CONTENT_TYPE' => 'text/html',446 'HTTP_CONTENT_LENGTH' => '1000',447 498 'SERVER_PORT' => '443', 448 499 'SERVER_PROTOCOL' => 'HTTP/1.1', … … 460 511 461 512 $expected = array( 462 ' sentry.interfaces.Http' => array(513 'request' => array( 463 514 'method' => 'PATCH', 464 515 'url' => 'https://getsentry.com/welcome/', … … 494 545 } 495 546 496 public function testGetUserDataWithSetUser() { 547 public function testGetUserDataWithSetUser() 548 { 497 549 $client = new Dummy_Raven_Client(); 498 550 … … 507 559 508 560 $expected = array( 509 ' sentry.interfaces.User' => array(561 'user' => array( 510 562 'id' => 'unique_id', 511 563 'username' => 'my_user', … … 517 569 } 518 570 519 public function testGetUserDataWithNoUser() { 571 public function testGetUserDataWithNoUser() 572 { 520 573 $client = new Dummy_Raven_Client(); 521 574 522 575 $expected = array( 523 ' sentry.interfaces.User' => array(576 'user' => array( 524 577 'id' => session_id(), 525 578 ) … … 528 581 } 529 582 530 public function testGetAuthHeader() { 531 $client = new Dummy_Raven_Client(); 532 533 $clientstring = 'raven-php/test'; 583 public function testGetAuthHeader() 584 { 585 $client = new Dummy_Raven_Client(); 586 587 $clientstring = 'sentry-php/test'; 534 588 $timestamp = '1234341324.340000'; 535 589 … … 538 592 "sentry_key=publickey, sentry_secret=secretkey"; 539 593 540 $this->assertEquals($expected, $client->get_auth_header($timestamp, ' raven-php/test', 'publickey', 'secretkey'));594 $this->assertEquals($expected, $client->get_auth_header($timestamp, 'sentry-php/test', 'publickey', 'secretkey')); 541 595 } 542 596 … … 553 607 $this->assertEquals(array( 554 608 'email' => 'foo@example.com', 555 ), $event[' sentry.interfaces.User']);609 ), $event['user']); 556 610 } 557 611 … … 592 646 } 593 647 594 public function cb1($data) { 648 public function testGetLastEventID() 649 { 650 $client = new Dummy_Raven_Client(); 651 $client->capture(array('message' => 'test', 'event_id' => 'abc')); 652 $this->assertEquals($client->getLastEventID(), 'abc'); 653 } 654 655 public function cb1($data) 656 { 595 657 $this->assertEquals('test', $data['message']); 596 658 return false; 597 659 } 598 660 599 public function cb2($data) { 661 public function cb2($data) 662 { 600 663 $this->assertEquals('test', $data['message']); 601 664 return true; … … 604 667 public function testSendCallback() 605 668 { 606 607 669 $client = new Dummy_Raven_Client(array('send_callback' => array($this, 'cb1'))); 608 670 $client->captureMessage('test'); … … 615 677 $this->assertEquals(1, count($events)); 616 678 } 679 680 /** 681 * Set the server array to the test values, check the current url 682 * 683 * @dataProvider currentUrlProvider 684 * @param array $serverData 685 * @param array $options 686 * @param string $expected - the url expected 687 * @param string $message - fail message 688 */ 689 public function testCurrentUrl($serverVars, $options, $expected, $message) 690 { 691 $_SERVER = $serverVars; 692 693 $client = new Dummy_Raven_Client($options); 694 $result = $client->test_get_current_url(); 695 696 $this->assertSame($expected, $result, $message); 697 } 698 699 /** 700 * Arrays of: 701 * $_SERVER data 702 * config 703 * expected url 704 * Fail message 705 * 706 * @return array 707 */ 708 public function currentUrlProvider() 709 { 710 return array( 711 array( 712 array(), 713 array(), 714 null, 715 'No url expected for empty REQUEST_URI' 716 ), 717 array( 718 array( 719 'REQUEST_URI' => '/', 720 'HTTP_HOST' => 'example.com', 721 ), 722 array(), 723 'http://example.com/', 724 'The url is expected to be http with the request uri' 725 ), 726 array( 727 array( 728 'REQUEST_URI' => '/', 729 'HTTP_HOST' => 'example.com', 730 'HTTPS' => 'on' 731 ), 732 array(), 733 'https://example.com/', 734 'The url is expected to be https because of HTTPS on' 735 ), 736 array( 737 array( 738 'REQUEST_URI' => '/', 739 'HTTP_HOST' => 'example.com', 740 'SERVER_PORT' => '443' 741 ), 742 array(), 743 'https://example.com/', 744 'The url is expected to be https because of the server port' 745 ), 746 array( 747 array( 748 'REQUEST_URI' => '/', 749 'HTTP_HOST' => 'example.com', 750 'X-FORWARDED-PROTO' => 'https' 751 ), 752 array(), 753 'http://example.com/', 754 'The url is expected to be http because the X-Forwarded header is ignored' 755 ), 756 array( 757 array( 758 'REQUEST_URI' => '/', 759 'HTTP_HOST' => 'example.com', 760 'X-FORWARDED-PROTO' => 'https' 761 ), 762 array('trust_x_forwarded_proto' => true), 763 'https://example.com/', 764 'The url is expected to be https because the X-Forwarded header is trusted' 765 ) 766 ); 767 } 617 768 } -
getsentry-client/trunk/raven/test/Raven/Tests/ErrorHandlerTest.php
r1098247 r1418133 17 17 { 18 18 $this->errorLevel = error_reporting(); 19 $this->errorHandlerCalled = false; 20 $this->existingErrorHandler = set_error_handler(array($this, 'errorHandler'), -1); 21 } 22 23 public function errorHandler() 24 { 25 $this->errorHandlerCalled = true; 19 26 } 20 27 21 28 public function tearDown() 22 29 { 30 // XXX(dcramer): this isn't great as it doesnt restore the old error reporting level 31 set_error_handler(array($this, 'errorHandler'), error_reporting()); 23 32 error_reporting($this->errorLevel); 24 33 } … … 26 35 public function testErrorsAreLoggedAsExceptions() 27 36 { 28 $client = $this->getMock('Client', array('captureException', 'getIdent' ));37 $client = $this->getMock('Client', array('captureException', 'getIdent', 'sendUnsentErrors')); 29 38 $client->expects($this->once()) 30 39 ->method('captureException') 31 40 ->with($this->isInstanceOf('ErrorException')); 32 41 33 $handler = new Raven_ErrorHandler($client );42 $handler = new Raven_ErrorHandler($client, E_ALL); 34 43 $handler->handleError(E_WARNING, 'message'); 35 44 } … … 48 57 } 49 58 50 public function testErrorHandlerCheckSilentReporting() 59 public function testErrorHandlerPassErrorReportingPass() 60 { 61 $client = $this->getMock('Client', array('captureException', 'getIdent')); 62 $client->expects($this->once()) 63 ->method('captureException'); 64 65 $handler = new Raven_ErrorHandler($client); 66 $handler->registerErrorHandler(false, -1); 67 68 error_reporting(E_USER_WARNING); 69 trigger_error('Warning', E_USER_WARNING); 70 } 71 72 public function testErrorHandlerPropagates() 51 73 { 52 74 $client = $this->getMock('Client', array('captureException', 'getIdent')); 53 75 $client->expects($this->never()) 54 76 ->method('captureException'); 77 78 $handler = new Raven_ErrorHandler($client); 79 $handler->registerErrorHandler(true, E_DEPRECATED); 80 81 error_reporting(E_USER_WARNING); 82 trigger_error('Warning', E_USER_WARNING); 83 84 $this->assertEquals($this->errorHandlerCalled, 1); 85 } 86 87 public function testErrorHandlerRespectsErrorReportingDefault() 88 { 89 $client = $this->getMock('Client', array('captureException', 'getIdent')); 90 $client->expects($this->once()) 91 ->method('captureException'); 92 93 error_reporting(E_DEPRECATED); 94 95 $handler = new Raven_ErrorHandler($client); 96 $handler->registerErrorHandler(true); 97 98 error_reporting(E_ALL); 99 trigger_error('Warning', E_USER_WARNING); 100 101 $this->assertEquals($this->errorHandlerCalled, 1); 102 } 103 104 // Because we cannot **know** that a user silenced an error, we always 105 // defer to respecting the error reporting settings. 106 public function testSilentErrorsAreReported() 107 { 108 $client = $this->getMock('Client', array('captureException', 'getIdent')); 109 $client->expects($this->never()) 110 ->method('captureException'); 111 112 error_reporting(E_USER_WARNING); 55 113 56 114 $handler = new Raven_ErrorHandler($client); … … 60 118 } 61 119 62 public function testErrorHandler BlockErrorReporting()120 public function testErrorHandlerDefaultsErrorReporting() 63 121 { 64 122 $client = $this->getMock('Client', array('captureException', 'getIdent')); … … 66 124 ->method('captureException'); 67 125 68 $handler = new Raven_ErrorHandler($client);69 $handler->registerErrorHandler(false);70 71 126 error_reporting(E_USER_ERROR); 72 trigger_error('Warning', E_USER_WARNING);73 }74 75 public function testErrorHandlerPassErrorReportingPass()76 {77 $client = $this->getMock('Client', array('captureException', 'getIdent'));78 $client->expects($this->once())79 ->method('captureException');80 127 81 128 $handler = new Raven_ErrorHandler($client); 82 129 $handler->registerErrorHandler(false); 83 130 84 error_reporting(E_USER_WARNING);85 131 trigger_error('Warning', E_USER_WARNING); 86 132 } 133 134 public function testFluidInterface() 135 { 136 $client = $this->getMock('Client', array('captureException', 'getIdent')); 137 $handler = new Raven_ErrorHandler($client); 138 $result = $handler->registerErrorHandler(); 139 $this->assertEquals($result, $handler); 140 $result = $handler->registerExceptionHandler(); 141 $this->assertEquals($result, $handler); 142 // TODO(dcramer): cant find a great way to test resetting the shutdown 143 // handler 144 // $result = $handler->registerShutdownHandler(); 145 // $this->assertEquals($result, $handler); 146 } 87 147 } -
getsentry-client/trunk/raven/test/Raven/Tests/SanitizeDataProcessorTest.php
r1098363 r1418133 15 15 { 16 16 $data = array( 17 ' sentry.interfaces.Http' => array(17 'request' => array( 18 18 'data' => array( 19 19 'foo' => 'bar', … … 37 37 $processor->process($data); 38 38 39 $vars = $data[' sentry.interfaces.Http']['data'];39 $vars = $data['request']['data']; 40 40 $this->assertEquals($vars['foo'], 'bar'); 41 41 $this->assertEquals(Raven_SanitizeDataProcessor::MASK, $vars['password']); … … 48 48 49 49 $this->assertEquals(Raven_SanitizeDataProcessor::MASK, $vars['card_number']['0']); 50 } 51 52 public function testDoesFilterSessionId() 53 { 54 $data = array( 55 'request' => array( 56 'cookies' => array( 57 ini_get('session.name') => 'abc', 58 ), 59 ) 60 ); 61 62 $client = new Raven_Client(); 63 $processor = new Raven_SanitizeDataProcessor($client); 64 $processor->process($data); 65 66 $cookies = $data['request']['cookies']; 67 $this->assertEquals($cookies[ini_get('session.name')], Raven_SanitizeDataProcessor::MASK); 50 68 } 51 69 … … 67 85 * 68 86 */ 69 public function testSettingProcessorOptions(){ 87 public function testSettingProcessorOptions() 88 { 70 89 $client = new Raven_Client(); 71 90 $processor = new Raven_SanitizeDataProcessor($client); 72 91 73 $this->assertEquals($processor->getFieldsRe(), '/(authorization|password|passwd|secret|password_confirmation|card_number )/i','got default fields');74 $this->assertEquals($processor->getValuesRe(), '/^(?:\d[ -]*?){13,16}$/','got default values');92 $this->assertEquals($processor->getFieldsRe(), '/(authorization|password|passwd|secret|password_confirmation|card_number|auth_pw)/i', 'got default fields'); 93 $this->assertEquals($processor->getValuesRe(), '/^(?:\d[ -]*?){13,16}$/', 'got default values'); 75 94 76 95 $options = array( … … 81 100 $processor->setProcessorOptions($options); 82 101 83 $this->assertEquals($processor->getFieldsRe(), '/(api_token)/i', 'overwrote fields');84 $this->assertEquals($processor->getValuesRe(), '/^(?:\d[ -]*?){15,16}$/', 'overwrote values');102 $this->assertEquals($processor->getFieldsRe(), '/(api_token)/i', 'overwrote fields'); 103 $this->assertEquals($processor->getValuesRe(), '/^(?:\d[ -]*?){15,16}$/', 'overwrote values'); 85 104 } 86 105 … … 92 111 * @param $dsn 93 112 */ 94 public function testOverrideOptions($processorOptions, $client_options, $dsn){ 113 public function testOverrideOptions($processorOptions, $client_options, $dsn) 114 { 95 115 $client = new Raven_Client($dsn, $client_options); 96 116 $processor = $client->processors[0]; 97 117 98 118 $this->assertInstanceOf('Raven_SanitizeDataProcessor', $processor); 99 $this->assertEquals($processor->getFieldsRe(), $processorOptions['Raven_SanitizeDataProcessor']['fields_re'], 'overwrote fields');100 $this->assertEquals($processor->getValuesRe(), $processorOptions['Raven_SanitizeDataProcessor']['values_re'], 'overwrote values');119 $this->assertEquals($processor->getFieldsRe(), $processorOptions['Raven_SanitizeDataProcessor']['fields_re'], 'overwrote fields'); 120 $this->assertEquals($processor->getValuesRe(), $processorOptions['Raven_SanitizeDataProcessor']['values_re'], 'overwrote values'); 101 121 } 102 122 … … 109 129 * @param $dsn 110 130 */ 111 public function testOverridenSanitize($processorOptions, $client_options, $dsn){ 131 public function testOverridenSanitize($processorOptions, $client_options, $dsn) 132 { 112 133 $data = array( 113 ' sentry.interfaces.Http' => array(134 'request' => array( 114 135 'data' => array( 115 136 'foo' => 'bar', … … 132 153 133 154 $this->assertInstanceOf('Raven_SanitizeDataProcessor', $processor); 134 $this->assertEquals($processor->getFieldsRe(), $processorOptions['Raven_SanitizeDataProcessor']['fields_re'], 'overwrote fields');135 $this->assertEquals($processor->getValuesRe(), $processorOptions['Raven_SanitizeDataProcessor']['values_re'], 'overwrote values');155 $this->assertEquals($processor->getFieldsRe(), $processorOptions['Raven_SanitizeDataProcessor']['fields_re'], 'overwrote fields'); 156 $this->assertEquals($processor->getValuesRe(), $processorOptions['Raven_SanitizeDataProcessor']['values_re'], 'overwrote values'); 136 157 137 158 $processor->process($data); 138 159 139 $vars = $data[' sentry.interfaces.Http']['data'];140 $this->assertEquals($vars['foo'], 'bar', 'did not alter foo');141 $this->assertEquals($vars['password'], 'hello', 'did not alter password');142 $this->assertEquals($vars['the_secret'], 'hello','did not alter the_secret');143 $this->assertEquals($vars['a_password_here'], 'hello','did not alter a_password_here');144 $this->assertEquals($vars['mypasswd'], 'hello','did not alter mypasswd');145 $this->assertEquals($vars['authorization'], 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=','did not alter authorization');146 $this->assertEquals(Raven_SanitizeDataProcessor::MASK, $vars['api_token'], 'masked api_token');160 $vars = $data['request']['data']; 161 $this->assertEquals($vars['foo'], 'bar', 'did not alter foo'); 162 $this->assertEquals($vars['password'], 'hello', 'did not alter password'); 163 $this->assertEquals($vars['the_secret'], 'hello', 'did not alter the_secret'); 164 $this->assertEquals($vars['a_password_here'], 'hello', 'did not alter a_password_here'); 165 $this->assertEquals($vars['mypasswd'], 'hello', 'did not alter mypasswd'); 166 $this->assertEquals($vars['authorization'], 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'did not alter authorization'); 167 $this->assertEquals(Raven_SanitizeDataProcessor::MASK, $vars['api_token'], 'masked api_token'); 147 168 148 169 $this->assertEquals(Raven_SanitizeDataProcessor::MASK, $vars['card_number']['0'], 'masked card_number[0]'); 149 $this->assertEquals($vars['card_number']['1'], $vars['card_number']['1'], 'did not alter card_number[1]');170 $this->assertEquals($vars['card_number']['1'], $vars['card_number']['1'], 'did not alter card_number[1]'); 150 171 } 151 172 … … 155 176 * @return array 156 177 */ 157 public static function overrideDataProvider(){ 178 public static function overrideDataProvider() 179 { 158 180 $processorOptions = array( 159 181 'Raven_SanitizeDataProcessor' => array( -
getsentry-client/trunk/raven/test/Raven/Tests/SerializerTest.php
r1098247 r1418133 19 19 public function testArraysAreArrays() 20 20 { 21 $serializer = new Raven_Serializer(); 21 22 $input = array(1, 2, 3); 22 $result = Raven_Serializer::serialize($input);23 $result = $serializer->serialize($input); 23 24 $this->assertEquals(array('1', '2', '3'), $result); 24 25 } … … 26 27 public function testObjectsAreStrings() 27 28 { 29 $serializer = new Raven_Serializer(); 28 30 $input = new Raven_StacktraceTestObject(); 29 $result = Raven_Serializer::serialize($input);31 $result = $serializer->serialize($input); 30 32 $this->assertEquals('Object Raven_StacktraceTestObject', $result); 31 33 } … … 33 35 public function testIntsAreInts() 34 36 { 37 $serializer = new Raven_Serializer(); 35 38 $input = 1; 36 $result = Raven_Serializer::serialize($input);39 $result = $serializer->serialize($input); 37 40 $this->assertTrue(is_integer($result)); 38 41 $this->assertEquals(1, $result); 39 42 } 40 43 44 public function testFloats() 45 { 46 $serializer = new Raven_Serializer(); 47 $input = 1.5; 48 $result = $serializer->serialize($input); 49 $this->assertTrue(is_float($result)); 50 $this->assertEquals(1.5, $result); 51 } 52 53 public function testBooleans() 54 { 55 $serializer = new Raven_Serializer(); 56 $input = true; 57 $result = $serializer->serialize($input); 58 $this->assertTrue(is_bool($result)); 59 $this->assertEquals(true, $result); 60 61 $input = false; 62 $result = $serializer->serialize($input); 63 $this->assertTrue(is_bool($result)); 64 $this->assertEquals(false, $result); 65 } 66 67 public function testNull() 68 { 69 $serializer = new Raven_Serializer(); 70 $input = null; 71 $result = $serializer->serialize($input); 72 $this->assertTrue(is_null($result)); 73 $this->assertEquals(null, $result); 74 } 75 41 76 public function testRecursionMaxDepth() 42 77 { 78 $serializer = new Raven_Serializer(); 43 79 $input = array(); 44 80 $input[] = &$input; 45 $result = Raven_Serializer::serialize($input, 3);81 $result = $serializer->serialize($input, 3); 46 82 $this->assertEquals(array(array(array('Array of length 1'))), $result); 47 83 } 48 49 84 } -
getsentry-client/trunk/raven/test/Raven/Tests/StacktraceTest.php
r1098247 r1418133 70 70 $this->assertEquals('include_once', $frame["function"]); 71 71 $this->assertEquals('a_test($foo);', $frame["context_line"]); 72 73 74 72 } 75 73 … … 109 107 $this->assertEquals('friend', $frame['vars']['param1']); 110 108 $this->assertEquals('a_test($foo);', $frame["context_line"]); 111 112 113 109 } 114 110 … … 153 149 $this->assertEquals('a_test($foo);', $frame["context_line"]); 154 150 $this->assertEquals($vars, $frame['vars']); 155 156 151 } 152 153 public function testDoesNotModifyCaptureVars() 154 { 155 $stack = array( 156 array( 157 "file" => dirname(__FILE__) . "/resources/a.php", 158 "line" => 11, 159 "function" => "a_test", 160 "args"=> array( 161 "friend", 162 ), 163 ), 164 array( 165 "file" => dirname(__FILE__) . "/resources/b.php", 166 "line" => 3, 167 "args"=> array( 168 "/tmp/a.php", 169 ), 170 "function" => "include_once", 171 ), 172 ); 173 174 // PHP's errcontext as passed to the error handler contains REFERENCES to any vars that were in the global scope. 175 // Modification of these would be really bad, since if control is returned (non-fatal error) we'll have altered the state of things! 176 $originalFoo = "bloopblarp"; 177 $iAmFoo = $originalFoo; 178 $vars = array( 179 "foo" => &$iAmFoo 180 ); 181 182 $frames = Raven_Stacktrace::get_stack_info($stack, true, true, $vars, 5); 183 184 // Check we haven't modified our vars. 185 $this->assertEquals($originalFoo, $vars["foo"]); 186 187 $frame = $frames[1]; 188 // Check that we did truncate the variable in our output 189 $this->assertEquals(5, strlen($frame['vars']['foo'])); 157 190 } 158 191 … … 197 230 $this->assertEquals($vars, $frame['vars']); 198 231 $this->assertEquals('a_test($foo);', $frame["context_line"]); 199 200 201 232 } 202 233 … … 229 260 $this->assertEquals('raven_test_recurse', $frame['function']); 230 261 } 262 263 public function testInApp() 264 { 265 $stack = array( 266 array( 267 "file" => dirname(__FILE__) . "/resources/a.php", 268 "line" => 11, 269 "function" => "a_test", 270 ), 271 array( 272 "file" => dirname(__FILE__) . "/resources/b.php", 273 "line" => 3, 274 "function" => "include_once", 275 ), 276 ); 277 278 $frames = Raven_Stacktrace::get_stack_info($stack, true, null, null, 0, null, dirname(__FILE__)); 279 280 $this->assertEquals($frames[0]['in_app'], true); 281 $this->assertEquals($frames[1]['in_app'], true); 282 } 283 284 public function testBasePath() 285 { 286 $stack = array( 287 array( 288 "file" => dirname(__FILE__) . "/resources/a.php", 289 "line" => 11, 290 "function" => "a_test", 291 ), 292 array( 293 "file" => dirname(__FILE__) . "/resources/b.php", 294 "line" => 3, 295 "function" => "include_once", 296 ), 297 ); 298 299 $frames = Raven_Stacktrace::get_stack_info($stack, true, null, null, 0, array(dirname(__FILE__))); 300 301 $this->assertEquals($frames[0]['filename'], 'resources/b.php'); 302 $this->assertEquals($frames[1]['filename'], 'resources/a.php'); 303 } 231 304 } -
getsentry-client/trunk/readme.txt
r1344226 r1418133 5 5 Requires at least: 3.0.1 6 6 Tested up to: 3.4 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 28 28 29 29 == Changelog == 30 31 = 1.1 = 32 33 Upgrade raven php client to v0.15.0 30 34 31 35 = 1.0 =
Note: See TracChangeset
for help on using the changeset viewer.