From d391712a9023b66897937c336eab152702cfa1a9 Mon Sep 17 00:00:00 2001 From: Nikita Date: Fri, 9 Feb 2018 10:59:11 +0200 Subject: [PATCH 01/13] Fix gzipCompress function name PHP doesn't have `gzipCompress` function, use `gzcompress` instead http://php.net/manual/en/function.gzcompress.php --- docs/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.rst b/docs/config.rst index ddfbababb..56538caaa 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -171,7 +171,7 @@ The following settings are available for the client: 'User-Agent' => $client->getUserAgent(), 'X-Sentry-Auth' => $client->getAuthHeader(), ), - 'body' => gzipCompress(jsonEncode($data)), + 'body' => gzcompress(jsonEncode($data)), )) }, From 1e6153d0a0667d91672efee9a2d31b10ffe30c64 Mon Sep 17 00:00:00 2001 From: Ryan White Date: Tue, 13 Feb 2018 03:49:55 -0500 Subject: [PATCH 02/13] Adding application/json input handling. (#546) * Adding application/json input handling. * Updated tests for negative test case --- lib/Raven/Client.php | 20 ++++++ test/Raven/Tests/ClientTest.php | 110 +++++++++++++++++++++++++++++++- 2 files changed, 128 insertions(+), 2 deletions(-) diff --git a/lib/Raven/Client.php b/lib/Raven/Client.php index 85492a57e..9c0b2c9a5 100644 --- a/lib/Raven/Client.php +++ b/lib/Raven/Client.php @@ -276,6 +276,21 @@ public function setEnvironment($value) return $this; } + /** + * Note: Prior to PHP 5.6, a stream opened with php://input can + * only be read once; + * + * @see http://php.net/manual/en/wrappers.php.php + */ + protected static function getInputStream() + { + if (PHP_VERSION_ID < 50600) { + return null; + } + + return file_get_contents('php://input'); + } + private static function getDefaultPrefixes() { $value = get_include_path(); @@ -748,6 +763,11 @@ protected function get_http_data() // instead of a mapping which goes against the defined Sentry spec if (!empty($_POST)) { $result['data'] = $_POST; + } elseif (isset($_SERVER['CONTENT_TYPE']) && stripos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) { + $raw_data = $this->getInputStream() ?: false; + if ($raw_data !== false) { + $result['data'] = (array) json_decode($raw_data, true) ?: null; + } } if (!empty($_COOKIE)) { $result['cookies'] = $_COOKIE; diff --git a/test/Raven/Tests/ClientTest.php b/test/Raven/Tests/ClientTest.php index 82eb49d28..0c63e189f 100644 --- a/test/Raven/Tests/ClientTest.php +++ b/test/Raven/Tests/ClientTest.php @@ -25,6 +25,7 @@ function invalid_encoding() class Dummy_Raven_Client extends Raven_Client { private $__sent_events = array(); + private static $input_stream; public $dummy_breadcrumbs_handlers_has_set = false; public $dummy_shutdown_handlers_has_set = false; @@ -62,6 +63,16 @@ public function get_user_data() return parent::get_user_data(); } + public function setInputStream($input) + { + static::$input_stream = isset($_SERVER['CONTENT_TYPE']) ? $input : false; + } + + protected static function getInputStream() + { + return static::$input_stream ? static::$input_stream : file_get_contents('php://input'); + } + public function buildCurlCommand($url, $data, $headers) { return parent::buildCurlCommand($url, $data, $headers); @@ -789,7 +800,7 @@ public function testGetHttpData() 'SERVER_PORT' => '443', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'PATCH', - 'QUERY_STRING' => 'q=bitch&l=en', + 'QUERY_STRING' => 'q=foobar&l=en', 'REQUEST_URI' => '/welcome/', 'SCRIPT_NAME' => '/index.php', ); @@ -804,7 +815,7 @@ public function testGetHttpData() 'request' => array( 'method' => 'PATCH', 'url' => 'https://getsentry.com/welcome/', - 'query_string' => 'q=bitch&l=en', + 'query_string' => 'q=foobar&l=en', 'data' => array( 'stamp' => '1c', ), @@ -826,6 +837,101 @@ public function testGetHttpData() $this->assertEquals($expected, $client->get_http_data()); } + /** + * @backupGlobals + * @covers Raven_Client::get_http_data + */ + public function testGetHttpDataApplicationJson() + { + $_SERVER = array( + 'REDIRECT_STATUS' => '200', + 'CONTENT_TYPE' => 'application/json', + 'CONTENT_LENGTH' => '99', + 'HTTP_HOST' => 'getsentry.com', + 'HTTP_ACCEPT' => 'text/html', + 'HTTP_ACCEPT_CHARSET' => 'utf-8', + 'HTTP_COOKIE' => 'cupcake: strawberry', + 'SERVER_PORT' => '443', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'REQUEST_METHOD' => 'POST', + 'QUERY_STRING' => 'q=foobar&l=en', + 'REQUEST_URI' => '/welcome/', + 'SCRIPT_NAME' => '/index.php', + ); + $_COOKIE = array( + 'donut' => 'chocolat', + ); + + $expected = array( + 'request' => array( + 'method' => 'POST', + 'url' => 'https://getsentry.com/welcome/', + 'query_string' => 'q=foobar&l=en', + 'data' => array( + 'json_test' => 'json_data', + ), + 'cookies' => array( + 'donut' => 'chocolat', + ), + 'headers' => array( + 'Host' => 'getsentry.com', + 'Accept' => 'text/html', + 'Accept-Charset' => 'utf-8', + 'Cookie' => 'cupcake: strawberry', + 'Content-Type' => 'application/json', + 'Content-Length' => '99', + ), + ) + ); + + $client = new Dummy_Raven_Client(); + $client->setInputStream(json_encode(array('json_test' => 'json_data'))); + + $this->assertEquals($expected, $client->get_http_data()); + } + + /** + * Test showing that invalid json will be discarded from data collection. + */ + public function testGetHttpDataApplicationInvalidJson() + { + $_SERVER = array( + 'REDIRECT_STATUS' => '200', + 'CONTENT_TYPE' => 'application/json', + 'CONTENT_LENGTH' => '99', + 'HTTP_HOST' => 'getsentry.com', + 'HTTP_ACCEPT' => 'text/html', + 'HTTP_ACCEPT_CHARSET' => 'utf-8', + 'HTTP_COOKIE' => 'cupcake: strawberry', + 'SERVER_PORT' => '443', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'REQUEST_METHOD' => 'POST', + 'REQUEST_URI' => '/welcome/', + 'SCRIPT_NAME' => '/index.php', + ); + + $expected = array( + 'request' => array( + 'method' => 'POST', + 'url' => 'https://getsentry.com/welcome/', + 'query_string' => '', + 'data' => null, + 'headers' => array( + 'Host' => 'getsentry.com', + 'Accept' => 'text/html', + 'Accept-Charset' => 'utf-8', + 'Cookie' => 'cupcake: strawberry', + 'Content-Type' => 'application/json', + 'Content-Length' => '99', + ), + ) + ); + + $client = new Dummy_Raven_Client(); + $client->setInputStream('{"binary_json":"'.pack("NA3CC", 3, "aBc", 0x0D, 0x0A).'"}'); + $this->assertEquals($expected, $client->get_http_data()); + } + /** * @covers Raven_Client::user_context * @covers Raven_Client::get_user_data From 7201cc1e58266e11cc5eb2db1685889df26ead9c Mon Sep 17 00:00:00 2001 From: mark burdett Date: Tue, 13 Feb 2018 00:53:04 -0800 Subject: [PATCH 03/13] Use correct class name for default processor in the docs (#547) In version 1.7.0 the default processor class changed from Raven_SanitizeDataProcessor to Raven_Processor_SanitizeDataProcessor This means the sample config documentation would be wrong for someone who didn't customize their processors. --- docs/config.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 56538caaa..952e4f470 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -221,7 +221,7 @@ The following settings are available for the client: .. describe:: processors An array of classes to use to process data before it is sent to - Sentry. By default, ``Raven_SanitizeDataProcessor`` is used + Sentry. By default, ``Raven_Processor_SanitizeDataProcessor`` is used .. describe:: processorOptions @@ -230,12 +230,12 @@ The following settings are available for the client: the list of processors used by ``Raven_Client`` An example of overriding the regular expressions in - ``Raven_SanitizeDataProcessor`` is below: + ``Raven_Processor_SanitizeDataProcessor`` is below: .. code-block:: php 'processorOptions' => array( - 'Raven_SanitizeDataProcessor' => array( + 'Raven_Processor_SanitizeDataProcessor' => array( 'fields_re' => '/(user_password|user_token|user_secret)/i', 'values_re' => '/^(?:\d[ -]*?){15,16}$/' ) From 25a2134ad9461e375baa22fe1e186796edab60a9 Mon Sep 17 00:00:00 2001 From: tiger-seo Date: Wed, 14 Feb 2018 11:29:00 +0200 Subject: [PATCH 04/13] Update Client.php (#548) fixing Doctrine\Common\Annotations\AnnotationException with message [Semantical Error] The annotation "@doc" in method Raven_Client::parseDSN() was never imported. Did maybe forget to add a "use" statement for this annotation? --- lib/Raven/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Raven/Client.php b/lib/Raven/Client.php index 9c0b2c9a5..7d155fffd 100644 --- a/lib/Raven/Client.php +++ b/lib/Raven/Client.php @@ -452,7 +452,7 @@ public function setProcessorsFromOptions($options) * @param string $dsn Raven compatible DSN * @return array parsed DSN * - * @doc http://raven.readthedocs.org/en/latest/config/#the-sentry-dsn + * @see http://raven.readthedocs.org/en/latest/config/#the-sentry-dsn */ public static function parseDSN($dsn) { @@ -1062,7 +1062,7 @@ protected static function get_default_ca_cert() /** * @return array - * @doc http://stackoverflow.com/questions/9062798/php-curl-timeout-is-not-working/9063006#9063006 + * @see http://stackoverflow.com/questions/9062798/php-curl-timeout-is-not-working/9063006#9063006 */ protected function get_curl_options() { From 4dd0a3ed35371a5e47b4a46dd90414b2831eac3f Mon Sep 17 00:00:00 2001 From: Elias Ojala Date: Sat, 17 Feb 2018 17:01:12 +0200 Subject: [PATCH 05/13] Added syntax highlighting to README.md (#551) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f9366039..d57d6f415 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ $ git checkout -b releases/1.9.x 3. Update the hardcoded version tag in ``Client.php``: -``` +```php class Raven_Client { const VERSION = '1.9.0'; @@ -142,7 +142,7 @@ git checkout master 9. Update the version in ``Client.php``: -``` +```php class Raven_Client { const VERSION = '1.10.x-dev'; @@ -151,7 +151,7 @@ class Raven_Client 10. Lastly, update the composer version in ``composer.json``: -``` +```json "extra": { "branch-alias": { "dev-master": "1.10.x-dev" From 389c3ac9540f6684f3b0946bffbf2703d287c4f1 Mon Sep 17 00:00:00 2001 From: ismaail Date: Thu, 22 Feb 2018 19:27:11 +0000 Subject: [PATCH 06/13] Add use statement for HttpException class --- docs/integrations/laravel.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/integrations/laravel.rst b/docs/integrations/laravel.rst index acd72a337..60b3ba167 100644 --- a/docs/integrations/laravel.rst +++ b/docs/integrations/laravel.rst @@ -64,6 +64,8 @@ step is not required anymore an you can skip ahead to the next one: Date: Mon, 26 Feb 2018 10:35:59 +0100 Subject: [PATCH 07/13] Change badge with badge poser. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d57d6f415..f99bf4233 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ # Sentry for PHP [![Build Status](https://secure.travis-ci.org/getsentry/sentry-php.png?branch=master)](http://travis-ci.org/getsentry/sentry-php) -[![Total Downloads](https://img.shields.io/packagist/dt/sentry/sentry.svg?style=flat-square)](https://packagist.org/packages/sentry/sentry) -[![Downloads per month](https://img.shields.io/packagist/dm/sentry/sentry.svg?style=flat-square)](https://packagist.org/packages/sentry/sentry) -[![Latest stable version](https://img.shields.io/packagist/v/sentry/sentry.svg?style=flat-square)](https://packagist.org/packages/sentry/sentry) -[![License](http://img.shields.io/packagist/l/sentry/sentry.svg?style=flat-square)](https://packagist.org/packages/sentry/sentry) +[![Total Downloads](https://poser.pugx.org/sentry/sentry/downloads)](https://packagist.org/packages/sentry/sentry) +[![Monthly Downloads](https://poser.pugx.org/sentry/sentry/d/monthly)](https://packagist.org/packages/sentry/sentry) +[![Latest Stable Version](https://poser.pugx.org/sentry/sentry/v/stable)](https://packagist.org/packages/sentry/sentry) +[![License](https://poser.pugx.org/sentry/sentry/license)](https://packagist.org/packages/sentry/sentry) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/getsentry/sentry-php/master.svg)](https://scrutinizer-ci.com/g/getsentry/sentry-php/) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/getsentry/sentry-php/master.svg)](https://scrutinizer-ci.com/g/getsentry/sentry-php/) From 351cb63da6fc40dbb2a8324e0b3fdff2e7dcc55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20St=C3=BCcklschwaiger?= Date: Mon, 26 Feb 2018 23:43:34 +0100 Subject: [PATCH 08/13] Cleanup the 'site' value if it's empty (#555) * Cleanup the 'site' value if it's empty * Add test if 'site' param really gets cleared --- lib/Raven/Client.php | 3 +++ test/Raven/Tests/ClientTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/Raven/Client.php b/lib/Raven/Client.php index 7d155fffd..f9887b213 100644 --- a/lib/Raven/Client.php +++ b/lib/Raven/Client.php @@ -881,6 +881,9 @@ public function capture($data, $stack = null, $vars = null) if (empty($data['request'])) { unset($data['request']); } + if (empty($data['site'])) { + unset($data['site']); + } if (!$this->breadcrumbs->is_empty()) { $data['breadcrumbs'] = $this->breadcrumbs->fetch(); diff --git a/test/Raven/Tests/ClientTest.php b/test/Raven/Tests/ClientTest.php index 0c63e189f..b8fb70bf9 100644 --- a/test/Raven/Tests/ClientTest.php +++ b/test/Raven/Tests/ClientTest.php @@ -760,6 +760,21 @@ public function testDefaultProcessorsContainSanitizeDataProcessor() } /** + * @covers Raven_Client::capture + */ + public function testEmptySiteGetsRemoved() + { + $client = new Dummy_Raven_Client(); + $client->site = ''; + + $client->captureMessage("My message"); + $events = $client->getSentEvents(); + $this->assertSame(1, count($events)); + $event = array_pop($events); + $this->assertFalse(array_key_exists('site', $event)); + } + + /** * @covers Raven_Client::__construct * @covers Raven_Client::get_default_data */ From 9d842774a3b09e7cf0b7acf8eda729d5314534f7 Mon Sep 17 00:00:00 2001 From: Helmut Januschka Date: Thu, 15 Mar 2018 11:09:38 +0100 Subject: [PATCH 09/13] Add runtime information (#564) * add php runtime information * add more tests * also support user provided runtime context * change array_merge order so [runtime][name|version] is overrideable * add test for overriden runtime --- lib/Raven/Client.php | 4 ++ test/Raven/Tests/ClientTest.php | 92 +++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) diff --git a/lib/Raven/Client.php b/lib/Raven/Client.php index f9887b213..d547760f0 100644 --- a/lib/Raven/Client.php +++ b/lib/Raven/Client.php @@ -885,6 +885,10 @@ public function capture($data, $stack = null, $vars = null) unset($data['site']); } + $existing_runtime_context = isset($data['contexts']['runtime']) ? $data['contexts']['runtime'] : array(); + $runtime_context = array('version' => PHP_VERSION, 'name' => 'php'); + $data['contexts']['runtime'] = array_merge($runtime_context, $existing_runtime_context); + if (!$this->breadcrumbs->is_empty()) { $data['breadcrumbs'] = $this->breadcrumbs->fetch(); } diff --git a/test/Raven/Tests/ClientTest.php b/test/Raven/Tests/ClientTest.php index b8fb70bf9..95e114f58 100644 --- a/test/Raven/Tests/ClientTest.php +++ b/test/Raven/Tests/ClientTest.php @@ -1035,6 +1035,98 @@ public function testCaptureMessageWithUserContext() ), $event['user']); } + /** + * @covers Raven_Client::capture + */ + public function testRuntimeContext() + { + $client = new Dummy_Raven_Client(); + + $client->captureMessage('test'); + $events = $client->getSentEvents(); + $event = array_pop($events); + $this->assertEquals(PHP_VERSION, $event['contexts']['runtime']['version']); + $this->assertEquals('php', $event['contexts']['runtime']['name']); + } + + /** + * @covers Raven_Client::capture + */ + public function testRuntimeOnCustomContext() + { + $client = new Dummy_Raven_Client(); + + $data = array('contexts' => array( + 'mine' => array( + 'line' => 1216, + 'stack' => array( + 1, array( + 'foo' => 'bar', + 'level4' => array(array('level5', 'level5 a'), 2), + ), 3 + ), + ), + )); + + $client->captureMessage('test', array(), $data); + + $events = $client->getSentEvents(); + $event = array_pop($events); + $this->assertEquals(PHP_VERSION, $event['contexts']['runtime']['version']); + $this->assertEquals('php', $event['contexts']['runtime']['name']); + $this->assertEquals(1216, $event['contexts']['mine']['line']); + } + + /** + * @covers Raven_Client::capture + */ + public function testRuntimeOnOverrideRuntimeItself() + { + $client = new Dummy_Raven_Client(); + + $data = array('contexts' => array( + 'runtime' => array( + 'name' => 'sentry', + 'version' => '0.1.1-alpha.1' + ), + )); + + $client->captureMessage('test', array(), $data); + + $events = $client->getSentEvents(); + $event = array_pop($events); + $this->assertEquals('0.1.1-alpha.1', $event['contexts']['runtime']['version']); + $this->assertEquals('sentry', $event['contexts']['runtime']['name']); + } + + /** + * @covers Raven_Client::capture + */ + public function testRuntimeOnExistingRuntimeContext() + { + $client = new Dummy_Raven_Client(); + + $data = array('contexts' => array( + 'runtime' => array( + 'line' => 1216, + 'stack' => array( + 1, array( + 'foo' => 'bar', + 'level4' => array(array('level5', 'level5 a'), 2), + ), 3 + ), + ), + )); + + $client->captureMessage('test', array(), $data); + + $events = $client->getSentEvents(); + $event = array_pop($events); + $this->assertEquals(PHP_VERSION, $event['contexts']['runtime']['version']); + $this->assertEquals('php', $event['contexts']['runtime']['name']); + $this->assertEquals(1216, $event['contexts']['runtime']['line']); + } + /** * @covers Raven_Client::captureMessage */ From f9c90cfef3624197b8a8d2bce760a70e799f7a14 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Sun, 18 Mar 2018 16:40:46 +0100 Subject: [PATCH 10/13] Update docs config --- docs/sentry-doc-config.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/sentry-doc-config.json b/docs/sentry-doc-config.json index fe0854355..972fa207d 100644 --- a/docs/sentry-doc-config.json +++ b/docs/sentry-doc-config.json @@ -16,8 +16,9 @@ "type": "framework", "doc_link": "integrations/laravel/", "wizard": [ - "index#installation", - "integrations/laravel#laravel-5-x" + "integrations/laravel#laravel-5-x", + "integrations/laravel#laravel-4-x", + "integrations/laravel#lumen-5-x" ] }, "php.monolog": { @@ -34,7 +35,6 @@ "type": "framework", "doc_link": "integrations/symfony2/", "wizard": [ - "index#installation", "integrations/symfony2#symfony-2" ] } From 047f0d38833c6ef6eec7c1b7acbe2932be62bb8f Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Tue, 20 Mar 2018 13:18:01 +0100 Subject: [PATCH 11/13] Try to fix #552 allowing all fatals to be captured; add regression PHPT test (#571) --- lib/Raven/ErrorHandler.php | 7 ----- test/Raven/Tests/ErrorHandlerTest.php | 2 -- .../phpt/fatal_reported_twice_regression.phpt | 30 +++++++++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 test/Raven/phpt/fatal_reported_twice_regression.phpt diff --git a/lib/Raven/ErrorHandler.php b/lib/Raven/ErrorHandler.php index 54e8984d2..21358c1ad 100644 --- a/lib/Raven/ErrorHandler.php +++ b/lib/Raven/ErrorHandler.php @@ -140,13 +140,6 @@ public function handleFatalError() public function shouldCaptureFatalError($type) { - // Do not capture E_ERROR since those can be caught by userland since PHP 7.0 - // E_ERROR should already be handled by the exception handler - // This prevents duplicated exceptions in PHP 7.0+ - if (PHP_VERSION_ID >= 70000 && $type === E_ERROR) { - return false; - } - return $type & $this->fatal_error_types; } diff --git a/test/Raven/Tests/ErrorHandlerTest.php b/test/Raven/Tests/ErrorHandlerTest.php index c19b02b91..83ee025d7 100644 --- a/test/Raven/Tests/ErrorHandlerTest.php +++ b/test/Raven/Tests/ErrorHandlerTest.php @@ -207,8 +207,6 @@ public function testShouldCaptureFatalErrorBehavior() ->getMock(); $handler = new Raven_ErrorHandler($client); - $this->assertEquals($handler->shouldCaptureFatalError(E_ERROR), PHP_VERSION_ID < 70000); - $this->assertEquals($handler->shouldCaptureFatalError(E_WARNING), false); } diff --git a/test/Raven/phpt/fatal_reported_twice_regression.phpt b/test/Raven/phpt/fatal_reported_twice_regression.phpt new file mode 100644 index 000000000..1ff56ab2a --- /dev/null +++ b/test/Raven/phpt/fatal_reported_twice_regression.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test that, when handling a fatal, we report it once and only once +--FILE-- +getLastEventID() !== null ? 'reported correctly' : 'NOT reported'); +}); + +set_exception_handler(function () { + echo 'This should not be called'; +}); + +$client->install(); + +require 'inexistent_file.php'; +?> +--EXPECTF-- +Previous error handler is called +Error is reported correctly +Fatal error: %a From 402199fa1124fb93969ee43f88bc7d8a36ba82b7 Mon Sep 17 00:00:00 2001 From: Thomas Rothe Date: Mon, 5 Mar 2018 08:59:12 +0100 Subject: [PATCH 12/13] Handle and add non default port to host (#558) --- lib/Raven/Client.php | 5 +++++ test/Raven/Tests/ClientTest.php | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/Raven/Client.php b/lib/Raven/Client.php index d547760f0..984cb851f 100644 --- a/lib/Raven/Client.php +++ b/lib/Raven/Client.php @@ -1306,6 +1306,11 @@ protected function get_current_url() : (!empty($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : (!empty($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : ''))); + $hasNonDefaultPort = !empty($_SERVER['SERVER_PORT']) && !in_array((int)$_SERVER['SERVER_PORT'], array(80, 443)); + if ($hasNonDefaultPort && !preg_match('#:[0-9]*$#', $host)) { + $host .= ':' . $_SERVER['SERVER_PORT']; + } + $httpS = $this->isHttps() ? 's' : ''; return "http{$httpS}://{$host}{$_SERVER['REQUEST_URI']}"; } diff --git a/test/Raven/Tests/ClientTest.php b/test/Raven/Tests/ClientTest.php index 95e114f58..528eddabe 100644 --- a/test/Raven/Tests/ClientTest.php +++ b/test/Raven/Tests/ClientTest.php @@ -1665,6 +1665,16 @@ public function currentUrlProvider() array('trust_x_forwarded_proto' => true), 'https://example.com/', 'The url is expected to be https because the X-Forwarded header is trusted' + ), + array( + array( + 'REQUEST_URI' => '/', + 'HTTP_HOST' => 'example.com', + 'SERVER_PORT' => 81 + ), + array(), + 'http://example.com:81/', + 'Port is not appended' ) ); } From d8154bf6e604be48769c76134cecd1886d8a5fee Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Tue, 20 Mar 2018 13:35:39 +0100 Subject: [PATCH 13/13] Update changelog for version 1.8.4 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11c6ca486..a930b861f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ - ... +## 1.8.4 (2018-03-20) + +- Revert ignoring fatal errors on PHP 7+ (#571) +- Add PHP runtime information (#564) +- Cleanup the `site` value if it's empty (#555) +- Add `application/json` input handling (#546) + ## 1.8.3 (2018-02-07) - Serialize breadcrumbs to prevent issues with binary data (#538)