From 3804879f8718f5fcefac021e4494ee80421968e8 Mon Sep 17 00:00:00 2001 From: Artur Moczulski Date: Thu, 17 Jan 2019 19:54:27 +0000 Subject: [PATCH] Update dependencies to the latest versions --- vendor/composer/installed.json | 503 +++++++++--------- vendor/monolog/monolog/CHANGELOG.md | 28 + vendor/monolog/monolog/README.md | 1 - .../doc/02-handlers-formatters-processors.md | 1 + vendor/monolog/monolog/doc/03-utilities.md | 2 + .../monolog/src/Monolog/ErrorHandler.php | 13 +- .../Monolog/Formatter/FluentdFormatter.php | 1 + .../src/Monolog/Formatter/HtmlFormatter.php | 2 +- .../src/Monolog/Formatter/JsonFormatter.php | 18 +- .../src/Monolog/Formatter/LineFormatter.php | 8 +- .../Monolog/Formatter/MongoDBFormatter.php | 6 +- .../Monolog/Formatter/NormalizerFormatter.php | 31 +- .../Monolog/Formatter/WildfireFormatter.php | 4 +- .../src/Monolog/Handler/AbstractHandler.php | 26 +- .../Handler/AbstractProcessingHandler.php | 2 + .../Monolog/Handler/AbstractSyslogHandler.php | 6 +- .../Monolog/Handler/BrowserConsoleHandler.php | 56 +- .../src/Monolog/Handler/BufferHandler.php | 16 +- .../src/Monolog/Handler/ChromePHPHandler.php | 10 +- .../Monolog/Handler/DeduplicationHandler.php | 2 +- .../Monolog/Handler/ElasticSearchHandler.php | 8 +- .../src/Monolog/Handler/ErrorLogHandler.php | 8 +- .../src/Monolog/Handler/FilterHandler.php | 4 +- .../ActivationStrategyInterface.php | 2 +- .../Monolog/Handler/FingersCrossedHandler.php | 46 +- .../src/Monolog/Handler/FirePHPHandler.php | 2 +- .../src/Monolog/Handler/GelfHandler.php | 8 - .../src/Monolog/Handler/GroupHandler.php | 16 +- .../src/Monolog/Handler/HandlerInterface.php | 4 +- .../src/Monolog/Handler/HandlerWrapper.php | 10 +- .../src/Monolog/Handler/HipChatHandler.php | 15 + .../src/Monolog/Handler/IFTTTHandler.php | 8 +- .../src/Monolog/Handler/InsightOpsHandler.php | 62 +++ .../src/Monolog/Handler/LogEntriesHandler.php | 4 +- .../src/Monolog/Handler/MandrillHandler.php | 2 +- .../src/Monolog/Handler/NewRelicHandler.php | 4 +- .../src/Monolog/Handler/PsrHandler.php | 2 +- .../src/Monolog/Handler/PushoverHandler.php | 6 +- .../src/Monolog/Handler/RavenHandler.php | 12 +- .../src/Monolog/Handler/RollbarHandler.php | 12 + .../Monolog/Handler/RotatingFileHandler.php | 18 +- .../src/Monolog/Handler/Slack/SlackRecord.php | 10 +- .../src/Monolog/Handler/SlackHandler.php | 5 + .../Monolog/Handler/SlackWebhookHandler.php | 5 + .../src/Monolog/Handler/SocketHandler.php | 47 +- .../src/Monolog/Handler/StreamHandler.php | 6 +- .../Monolog/Handler/SwiftMailerHandler.php | 16 +- .../src/Monolog/Handler/SyslogHandler.php | 10 +- .../src/Monolog/Handler/SyslogUdpHandler.php | 12 +- .../src/Monolog/Handler/TestHandler.php | 16 +- .../Handler/WhatFailureGroupHandler.php | 10 + vendor/monolog/monolog/src/Monolog/Logger.php | 239 ++++++--- .../src/Monolog/Processor/GitProcessor.php | 2 +- .../Processor/IntrospectionProcessor.php | 2 +- .../src/Monolog/Processor/MemoryProcessor.php | 6 +- .../Monolog/Processor/MercurialProcessor.php | 2 +- .../Monolog/Processor/ProcessIdProcessor.php | 2 +- .../Monolog/Processor/ProcessorInterface.php | 25 + .../Processor/PsrLogMessageProcessor.php | 6 +- .../src/Monolog/Processor/TagProcessor.php | 2 +- .../src/Monolog/Processor/UidProcessor.php | 17 +- .../src/Monolog/Processor/WebProcessor.php | 2 +- .../src/Monolog/ResettableInterface.php | 31 ++ .../monolog/src/Monolog/SignalHandler.php | 115 ++++ vendor/monolog/monolog/src/Monolog/Utils.php | 25 + .../Formatter/FluentdFormatterTest.php | 4 +- .../Monolog/Formatter/JsonFormatterTest.php | 36 ++ .../Formatter/NormalizerFormatterTest.php | 60 ++- .../Handler/BrowserConsoleHandlerTest.php | 2 +- .../Monolog/Handler/ChromePHPHandlerTest.php | 4 +- .../Handler/FingersCrossedHandlerTest.php | 4 +- .../Monolog/Handler/FirePHPHandlerTest.php | 4 +- .../Monolog/Handler/InsightOpsHandlerTest.php | 80 +++ .../Handler/RotatingFileHandlerTest.php | 34 ++ .../Monolog/Handler/Slack/SlackRecordTest.php | 16 +- .../Monolog/Handler/SocketHandlerTest.php | 26 + .../tests/Monolog/Handler/TestHandlerTest.php | 46 ++ .../Handler/WhatFailureGroupHandlerTest.php | 23 + .../monolog/tests/Monolog/LoggerTest.php | 142 +++++ .../tests/Monolog/SignalHandlerTest.php | 287 ++++++++++ .../log/Psr/Log/Test/LoggerInterfaceTest.php | 4 + vendor/psr/log/Psr/Log/Test/TestLogger.php | 146 +++++ vendor/psr/log/README.md | 7 + vendor/rollbar/rollbar/.travis.yml | 4 +- vendor/rollbar/rollbar/README.md | 5 +- vendor/rollbar/rollbar/src/Config.php | 78 +-- vendor/rollbar/rollbar/src/DataBuilder.php | 58 +- vendor/rollbar/rollbar/src/Defaults.php | 368 ++++++++++--- vendor/rollbar/rollbar/src/ErrorWrapper.php | 2 +- vendor/rollbar/rollbar/src/Payload/Body.php | 28 +- .../rollbar/rollbar/src/Payload/Context.php | 5 +- vendor/rollbar/rollbar/src/Payload/Data.php | 5 +- .../rollbar/src/Payload/EncodedPayload.php | 2 +- .../rollbar/src/Payload/ExceptionInfo.php | 5 +- vendor/rollbar/rollbar/src/Payload/Frame.php | 5 +- .../rollbar/rollbar/src/Payload/Message.php | 18 +- .../rollbar/rollbar/src/Payload/Notifier.php | 7 +- .../rollbar/rollbar/src/Payload/Payload.php | 6 +- vendor/rollbar/rollbar/src/Payload/Person.php | 5 +- .../rollbar/rollbar/src/Payload/Request.php | 5 +- vendor/rollbar/rollbar/src/Payload/Server.php | 5 +- vendor/rollbar/rollbar/src/RollbarLogger.php | 38 +- .../src/Truncation/StringsStrategy.php | 9 +- .../rollbar/src/Truncation/Truncation.php | 2 +- vendor/rollbar/rollbar/src/Utilities.php | 105 +++- vendor/rollbar/rollbar/tests/BodyTest.php | 22 +- vendor/rollbar/rollbar/tests/ConfigTest.php | 30 +- .../rollbar/rollbar/tests/CurlSenderTest.php | 3 +- .../rollbar/rollbar/tests/DataBuilderTest.php | 25 + vendor/rollbar/rollbar/tests/DefaultsTest.php | 22 +- .../rollbar/tests/ErrorWrapperTest.php | 4 +- vendor/rollbar/rollbar/tests/MessageTest.php | 27 +- vendor/rollbar/rollbar/tests/NotifierTest.php | 2 +- .../rollbar/tests/RollbarLoggerTest.php | 145 ++--- vendor/rollbar/rollbar/tests/RollbarTest.php | 8 +- .../CycleCheck/ChildCycleCheck.php | 11 + .../ChildCycleCheckSerializable.php | 27 + .../CycleCheck/ParentCycleCheck.php | 11 + .../ParentCycleCheckSerializable.php | 27 + .../tests/Truncation/StringsStrategyTest.php | 59 +- .../tests/Truncation/TruncationTest.php | 3 +- .../rollbar/rollbar/tests/UtilitiesTest.php | 68 +++ vendor/symfony/yaml/Inline.php | 56 +- vendor/symfony/yaml/LICENSE | 2 +- vendor/symfony/yaml/Parser.php | 50 +- vendor/symfony/yaml/Tests/ParserTest.php | 46 ++ vendor/symfony/yaml/Yaml.php | 9 +- vendor/symfony/yaml/phpunit.xml.dist | 2 +- vendor/webmozart/assert/.composer-auth.json | 7 - vendor/webmozart/assert/.styleci.yml | 11 - vendor/webmozart/assert/CHANGELOG.md | 23 + vendor/webmozart/assert/README.md | 8 +- vendor/webmozart/assert/composer.json | 19 +- vendor/webmozart/assert/src/Assert.php | 106 +++- 134 files changed, 3140 insertions(+), 985 deletions(-) create mode 100644 vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php mode change 100644 => 100755 vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php create mode 100644 vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php create mode 100644 vendor/monolog/monolog/src/Monolog/ResettableInterface.php create mode 100644 vendor/monolog/monolog/src/Monolog/SignalHandler.php create mode 100644 vendor/monolog/monolog/src/Monolog/Utils.php create mode 100644 vendor/monolog/monolog/tests/Monolog/Handler/InsightOpsHandlerTest.php create mode 100644 vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php create mode 100644 vendor/psr/log/Psr/Log/Test/TestLogger.php create mode 100644 vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheck.php create mode 100644 vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheckSerializable.php create mode 100644 vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheck.php create mode 100644 vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheckSerializable.php delete mode 100644 vendor/webmozart/assert/.composer-auth.json delete mode 100644 vendor/webmozart/assert/.styleci.yml diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 3f2988c6..763552a1 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,133 +1,4 @@ [ - { - "name": "psr/log", - "version": "1.0.2", - "version_normalized": "1.0.2.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2016-10-10T12:19:37+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ] - }, - { - "name": "monolog/monolog", - "version": "1.23.0", - "version_normalized": "1.23.0.0", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4", - "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/log": "~1.0" - }, - "provide": { - "psr/log-implementation": "1.0.0" - }, - "require-dev": { - "aws/aws-sdk-php": "^2.4.9 || ^3.0", - "doctrine/couchdb": "~1.0@dev", - "graylog2/gelf-php": "~1.0", - "jakub-onderka/php-parallel-lint": "0.9", - "php-amqplib/php-amqplib": "~2.4", - "php-console/php-console": "^3.1.3", - "phpunit/phpunit": "~4.5", - "phpunit/phpunit-mock-objects": "2.3.0", - "ruflin/elastica": ">=0.90 <3.0", - "sentry/sentry": "^0.13", - "swiftmailer/swiftmailer": "^5.3|^6.0" - }, - "suggest": { - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-mongo": "Allow sending log messages to a MongoDB server", - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", - "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "php-console/php-console": "Allow sending log messages to Google Chrome", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server", - "sentry/sentry": "Allow sending log messages to a Sentry server" - }, - "time": "2017-06-19T01:22:40+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Monolog\\": "src/Monolog" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "homepage": "http://github.com/Seldaek/monolog", - "keywords": [ - "log", - "logging", - "psr-3" - ] - }, { "name": "sebastian/version", "version": "1.0.6", @@ -830,58 +701,6 @@ "xunit" ] }, - { - "name": "webmozart/assert", - "version": "1.3.0", - "version_normalized": "1.3.0.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" - }, - "time": "2018-01-29T19:49:41+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ] - }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -1060,68 +879,6 @@ "markdown" ] }, - { - "name": "rollbar/rollbar", - "version": "v1.6.1", - "version_normalized": "1.6.1.0", - "source": { - "type": "git", - "url": "https://github.com/rollbar/rollbar-php.git", - "reference": "df343b8f3eab7e34b9fd40cec4eb97e11c98e445" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rollbar/rollbar-php/zipball/df343b8f3eab7e34b9fd40cec4eb97e11c98e445", - "reference": "df343b8f3eab7e34b9fd40cec4eb97e11c98e445", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "monolog/monolog": "^1.23", - "psr/log": "^1.0.1" - }, - "require-dev": { - "codeclimate/php-test-reporter": "dev-master", - "mockery/mockery": "0.9.*", - "monolog/monolog": "^1.23", - "packfire/php5.3-compat": "*", - "phpmd/phpmd": "@stable", - "phpunit/phpunit": "4.8.*", - "squizlabs/php_codesniffer": "2.*" - }, - "suggest": { - "fluent/logger": "Needed to use the 'fluent' handler for fluentd support", - "packfire/php5.3-compat": "for backward compatibility with PHP 5.3" - }, - "time": "2018-08-06T22:14:19+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Rollbar\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Rollbar, Inc.", - "email": "support@rollbar.com", - "role": "Developer" - } - ], - "description": "Monitors errors and exceptions and reports them to Rollbar", - "homepage": "http://github.com/rollbar/rollbar-php", - "keywords": [ - "debugging", - "errors", - "exceptions", - "logging", - "monitoring" - ] - }, { "name": "doctrine/instantiator", "version": "1.0.5", @@ -1339,10 +1096,201 @@ "stub" ] }, + { + "name": "psr/log", + "version": "1.1.0", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2018-11-20T15:27:04+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ] + }, + { + "name": "monolog/monolog", + "version": "1.24.0", + "version_normalized": "1.24.0.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", + "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "jakub-onderka/php-parallel-lint": "0.9", + "php-amqplib/php-amqplib": "~2.4", + "php-console/php-console": "^3.1.3", + "phpunit/phpunit": "~4.5", + "phpunit/phpunit-mock-objects": "2.3.0", + "ruflin/elastica": ">=0.90 <3.0", + "sentry/sentry": "^0.13", + "swiftmailer/swiftmailer": "^5.3|^6.0" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "php-console/php-console": "Allow sending log messages to Google Chrome", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server", + "sentry/sentry": "Allow sending log messages to a Sentry server" + }, + "time": "2018-11-05T09:00:11+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ] + }, + { + "name": "rollbar/rollbar", + "version": "v1.7.4", + "version_normalized": "1.7.4.0", + "source": { + "type": "git", + "url": "https://github.com/rollbar/rollbar-php.git", + "reference": "c20bc20b91222f367ce18b3e0bf30863c1c9de57" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rollbar/rollbar-php/zipball/c20bc20b91222f367ce18b3e0bf30863c1c9de57", + "reference": "c20bc20b91222f367ce18b3e0bf30863c1c9de57", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "monolog/monolog": "^1.23", + "psr/log": "^1.0.1" + }, + "require-dev": { + "codeclimate/php-test-reporter": "dev-master", + "mockery/mockery": "0.9.*", + "monolog/monolog": "^1.23", + "packfire/php5.3-compat": "*", + "phpmd/phpmd": "@stable", + "phpunit/phpunit": "4.8.*", + "squizlabs/php_codesniffer": "2.*" + }, + "suggest": { + "fluent/logger": "Needed to use the 'fluent' handler for fluentd support", + "packfire/php5.3-compat": "for backward compatibility with PHP 5.3" + }, + "time": "2019-01-02T16:24:41+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Rollbar\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Rollbar, Inc.", + "email": "support@rollbar.com", + "role": "Developer" + } + ], + "description": "Monitors errors and exceptions and reports them to Rollbar", + "homepage": "http://github.com/rollbar/rollbar-php", + "keywords": [ + "debugging", + "errors", + "exceptions", + "logging", + "monitoring" + ] + }, { "name": "symfony/polyfill-ctype", - "version": "v1.9.0", - "version_normalized": "1.9.0.0", + "version": "v1.10.0", + "version_normalized": "1.10.0.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -1401,17 +1349,17 @@ }, { "name": "symfony/yaml", - "version": "v3.4.14", - "version_normalized": "3.4.14.0", + "version": "v3.4.21", + "version_normalized": "3.4.21.0", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "810af2d35fc72b6cf5c01116806d2b65ccaaf2e2" + "reference": "554a59a1ccbaac238a89b19c8e551a556fd0e2ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/810af2d35fc72b6cf5c01116806d2b65ccaaf2e2", - "reference": "810af2d35fc72b6cf5c01116806d2b65ccaaf2e2", + "url": "https://api.github.com/repos/symfony/yaml/zipball/554a59a1ccbaac238a89b19c8e551a556fd0e2ea", + "reference": "554a59a1ccbaac238a89b19c8e551a556fd0e2ea", "shasum": "" }, "require": { @@ -1427,7 +1375,7 @@ "suggest": { "symfony/console": "For validating YAML files using the lint command" }, - "time": "2018-07-26T11:19:56+00:00", + "time": "2019-01-01T13:45:19+00:00", "type": "library", "extra": { "branch-alias": { @@ -1459,5 +1407,58 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com" + }, + { + "name": "webmozart/assert", + "version": "1.4.0", + "version_normalized": "1.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "time": "2018-12-25T11:19:39+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ] } ] diff --git a/vendor/monolog/monolog/CHANGELOG.md b/vendor/monolog/monolog/CHANGELOG.md index cd1142d1..bcf679c4 100644 --- a/vendor/monolog/monolog/CHANGELOG.md +++ b/vendor/monolog/monolog/CHANGELOG.md @@ -1,3 +1,31 @@ +### 1.24.0 (2018-11-05) + + * Added a `ResettableInterface` in order to reset/reset/clear/flush handlers and processors + * Added a `ProcessorInterface` as an optional way to label a class as being a processor (mostly useful for autowiring dependency containers) + * Added a way to log signals being received using Monolog\SignalHandler + * Added ability to customize error handling at the Logger level using Logger::setExceptionHandler + * Added InsightOpsHandler to migrate users of the LogEntriesHandler + * Added protection to NormalizerHandler against circular and very deep structures, it now stops normalizing at a depth of 9 + * Added capture of stack traces to ErrorHandler when logging PHP errors + * Added RavenHandler support for a `contexts` context or extra key to forward that to Sentry's contexts + * Added forwarding of context info to FluentdFormatter + * Added SocketHandler::setChunkSize to override the default chunk size in case you must send large log lines to rsyslog for example + * Added ability to extend/override BrowserConsoleHandler + * Added SlackWebhookHandler::getWebhookUrl and SlackHandler::getToken to enable class extensibility + * Added SwiftMailerHandler::getSubjectFormatter to enable class extensibility + * Dropped official support for HHVM in test builds + * Fixed normalization of exception traces when call_user_func is used to avoid serializing objects and the data they contain + * Fixed naming of fields in Slack handler, all field names are now capitalized in all cases + * Fixed HipChatHandler bug where slack dropped messages randomly + * Fixed normalization of objects in Slack handlers + * Fixed support for PHP7's Throwable in NewRelicHandler + * Fixed race bug when StreamHandler sometimes incorrectly reported it failed to create a directory + * Fixed table row styling issues in HtmlFormatter + * Fixed RavenHandler dropping the message when logging exception + * Fixed WhatFailureGroupHandler skipping processors when using handleBatch + and implement it where possible + * Fixed display of anonymous class names + ### 1.23.0 (2017-06-19) * Improved SyslogUdpHandler's support for RFC5424 and added optional `$ident` argument diff --git a/vendor/monolog/monolog/README.md b/vendor/monolog/monolog/README.md index 7d8ade52..d7569446 100644 --- a/vendor/monolog/monolog/README.md +++ b/vendor/monolog/monolog/README.md @@ -2,7 +2,6 @@ [![Total Downloads](https://img.shields.io/packagist/dt/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog) [![Latest Stable Version](https://img.shields.io/packagist/v/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog) -[![Reference Status](https://www.versioneye.com/php/monolog:monolog/reference_badge.svg)](https://www.versioneye.com/php/monolog:monolog/references) Monolog sends your logs to files, sockets, inboxes, databases and various diff --git a/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md b/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md index bea968ac..af45913a 100644 --- a/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md +++ b/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md @@ -55,6 +55,7 @@ - _RollbarHandler_: Logs records to a [Rollbar](https://rollbar.com/) account. - _SyslogUdpHandler_: Logs records to a remote [Syslogd](http://www.rsyslog.com/) server. - _LogEntriesHandler_: Logs records to a [LogEntries](http://logentries.com/) account. +- _InsightOpsHandler_: Logs records to a [InsightOps](https://www.rapid7.com/products/insightops/) account. ### Logging in development diff --git a/vendor/monolog/monolog/doc/03-utilities.md b/vendor/monolog/monolog/doc/03-utilities.md index c62aa416..fd3fd0e7 100644 --- a/vendor/monolog/monolog/doc/03-utilities.md +++ b/vendor/monolog/monolog/doc/03-utilities.md @@ -5,6 +5,8 @@ help in some older codebases or for ease of use. - _ErrorHandler_: The `Monolog\ErrorHandler` class allows you to easily register a Logger instance as an exception handler, error handler or fatal error handler. +- _SignalHandler_: The `Monolog\SignalHandler` class allows you to easily register + a Logger instance as a POSIX signal handler. - _ErrorLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain log level is reached. - _ChannelLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain diff --git a/vendor/monolog/monolog/src/Monolog/ErrorHandler.php b/vendor/monolog/monolog/src/Monolog/ErrorHandler.php index 7bfcd833..adc55bdf 100644 --- a/vendor/monolog/monolog/src/Monolog/ErrorHandler.php +++ b/vendor/monolog/monolog/src/Monolog/ErrorHandler.php @@ -14,6 +14,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; use Monolog\Handler\AbstractHandler; +use Monolog\Registry; /** * Monolog error handler @@ -38,6 +39,7 @@ class ErrorHandler private $hasFatalErrorHandler; private $fatalLevel; private $reservedMemory; + private $lastFatalTrace; private static $fatalErrors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR); public function __construct(LoggerInterface $logger) @@ -132,7 +134,7 @@ public function handleException($e) { $this->logger->log( $this->uncaughtExceptionLevel === null ? LogLevel::ERROR : $this->uncaughtExceptionLevel, - sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), + sprintf('Uncaught Exception %s: "%s" at %s line %s', Utils::getClass($e), $e->getMessage(), $e->getFile(), $e->getLine()), array('exception' => $e) ); @@ -156,6 +158,13 @@ public function handleError($code, $message, $file = '', $line = 0, $context = a if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) { $level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL; $this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line)); + } else { + // http://php.net/manual/en/function.debug-backtrace.php + // As of 5.3.6, DEBUG_BACKTRACE_IGNORE_ARGS option was added. + // Any version less than 5.3.6 must use the DEBUG_BACKTRACE_IGNORE_ARGS constant value '2'. + $trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS); + array_shift($trace); // Exclude handleError from trace + $this->lastFatalTrace = $trace; } if ($this->previousErrorHandler === true) { @@ -177,7 +186,7 @@ public function handleFatalError() $this->logger->log( $this->fatalLevel === null ? LogLevel::ALERT : $this->fatalLevel, 'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'], - array('code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line']) + array('code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line'], 'trace' => $this->lastFatalTrace) ); if ($this->logger instanceof Logger) { diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php index 02632bb5..46a91ffe 100644 --- a/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php +++ b/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php @@ -62,6 +62,7 @@ public function format(array $record) $message = array( 'message' => $record['message'], + 'context' => $record['context'], 'extra' => $record['extra'], ); diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php index 3eec95f6..dfc0b4a3 100644 --- a/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php +++ b/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php @@ -58,7 +58,7 @@ protected function addRow($th, $td = ' ', $escapeTd = true) $td = '
'.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'
'; } - return "\n$th:\n".$td."\n"; + return "\n$th:\n".$td."\n"; } /** diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php index 0782f149..9bd305f2 100644 --- a/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php +++ b/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php @@ -12,6 +12,7 @@ namespace Monolog\Formatter; use Exception; +use Monolog\Utils; use Throwable; /** @@ -138,18 +139,23 @@ protected function formatBatchNewlines(array $records) * * @return mixed */ - protected function normalize($data) + protected function normalize($data, $depth = 0) { + if ($depth > 9) { + return 'Over 9 levels deep, aborting normalization'; + } + if (is_array($data) || $data instanceof \Traversable) { $normalized = array(); $count = 1; foreach ($data as $key => $value) { - if ($count++ >= 1000) { - $normalized['...'] = 'Over 1000 items, aborting normalization'; + if ($count++ > 1000) { + $normalized['...'] = 'Over 1000 items ('.count($data).' total), aborting normalization'; break; } - $normalized[$key] = $this->normalize($value); + + $normalized[$key] = $this->normalize($value, $depth+1); } return $normalized; @@ -174,11 +180,11 @@ protected function normalizeException($e) { // TODO 2.0 only check for Throwable if (!$e instanceof Exception && !$e instanceof Throwable) { - throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e)); + throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e)); } $data = array( - 'class' => get_class($e), + 'class' => Utils::getClass($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile().':'.$e->getLine(), diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php index d3e209e6..f98e1a6f 100644 --- a/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php +++ b/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php @@ -11,6 +11,8 @@ namespace Monolog\Formatter; +use Monolog\Utils; + /** * Formats incoming records into a one-line string * @@ -129,17 +131,17 @@ protected function normalizeException($e) { // TODO 2.0 only check for Throwable if (!$e instanceof \Exception && !$e instanceof \Throwable) { - throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e)); + throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e)); } $previousText = ''; if ($previous = $e->getPrevious()) { do { - $previousText .= ', '.get_class($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine(); + $previousText .= ', '.Utils::getClass($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine(); } while ($previous = $previous->getPrevious()); } - $str = '[object] ('.get_class($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')'; + $str = '[object] ('.Utils::getClass($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')'; if ($this->includeStacktraces) { $str .= "\n[stacktrace]\n".$e->getTraceAsString()."\n"; } diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php index eb067bb7..eb7be849 100644 --- a/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php +++ b/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php @@ -11,6 +11,8 @@ namespace Monolog\Formatter; +use Monolog\Utils; + /** * Formats a record for use with the MongoDBHandler. * @@ -75,7 +77,7 @@ protected function formatArray(array $record, $nestingLevel = 0) protected function formatObject($value, $nestingLevel) { $objectVars = get_object_vars($value); - $objectVars['class'] = get_class($value); + $objectVars['class'] = Utils::getClass($value); return $this->formatArray($objectVars, $nestingLevel); } @@ -83,7 +85,7 @@ protected function formatObject($value, $nestingLevel) protected function formatException(\Exception $exception, $nestingLevel) { $formattedException = array( - 'class' => get_class($exception), + 'class' => Utils::getClass($exception), 'message' => $exception->getMessage(), 'code' => $exception->getCode(), 'file' => $exception->getFile() . ':' . $exception->getLine(), diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php index d4414882..66866578 100644 --- a/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php +++ b/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php @@ -12,6 +12,7 @@ namespace Monolog\Formatter; use Exception; +use Monolog\Utils; /** * Normalizes incoming records to remove objects/resources so it's easier to dump to various targets @@ -55,8 +56,12 @@ public function formatBatch(array $records) return $records; } - protected function normalize($data) + protected function normalize($data, $depth = 0) { + if ($depth > 9) { + return 'Over 9 levels deep, aborting normalization'; + } + if (null === $data || is_scalar($data)) { if (is_float($data)) { if (is_infinite($data)) { @@ -75,11 +80,12 @@ protected function normalize($data) $count = 1; foreach ($data as $key => $value) { - if ($count++ >= 1000) { + if ($count++ > 1000) { $normalized['...'] = 'Over 1000 items ('.count($data).' total), aborting normalization'; break; } - $normalized[$key] = $this->normalize($value); + + $normalized[$key] = $this->normalize($value, $depth+1); } return $normalized; @@ -103,7 +109,7 @@ protected function normalize($data) $value = $this->toJson($data, true); } - return sprintf("[object] (%s: %s)", get_class($data), $value); + return sprintf("[object] (%s: %s)", Utils::getClass($data), $value); } if (is_resource($data)) { @@ -117,11 +123,11 @@ protected function normalizeException($e) { // TODO 2.0 only check for Throwable if (!$e instanceof Exception && !$e instanceof \Throwable) { - throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e)); + throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e)); } $data = array( - 'class' => get_class($e), + 'class' => Utils::getClass($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile().':'.$e->getLine(), @@ -146,9 +152,20 @@ protected function normalizeException($e) if (isset($frame['file'])) { $data['trace'][] = $frame['file'].':'.$frame['line']; } elseif (isset($frame['function']) && $frame['function'] === '{closure}') { - // We should again normalize the frames, because it might contain invalid items + // Simplify closures handling $data['trace'][] = $frame['function']; } else { + if (isset($frame['args'])) { + // Make sure that objects present as arguments are not serialized nicely but rather only + // as a class name to avoid any unexpected leak of sensitive information + $frame['args'] = array_map(function ($arg) { + if (is_object($arg) && !($arg instanceof \DateTime || $arg instanceof \DateTimeInterface)) { + return sprintf("[object] (%s)", Utils::getClass($arg)); + } + + return $arg; + }, $frame['args']); + } // We should again normalize the frames, because it might contain invalid items $data['trace'][] = $this->toJson($this->normalize($frame), true); } diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php index 654710a8..65dba99c 100644 --- a/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php +++ b/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php @@ -102,12 +102,12 @@ public function formatBatch(array $records) throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter'); } - protected function normalize($data) + protected function normalize($data, $depth = 0) { if (is_object($data) && !$data instanceof \DateTime) { return $data; } - return parent::normalize($data); + return parent::normalize($data, $depth); } } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php index 758a425c..92b9d458 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php @@ -11,16 +11,17 @@ namespace Monolog\Handler; -use Monolog\Logger; use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; +use Monolog\Logger; +use Monolog\ResettableInterface; /** * Base Handler class providing the Handler structure * * @author Jordi Boggiano */ -abstract class AbstractHandler implements HandlerInterface +abstract class AbstractHandler implements HandlerInterface, ResettableInterface { protected $level = Logger::DEBUG; protected $bubble = true; @@ -32,8 +33,8 @@ abstract class AbstractHandler implements HandlerInterface protected $processors = array(); /** - * @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 + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($level = Logger::DEBUG, $bubble = true) { @@ -141,8 +142,8 @@ public function getLevel() /** * Sets the bubbling behavior. * - * @param Boolean $bubble true means that this handler allows bubbling. - * false means that bubbling is not permitted. + * @param bool $bubble true means that this handler allows bubbling. + * false means that bubbling is not permitted. * @return self */ public function setBubble($bubble) @@ -155,8 +156,8 @@ public function setBubble($bubble) /** * Gets the bubbling behavior. * - * @return Boolean true means that this handler allows bubbling. - * false means that bubbling is not permitted. + * @return bool true means that this handler allows bubbling. + * false means that bubbling is not permitted. */ public function getBubble() { @@ -174,6 +175,15 @@ public function __destruct() } } + public function reset() + { + foreach ($this->processors as $processor) { + if ($processor instanceof ResettableInterface) { + $processor->reset(); + } + } + } + /** * Gets the default formatter. * diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php index 6f18f72e..e1e89530 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php @@ -11,6 +11,8 @@ namespace Monolog\Handler; +use Monolog\ResettableInterface; + /** * Base Handler class providing the Handler structure * diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php index e2b2832d..8c76aca0 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php @@ -53,9 +53,9 @@ abstract class AbstractSyslogHandler extends AbstractProcessingHandler ); /** - * @param mixed $facility - * @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 + * @param mixed $facility + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php index b3a21bd4..23cf23ba 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php @@ -43,11 +43,11 @@ protected function getDefaultFormatter() protected function write(array $record) { // Accumulate records - self::$records[] = $record; + static::$records[] = $record; // Register shutdown handler if not already done - if (!self::$initialized) { - self::$initialized = true; + if (!static::$initialized) { + static::$initialized = true; $this->registerShutdownFunction(); } } @@ -58,27 +58,37 @@ protected function write(array $record) */ public static function send() { - $format = self::getResponseFormat(); + $format = static::getResponseFormat(); if ($format === 'unknown') { return; } - if (count(self::$records)) { + if (count(static::$records)) { if ($format === 'html') { - self::writeOutput(''); + static::writeOutput(''); } elseif ($format === 'js') { - self::writeOutput(self::generateScript()); + static::writeOutput(static::generateScript()); } - self::reset(); + static::resetStatic(); } } + public function close() + { + self::resetStatic(); + } + + public function reset() + { + self::resetStatic(); + } + /** * Forget all logged records */ - public static function reset() + public static function resetStatic() { - self::$records = array(); + static::$records = array(); } /** @@ -133,18 +143,18 @@ protected static function getResponseFormat() private static function generateScript() { $script = array(); - foreach (self::$records as $record) { - $context = self::dump('Context', $record['context']); - $extra = self::dump('Extra', $record['extra']); + foreach (static::$records as $record) { + $context = static::dump('Context', $record['context']); + $extra = static::dump('Extra', $record['extra']); if (empty($context) && empty($extra)) { - $script[] = self::call_array('log', self::handleStyles($record['formatted'])); + $script[] = static::call_array('log', static::handleStyles($record['formatted'])); } else { $script = array_merge($script, - array(self::call_array('groupCollapsed', self::handleStyles($record['formatted']))), + array(static::call_array('groupCollapsed', static::handleStyles($record['formatted']))), $context, $extra, - array(self::call('groupEnd')) + array(static::call('groupEnd')) ); } } @@ -154,19 +164,19 @@ private static function generateScript() private static function handleStyles($formatted) { - $args = array(self::quote('font-weight: normal')); + $args = array(static::quote('font-weight: normal')); $format = '%c' . $formatted; preg_match_all('/\[\[(.*?)\]\]\{([^}]*)\}/s', $format, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); foreach (array_reverse($matches) as $match) { - $args[] = self::quote(self::handleCustomStyles($match[2][0], $match[1][0])); + $args[] = static::quote(static::handleCustomStyles($match[2][0], $match[1][0])); $args[] = '"font-weight: normal"'; $pos = $match[0][1]; $format = substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . substr($format, $pos + strlen($match[0][0])); } - array_unshift($args, self::quote($format)); + array_unshift($args, static::quote($format)); return $args; } @@ -198,13 +208,13 @@ private static function dump($title, array $dict) if (empty($dict)) { return $script; } - $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title)); + $script[] = static::call('log', static::quote('%c%s'), static::quote('font-weight: bold'), static::quote($title)); foreach ($dict as $key => $value) { $value = json_encode($value); if (empty($value)) { - $value = self::quote(''); + $value = static::quote(''); } - $script[] = self::call('log', self::quote('%s: %o'), self::quote($key), $value); + $script[] = static::call('log', static::quote('%s: %o'), static::quote($key), $value); } return $script; @@ -220,7 +230,7 @@ private static function call() $args = func_get_args(); $method = array_shift($args); - return self::call_array($method, $args); + return static::call_array($method, $args); } private static function call_array($method, array $args) diff --git a/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php index 72f89535..61d1b50c 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Logger; +use Monolog\ResettableInterface; /** * Buffers all records until closing the handler and then pass them as batch. @@ -34,8 +35,8 @@ class BufferHandler extends AbstractHandler * @param HandlerInterface $handler Handler. * @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. * @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 - * @param Boolean $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param bool $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded */ public function __construct(HandlerInterface $handler, $bufferLimit = 0, $level = Logger::DEBUG, $bubble = true, $flushOnOverflow = false) { @@ -114,4 +115,15 @@ public function clear() $this->bufferSize = 0; $this->buffer = array(); } + + public function reset() + { + $this->flush(); + + parent::reset(); + + if ($this->handler instanceof ResettableInterface) { + $this->handler->reset(); + } + } } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php index 785cb0c9..37419a06 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php @@ -32,7 +32,7 @@ class ChromePHPHandler extends AbstractProcessingHandler * Header name */ const HEADER_NAME = 'X-ChromeLogger-Data'; - + /** * Regular expression to detect supported browsers (matches any Chrome, or Firefox 43+) */ @@ -45,7 +45,7 @@ class ChromePHPHandler extends AbstractProcessingHandler * * Chrome limits the headers to 256KB, so when we sent 240KB we stop sending * - * @var Boolean + * @var bool */ protected static $overflowed = false; @@ -58,8 +58,8 @@ class ChromePHPHandler extends AbstractProcessingHandler protected static $sendHeaders = true; /** - * @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 + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($level = Logger::DEBUG, $bubble = true) { @@ -174,7 +174,7 @@ protected function sendHeader($header, $content) /** * Verifies if the headers are accepted by the current user agent * - * @return Boolean + * @return bool */ protected function headersAccepted() { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php index 7778c22a..35b55cb4 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php @@ -60,7 +60,7 @@ class DeduplicationHandler extends BufferHandler * @param string $deduplicationStore The file/path where the deduplication log should be kept * @param int $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes * @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct(HandlerInterface $handler, $deduplicationStore = null, $deduplicationLevel = Logger::ERROR, $time = 60, $bubble = true) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php index 81967406..bb0f83eb 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php @@ -46,10 +46,10 @@ class ElasticSearchHandler extends AbstractProcessingHandler protected $options = array(); /** - * @param Client $client Elastica Client object - * @param array $options Handler configuration - * @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 + * @param Client $client Elastica Client object + * @param array $options Handler configuration + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php index 1447a584..b2986b0f 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php @@ -28,10 +28,10 @@ class ErrorLogHandler extends AbstractProcessingHandler protected $expandNewlines; /** - * @param int $messageType Says where the error should go. - * @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 - * @param Boolean $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries + * @param int $messageType Says where the error should go. + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param bool $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries */ public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, $bubble = true, $expandNewlines = false) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php index 2a0f7fd1..938c1a7e 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php @@ -40,7 +40,7 @@ class FilterHandler extends AbstractHandler /** * Whether the messages that are handled can bubble up the stack or not * - * @var Boolean + * @var bool */ protected $bubble; @@ -48,7 +48,7 @@ class FilterHandler extends AbstractHandler * @param callable|HandlerInterface $handler Handler or factory callable($record, $this). * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided * @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, $bubble = true) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php index c3e42efe..aaca12cc 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php @@ -22,7 +22,7 @@ interface ActivationStrategyInterface * Returns whether the given record activates the handler. * * @param array $record - * @return Boolean + * @return bool */ public function isHandlerActivated(array $record); } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php index d1dcaacf..275fd513 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php @@ -14,6 +14,7 @@ use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; use Monolog\Handler\FingersCrossed\ActivationStrategyInterface; use Monolog\Logger; +use Monolog\ResettableInterface; /** * Buffers all records until a certain level is reached @@ -41,8 +42,8 @@ class FingersCrossedHandler extends AbstractHandler * @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler). * @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true) + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param bool $stopBuffering Whether the handler should stop buffering after being triggered (default true) * @param int $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered */ public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true, $passthruLevel = null) @@ -130,24 +131,18 @@ public function handle(array $record) */ public function close() { - if (null !== $this->passthruLevel) { - $level = $this->passthruLevel; - $this->buffer = array_filter($this->buffer, function ($record) use ($level) { - return $record['level'] >= $level; - }); - if (count($this->buffer) > 0) { - $this->handler->handleBatch($this->buffer); - $this->buffer = array(); - } - } + $this->flushBuffer(); } - /** - * Resets the state of the handler. Stops forwarding records to the wrapped handler. - */ public function reset() { - $this->buffering = true; + $this->flushBuffer(); + + parent::reset(); + + if ($this->handler instanceof ResettableInterface) { + $this->handler->reset(); + } } /** @@ -160,4 +155,23 @@ public function clear() $this->buffer = array(); $this->reset(); } + + /** + * Resets the state of the handler. Stops forwarding records to the wrapped handler. + */ + private function flushBuffer() + { + if (null !== $this->passthruLevel) { + $level = $this->passthruLevel; + $this->buffer = array_filter($this->buffer, function ($record) use ($level) { + return $record['level'] >= $level; + }); + if (count($this->buffer) > 0) { + $this->handler->handleBatch($this->buffer); + } + } + + $this->buffer = array(); + $this->buffering = true; + } } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php index fee47950..c30b1843 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php @@ -158,7 +158,7 @@ protected function write(array $record) /** * Verifies if the headers are accepted by the current user agent * - * @return Boolean + * @return bool */ protected function headersAccepted() { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php index d3847d82..71e46693 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php @@ -47,14 +47,6 @@ public function __construct($publisher, $level = Logger::DEBUG, $bubble = true) $this->publisher = $publisher; } - /** - * {@inheritdoc} - */ - public function close() - { - $this->publisher = null; - } - /** * {@inheritdoc} */ diff --git a/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php index 663f5a92..28e5c564 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Formatter\FormatterInterface; +use Monolog\ResettableInterface; /** * Forwards records to multiple handlers @@ -23,8 +24,8 @@ class GroupHandler extends AbstractHandler protected $handlers; /** - * @param array $handlers Array of Handlers. - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param array $handlers Array of Handlers. + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct(array $handlers, $bubble = true) { @@ -90,6 +91,17 @@ public function handleBatch(array $records) } } + public function reset() + { + parent::reset(); + + foreach ($this->handlers as $handler) { + if ($handler instanceof ResettableInterface) { + $handler->reset(); + } + } + } + /** * {@inheritdoc} */ diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php b/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php index d920c4ba..8d5a4a09 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php @@ -31,7 +31,7 @@ interface HandlerInterface * * @param array $record Partial log record containing only a level key * - * @return Boolean + * @return bool */ public function isHandling(array $record); @@ -46,7 +46,7 @@ public function isHandling(array $record); * calling further handlers in the stack with a given log record. * * @param array $record The record to handle - * @return Boolean true means that this handler handled the record, and that bubbling is not permitted. + * @return bool true means that this handler handled the record, and that bubbling is not permitted. * false means the record was either not processed or that this handler allows bubbling. */ public function handle(array $record); diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php b/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php index e540d80f..55e64986 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php @@ -11,6 +11,7 @@ namespace Monolog\Handler; +use Monolog\ResettableInterface; use Monolog\Formatter\FormatterInterface; /** @@ -30,7 +31,7 @@ * * @author Alexey Karapetov */ -class HandlerWrapper implements HandlerInterface +class HandlerWrapper implements HandlerInterface, ResettableInterface { /** * @var HandlerInterface @@ -105,4 +106,11 @@ public function getFormatter() { return $this->handler->getFormatter(); } + + public function reset() + { + if ($this->handler instanceof ResettableInterface) { + return $this->handler->reset(); + } + } } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php index 73049f36..73233c95 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php @@ -219,6 +219,21 @@ protected function getAlertColor($level) protected function write(array $record) { parent::write($record); + $this->finalizeWrite(); + } + + /** + * Finalizes the request by reading some bytes and then closing the socket + * + * If we do not read some but close the socket too early, hipchat sometimes + * drops the request entirely. + */ + protected function finalizeWrite() + { + $res = $this->getResource(); + if (is_resource($res)) { + @fread($res, 2048); + } $this->closeSocket(); } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php index d60a3c82..7f226220 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php @@ -30,10 +30,10 @@ class IFTTTHandler extends AbstractProcessingHandler private $secretKey; /** - * @param string $eventName The name of the IFTTT Maker event that should be triggered - * @param string $secretKey A valid IFTTT secret key - * @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 + * @param string $eventName The name of the IFTTT Maker event that should be triggered + * @param string $secretKey A valid IFTTT secret key + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($eventName, $secretKey, $level = Logger::ERROR, $bubble = true) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php new file mode 100644 index 00000000..a12e3de5 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Monolog\Handler; + + use Monolog\Logger; + +/** + * Inspired on LogEntriesHandler. + * + * @author Robert Kaufmann III + * @author Gabriel Machado + */ +class InsightOpsHandler extends SocketHandler +{ + /** + * @var string + */ + protected $logToken; + + /** + * @param string $token Log token supplied by InsightOps + * @param string $region Region where InsightOps account is hosted. Could be 'us' or 'eu'. + * @param bool $useSSL Whether or not SSL encryption should be used + * @param int $level The minimum logging level to trigger this handler + * @param bool $bubble Whether or not messages that are handled should bubble up the stack. + * + * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing + */ + public function __construct($token, $region = 'us', $useSSL = true, $level = Logger::DEBUG, $bubble = true) + { + if ($useSSL && !extension_loaded('openssl')) { + throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler'); + } + + $endpoint = $useSSL + ? 'ssl://' . $region . '.data.logs.insight.rapid7.com:443' + : $region . '.data.logs.insight.rapid7.com:80'; + + parent::__construct($endpoint, $level, $bubble); + $this->logToken = $token; + } + + /** + * {@inheritdoc} + * + * @param array $record + * @return string + */ + protected function generateDataStream($record) + { + return $this->logToken . ' ' . $record['formatted']; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php index 494c605b..ea89fb3e 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php @@ -31,13 +31,13 @@ class LogEntriesHandler extends SocketHandler * * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing */ - public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true) + public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true, $host = 'data.logentries.com') { if ($useSSL && !extension_loaded('openssl')) { throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler'); } - $endpoint = $useSSL ? 'ssl://data.logentries.com:443' : 'data.logentries.com:80'; + $endpoint = $useSSL ? 'ssl://' . $host . ':443' : $host . ':80'; parent::__construct($endpoint, $level, $bubble); $this->logToken = $token; } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php index ab95924f..3f0956a9 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php @@ -27,7 +27,7 @@ class MandrillHandler extends MailHandler * @param string $apiKey A valid Mandrill API key * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced * @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 + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($apiKey, $message, $level = Logger::ERROR, $bubble = true) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php index 6718e9e0..f911997a 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php @@ -18,6 +18,8 @@ * Class to record a log on a NewRelic application. * Enabling New Relic High Security mode may prevent capture of useful information. * + * This handler requires a NormalizerFormatter to function and expects an array in $record['formatted'] + * * @see https://docs.newrelic.com/docs/agents/php-agent * @see https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security */ @@ -84,7 +86,7 @@ protected function write(array $record) unset($record['formatted']['context']['transaction_name']); } - if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { + if (isset($record['context']['exception']) && ($record['context']['exception'] instanceof \Exception || (PHP_VERSION_ID >= 70000 && $record['context']['exception'] instanceof \Throwable))) { newrelic_notice_error($record['message'], $record['context']['exception']); unset($record['formatted']['context']['exception']); } else { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php index 1ae85845..a99e6ab7 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php @@ -31,7 +31,7 @@ class PsrHandler extends AbstractHandler /** * @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied * @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 + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct(LoggerInterface $logger, $level = Logger::DEBUG, $bubble = true) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php index bba72005..f27bb3da 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php @@ -69,8 +69,8 @@ class PushoverHandler extends SocketHandler * @param string|array $users Pushover user id or array of ids the message will be sent to * @param string $title Title sent to the Pushover API * @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 - * @param Boolean $useSSL Whether to connect via SSL. Required when pushing messages to users that are not + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param bool $useSSL Whether to connect via SSL. Required when pushing messages to users that are not * the pushover.net app owner. OpenSSL is required for this option. * @param int $highPriorityLevel The minimum logging level at which this handler will start * sending "high priority" requests to the Pushover API @@ -180,6 +180,6 @@ public function setEmergencyLevel($value) */ public function useFormattedMessage($value) { - $this->useFormattedMessage = (boolean) $value; + $this->useFormattedMessage = (bool) $value; } } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php index 53a8b391..10d7f43b 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php @@ -18,7 +18,7 @@ /** * Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server - * using raven-php (https://github.com/getsentry/raven-php) + * using sentry-php (https://github.com/getsentry/sentry-php) * * @author Marc Abramowitz */ @@ -27,7 +27,7 @@ class RavenHandler extends AbstractProcessingHandler /** * Translates Monolog log levels to Raven log levels. */ - private $logLevels = array( + protected $logLevels = array( Logger::DEBUG => Raven_Client::DEBUG, Logger::INFO => Raven_Client::INFO, Logger::NOTICE => Raven_Client::INFO, @@ -42,7 +42,7 @@ class RavenHandler extends AbstractProcessingHandler * @var string should represent the current version of the calling * software. Can be any string (git commit, version number) */ - private $release; + protected $release; /** * @var Raven_Client the client object that sends the message to the server @@ -57,7 +57,7 @@ class RavenHandler extends AbstractProcessingHandler /** * @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 + * @param bool $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) { @@ -180,7 +180,7 @@ protected function write(array $record) } if (isset($record['context']['exception']) && ($record['context']['exception'] instanceof \Exception || (PHP_VERSION_ID >= 70000 && $record['context']['exception'] instanceof \Throwable))) { - $options['extra']['message'] = $record['formatted']; + $options['message'] = $record['formatted']; $this->ravenClient->captureException($record['context']['exception'], $options); } else { $this->ravenClient->captureMessage($record['formatted'], array(), $options); @@ -216,7 +216,7 @@ protected function getDefaultBatchFormatter() */ protected function getExtraParameters() { - return array('checksum', 'release', 'event_id'); + return array('contexts', 'checksum', 'release', 'event_id'); } /** diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php index 6c8a3e3e..65073ffe 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php @@ -129,4 +129,16 @@ public function close() { $this->flush(); } + + /** + * {@inheritdoc} + */ + public function reset() + { + $this->flush(); + + parent::reset(); + } + + } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php index 3b60b3d1..ae2309f8 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php @@ -39,9 +39,9 @@ class RotatingFileHandler extends StreamHandler * @param string $filename * @param int $maxFiles The maximal amount of files to keep (0 means unlimited) * @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 + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) - * @param Boolean $useLocking Try to lock log file before doing any writes + * @param bool $useLocking Try to lock log file before doing any writes */ public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false) { @@ -66,6 +66,18 @@ public function close() } } + /** + * {@inheritdoc} + */ + public function reset() + { + parent::reset(); + + if (true === $this->mustRotate) { + $this->rotate(); + } + } + public function setFilenameFormat($filenameFormat, $dateFormat) { if (!preg_match('{^Y(([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) { @@ -166,7 +178,7 @@ protected function getGlobPattern() $fileInfo = pathinfo($this->filename); $glob = str_replace( array('{filename}', '{date}'), - array($fileInfo['filename'], '*'), + array($fileInfo['filename'], '[0-9][0-9][0-9][0-9]*'), $fileInfo['dirname'] . '/' . $this->filenameFormat ); if (!empty($fileInfo['extension'])) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php b/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php old mode 100644 new mode 100755 index 38bc838a..e55e0e2e --- a/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php @@ -146,7 +146,7 @@ public function getSlackData(array $record) if ($this->useShortAttachment) { $attachment['fields'][] = $this->generateAttachmentField( - ucfirst($key), + $key, $record[$key] ); } else { @@ -229,8 +229,8 @@ public function setFormatter(FormatterInterface $formatter) /** * Generates attachment field * - * @param string $title - * @param string|array $value\ + * @param string $title + * @param string|array $value * * @return array */ @@ -241,7 +241,7 @@ private function generateAttachmentField($title, $value) : $value; return array( - 'title' => $title, + 'title' => ucfirst($title), 'value' => $value, 'short' => false ); @@ -257,7 +257,7 @@ private function generateAttachmentField($title, $value) private function generateAttachmentFields(array $data) { $fields = array(); - foreach ($data as $key => $value) { + foreach ($this->normalizerFormatter->format($data) as $key => $value) { $fields[] = $this->generateAttachmentField($key, $value); } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php index 3ac4d836..45d634f4 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php @@ -75,6 +75,11 @@ public function getSlackRecord() return $this->slackRecord; } + public function getToken() + { + return $this->token; + } + /** * {@inheritdoc} * diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php index 9a1bbb44..1ef85fae 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php @@ -70,6 +70,11 @@ public function getSlackRecord() return $this->slackRecord; } + public function getWebhookUrl() + { + return $this->webhookUrl; + } + /** * {@inheritdoc} * diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php index 7a61bf4e..db50d97f 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php @@ -27,15 +27,16 @@ class SocketHandler extends AbstractProcessingHandler private $timeout = 0; private $writingTimeout = 10; private $lastSentBytes = null; + private $chunkSize = null; private $persistent = false; private $errno; private $errstr; private $lastWritingAt; /** - * @param string $connectionString Socket connection string - * @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 + * @param string $connectionString Socket connection string + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true) { @@ -87,7 +88,7 @@ public function closeSocket() */ public function setPersistent($persistent) { - $this->persistent = (boolean) $persistent; + $this->persistent = (bool) $persistent; } /** @@ -127,6 +128,16 @@ public function setWritingTimeout($seconds) $this->writingTimeout = (float) $seconds; } + /** + * Set chunk size. Only has effect during connection in the writing cycle. + * + * @param float $bytes + */ + public function setChunkSize($bytes) + { + $this->chunkSize = $bytes; + } + /** * Get current connection string * @@ -177,6 +188,16 @@ public function getWritingTimeout() return $this->writingTimeout; } + /** + * Get current chunk size + * + * @return float + */ + public function getChunkSize() + { + return $this->chunkSize; + } + /** * Check to see if the socket is currently available. * @@ -219,6 +240,16 @@ protected function streamSetTimeout() return stream_set_timeout($this->resource, $seconds, $microseconds); } + /** + * Wrapper to allow mocking + * + * @see http://php.net/manual/en/function.stream-set-chunk-size.php + */ + protected function streamSetChunkSize() + { + return stream_set_chunk_size($this->resource, $this->chunkSize); + } + /** * Wrapper to allow mocking */ @@ -268,6 +299,7 @@ private function connect() { $this->createSocketResource(); $this->setSocketTimeout(); + $this->setStreamChunkSize(); } private function createSocketResource() @@ -290,6 +322,13 @@ private function setSocketTimeout() } } + private function setStreamChunkSize() + { + if ($this->chunkSize && !$this->streamSetChunkSize()) { + throw new \UnexpectedValueException("Failed setting chunk size with stream_set_chunk_size()"); + } + } + private function writeToSocket($data) { $length = strlen($data); diff --git a/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php index 09a15738..a35b7e4c 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php @@ -32,9 +32,9 @@ class StreamHandler extends AbstractProcessingHandler /** * @param resource|string $stream * @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 + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) - * @param Boolean $useLocking Try to lock log file before doing any writes + * @param bool $useLocking Try to lock log file before doing any writes * * @throws \Exception If a missing directory is not buildable * @throws \InvalidArgumentException If stream is not a resource or string @@ -167,7 +167,7 @@ private function createDir() set_error_handler(array($this, 'customErrorHandler')); $status = mkdir($dir, 0777, true); restore_error_handler(); - if (false === $status) { + if (false === $status && !is_dir($dir)) { throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and its not buildable: '.$this->errorMessage, $dir)); } } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php index 72f44a53..ac7b16ff 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php @@ -12,6 +12,7 @@ namespace Monolog\Handler; use Monolog\Logger; +use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LineFormatter; use Swift; @@ -29,7 +30,7 @@ class SwiftMailerHandler extends MailHandler * @param \Swift_Mailer $mailer The mailer to use * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced * @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 + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not */ public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true) { @@ -47,6 +48,17 @@ protected function send($content, array $records) $this->mailer->send($this->buildMessage($content, $records)); } + /** + * Gets the formatter for the Swift_Message subject. + * + * @param string $format The format of the subject + * @return FormatterInterface + */ + protected function getSubjectFormatter($format) + { + return new LineFormatter($format); + } + /** * Creates instance of Swift_Message to be sent * @@ -69,7 +81,7 @@ protected function buildMessage($content, array $records) } if ($records) { - $subjectFormatter = new LineFormatter($message->getSubject()); + $subjectFormatter = $this->getSubjectFormatter($message->getSubject()); $message->setSubject($subjectFormatter->format($this->getHighestRecord($records))); } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php index 376bc3b2..f770c802 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php @@ -32,11 +32,11 @@ class SyslogHandler extends AbstractSyslogHandler protected $logopts; /** - * @param string $ident - * @param mixed $facility - * @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 - * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID + * @param string $ident + * @param mixed $facility + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID */ public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $logopts = LOG_PID) { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php index 4718711b..e14b378c 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php @@ -25,12 +25,12 @@ class SyslogUdpHandler extends AbstractSyslogHandler protected $ident; /** - * @param string $host - * @param int $port - * @param mixed $facility - * @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 - * @param string $ident Program name or tag for each log message. + * @param string $host + * @param int $port + * @param mixed $facility + * @param int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * @param string $ident Program name or tag for each log message. */ public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $ident = 'php') { diff --git a/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php index e39cfc66..b6b1343b 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php @@ -84,14 +84,24 @@ public function hasRecords($level) return isset($this->recordsByLevel[$level]); } + /** + * @param string|array $record Either a message string or an array containing message and optionally context keys that will be checked against all records + * @param int $level Logger::LEVEL constant value + */ public function hasRecord($record, $level) { - if (is_array($record)) { - $record = $record['message']; + if (is_string($record)) { + $record = array('message' => $record); } return $this->hasRecordThatPasses(function ($rec) use ($record) { - return $rec['message'] === $record; + if ($rec['message'] !== $record['message']) { + return false; + } + if (isset($record['context']) && $rec['context'] !== $record['context']) { + return false; + } + return true; }, $level); } diff --git a/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php index 2732ba3d..6bc4671c 100644 --- a/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php +++ b/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php @@ -48,6 +48,16 @@ public function handle(array $record) */ public function handleBatch(array $records) { + if ($this->processors) { + $processed = array(); + foreach ($records as $record) { + foreach ($this->processors as $processor) { + $processed[] = call_user_func($processor, $record); + } + } + $records = $processed; + } + foreach ($this->handlers as $handler) { try { $handler->handleBatch($records); diff --git a/vendor/monolog/monolog/src/Monolog/Logger.php b/vendor/monolog/monolog/src/Monolog/Logger.php index 49d00af1..05dfc817 100644 --- a/vendor/monolog/monolog/src/Monolog/Logger.php +++ b/vendor/monolog/monolog/src/Monolog/Logger.php @@ -15,6 +15,7 @@ use Monolog\Handler\StreamHandler; use Psr\Log\LoggerInterface; use Psr\Log\InvalidArgumentException; +use Exception; /** * Monolog log channel @@ -24,7 +25,7 @@ * * @author Jordi Boggiano */ -class Logger implements LoggerInterface +class Logger implements LoggerInterface, ResettableInterface { /** * Detailed debug information @@ -133,6 +134,11 @@ class Logger implements LoggerInterface */ protected $microsecondTimestamps = true; + /** + * @var callable + */ + protected $exceptionHandler; + /** * @param string $name The logging channel * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. @@ -141,7 +147,7 @@ class Logger implements LoggerInterface public function __construct($name, array $handlers = array(), array $processors = array()) { $this->name = $name; - $this->handlers = $handlers; + $this->setHandlers($handlers); $this->processors = $processors; } @@ -281,7 +287,7 @@ public function useMicrosecondTimestamps($micro) * @param int $level The logging level * @param string $message The log message * @param array $context The log context - * @return Boolean Whether the record has been processed + * @return bool Whether the record has been processed */ public function addRecord($level, $message, array $context = array()) { @@ -329,27 +335,75 @@ public function addRecord($level, $message, array $context = array()) 'extra' => array(), ); - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); + try { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + + while ($handler = current($this->handlers)) { + if (true === $handler->handle($record)) { + break; + } + + next($this->handlers); + } + } catch (Exception $e) { + $this->handleException($e, $record); } - while ($handler = current($this->handlers)) { - if (true === $handler->handle($record)) { - break; + return true; + } + + /** + * Ends a log cycle and frees all resources used by handlers. + * + * Closing a Handler means flushing all buffers and freeing any open resources/handles. + * Handlers that have been closed should be able to accept log records again and re-open + * themselves on demand, but this may not always be possible depending on implementation. + * + * This is useful at the end of a request and will be called automatically on every handler + * when they get destructed. + */ + public function close() + { + foreach ($this->handlers as $handler) { + if (method_exists($handler, 'close')) { + $handler->close(); } + } + } - next($this->handlers); + /** + * Ends a log cycle and resets all handlers and processors to their initial state. + * + * Resetting a Handler or a Processor means flushing/cleaning all buffers, resetting internal + * state, and getting it back to a state in which it can receive log records again. + * + * This is useful in case you want to avoid logs leaking between two requests or jobs when you + * have a long running process like a worker or an application server serving multiple requests + * in one process. + */ + public function reset() + { + foreach ($this->handlers as $handler) { + if ($handler instanceof ResettableInterface) { + $handler->reset(); + } } - return true; + foreach ($this->processors as $processor) { + if ($processor instanceof ResettableInterface) { + $processor->reset(); + } + } } /** * Adds a log record at the DEBUG level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addDebug($message, array $context = array()) { @@ -359,9 +413,9 @@ public function addDebug($message, array $context = array()) /** * Adds a log record at the INFO level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addInfo($message, array $context = array()) { @@ -371,9 +425,9 @@ public function addInfo($message, array $context = array()) /** * Adds a log record at the NOTICE level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addNotice($message, array $context = array()) { @@ -383,9 +437,9 @@ public function addNotice($message, array $context = array()) /** * Adds a log record at the WARNING level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addWarning($message, array $context = array()) { @@ -395,9 +449,9 @@ public function addWarning($message, array $context = array()) /** * Adds a log record at the ERROR level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addError($message, array $context = array()) { @@ -407,9 +461,9 @@ public function addError($message, array $context = array()) /** * Adds a log record at the CRITICAL level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addCritical($message, array $context = array()) { @@ -419,9 +473,9 @@ public function addCritical($message, array $context = array()) /** * Adds a log record at the ALERT level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addAlert($message, array $context = array()) { @@ -431,9 +485,9 @@ public function addAlert($message, array $context = array()) /** * Adds a log record at the EMERGENCY level. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function addEmergency($message, array $context = array()) { @@ -484,7 +538,7 @@ public static function toMonologLevel($level) * Checks whether the Logger has a handler that listens on the given level * * @param int $level - * @return Boolean + * @return bool */ public function isHandling($level) { @@ -501,15 +555,52 @@ public function isHandling($level) return false; } + /** + * Set a custom exception handler + * + * @param callable $callback + * @return $this + */ + public function setExceptionHandler($callback) + { + if (!is_callable($callback)) { + throw new \InvalidArgumentException('Exception handler must be valid callable (callback or object with an __invoke method), '.var_export($callback, true).' given'); + } + $this->exceptionHandler = $callback; + + return $this; + } + + /** + * @return callable + */ + public function getExceptionHandler() + { + return $this->exceptionHandler; + } + + /** + * Delegates exception management to the custom exception handler, + * or throws the exception if no custom handler is set. + */ + protected function handleException(Exception $e, array $record) + { + if (!$this->exceptionHandler) { + throw $e; + } + + call_user_func($this->exceptionHandler, $e, $record); + } + /** * Adds a log record at an arbitrary level. * * This method allows for compatibility with common interfaces. * * @param mixed $level The log level - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function log($level, $message, array $context = array()) { @@ -523,9 +614,9 @@ public function log($level, $message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function debug($message, array $context = array()) { @@ -537,9 +628,9 @@ public function debug($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function info($message, array $context = array()) { @@ -551,9 +642,9 @@ public function info($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function notice($message, array $context = array()) { @@ -565,9 +656,9 @@ public function notice($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function warn($message, array $context = array()) { @@ -579,9 +670,9 @@ public function warn($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function warning($message, array $context = array()) { @@ -593,9 +684,9 @@ public function warning($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function err($message, array $context = array()) { @@ -607,9 +698,9 @@ public function err($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function error($message, array $context = array()) { @@ -621,9 +712,9 @@ public function error($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function crit($message, array $context = array()) { @@ -635,9 +726,9 @@ public function crit($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function critical($message, array $context = array()) { @@ -649,9 +740,9 @@ public function critical($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function alert($message, array $context = array()) { @@ -663,9 +754,9 @@ public function alert($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function emerg($message, array $context = array()) { @@ -677,9 +768,9 @@ public function emerg($message, array $context = array()) * * This method allows for compatibility with common interfaces. * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed + * @param string $message The log message + * @param array $context The log context + * @return bool Whether the record has been processed */ public function emergency($message, array $context = array()) { diff --git a/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php index 1899400d..9fc3f50f 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php @@ -19,7 +19,7 @@ * @author Nick Otter * @author Jordi Boggiano */ -class GitProcessor +class GitProcessor implements ProcessorInterface { private $level; private static $cache; diff --git a/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php index 2c07caed..6ae192a2 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php @@ -24,7 +24,7 @@ * * @author Jordi Boggiano */ -class IntrospectionProcessor +class IntrospectionProcessor implements ProcessorInterface { private $level; diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php index 85f9dc5e..2a379a30 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php @@ -16,7 +16,7 @@ * * @author Rob Jensen */ -abstract class MemoryProcessor +abstract class MemoryProcessor implements ProcessorInterface { /** * @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported. @@ -34,8 +34,8 @@ abstract class MemoryProcessor */ public function __construct($realUsage = true, $useFormatting = true) { - $this->realUsage = (boolean) $realUsage; - $this->useFormatting = (boolean) $useFormatting; + $this->realUsage = (bool) $realUsage; + $this->useFormatting = (bool) $useFormatting; } /** diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php index 7c07a7e9..2f5b3265 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/MercurialProcessor.php @@ -18,7 +18,7 @@ * * @author Jonathan A. Schweder */ -class MercurialProcessor +class MercurialProcessor implements ProcessorInterface { private $level; private static $cache; diff --git a/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php index 9d3f5590..66b80fbb 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php @@ -16,7 +16,7 @@ * * @author Andreas Hörnicke */ -class ProcessIdProcessor +class ProcessIdProcessor implements ProcessorInterface { /** * @param array $record diff --git a/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php b/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php new file mode 100644 index 00000000..7e64d4df --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/ProcessorInterface.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * An optional interface to allow labelling Monolog processors. + * + * @author Nicolas Grekas + */ +interface ProcessorInterface +{ + /** + * @return array The processed records + */ + public function __invoke(array $records); +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php index c2686ce5..00885054 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php @@ -11,6 +11,8 @@ namespace Monolog\Processor; +use Monolog\Utils; + /** * Processes a record's message according to PSR-3 rules * @@ -18,7 +20,7 @@ * * @author Jordi Boggiano */ -class PsrLogMessageProcessor +class PsrLogMessageProcessor implements ProcessorInterface { /** * @param array $record @@ -35,7 +37,7 @@ public function __invoke(array $record) if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) { $replacements['{'.$key.'}'] = $val; } elseif (is_object($val)) { - $replacements['{'.$key.'}'] = '[object '.get_class($val).']'; + $replacements['{'.$key.'}'] = '[object '.Utils::getClass($val).']'; } else { $replacements['{'.$key.'}'] = '['.gettype($val).']'; } diff --git a/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php index 7e2df2ac..615a4d99 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php @@ -16,7 +16,7 @@ * * @author Martijn Riemers */ -class TagProcessor +class TagProcessor implements ProcessorInterface { private $tags; diff --git a/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php index 812707cd..d1f708cf 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php @@ -11,12 +11,14 @@ namespace Monolog\Processor; +use Monolog\ResettableInterface; + /** * Adds a unique identifier into records * * @author Simon Mönch */ -class UidProcessor +class UidProcessor implements ProcessorInterface, ResettableInterface { private $uid; @@ -26,7 +28,8 @@ public function __construct($length = 7) throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32'); } - $this->uid = substr(hash('md5', uniqid('', true)), 0, $length); + + $this->uid = $this->generateUid($length); } public function __invoke(array $record) @@ -43,4 +46,14 @@ public function getUid() { return $this->uid; } + + public function reset() + { + $this->uid = $this->generateUid(strlen($this->uid)); + } + + private function generateUid($length) + { + return substr(hash('md5', uniqid('', true)), 0, $length); + } } diff --git a/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php index ea1d8978..684188f6 100644 --- a/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php +++ b/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php @@ -16,7 +16,7 @@ * * @author Jordi Boggiano */ -class WebProcessor +class WebProcessor implements ProcessorInterface { /** * @var array|\ArrayAccess diff --git a/vendor/monolog/monolog/src/Monolog/ResettableInterface.php b/vendor/monolog/monolog/src/Monolog/ResettableInterface.php new file mode 100644 index 00000000..635bc77d --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/ResettableInterface.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +/** + * Handler or Processor implementing this interface will be reset when Logger::reset() is called. + * + * Resetting ends a log cycle gets them back to their initial state. + * + * Resetting a Handler or a Processor means flushing/cleaning all buffers, resetting internal + * state, and getting it back to a state in which it can receive log records again. + * + * This is useful in case you want to avoid logs leaking between two requests or jobs when you + * have a long running process like a worker or an application server serving multiple requests + * in one process. + * + * @author Grégoire Pineau + */ +interface ResettableInterface +{ + public function reset(); +} diff --git a/vendor/monolog/monolog/src/Monolog/SignalHandler.php b/vendor/monolog/monolog/src/Monolog/SignalHandler.php new file mode 100644 index 00000000..d5907805 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/SignalHandler.php @@ -0,0 +1,115 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Psr\Log\LoggerInterface; +use Psr\Log\LogLevel; +use ReflectionExtension; + +/** + * Monolog POSIX signal handler + * + * @author Robert Gust-Bardon + */ +class SignalHandler +{ + private $logger; + + private $previousSignalHandler = array(); + private $signalLevelMap = array(); + private $signalRestartSyscalls = array(); + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + + public function registerSignalHandler($signo, $level = LogLevel::CRITICAL, $callPrevious = true, $restartSyscalls = true, $async = true) + { + if (!extension_loaded('pcntl') || !function_exists('pcntl_signal')) { + return $this; + } + + if ($callPrevious) { + if (function_exists('pcntl_signal_get_handler')) { + $handler = pcntl_signal_get_handler($signo); + if ($handler === false) { + return $this; + } + $this->previousSignalHandler[$signo] = $handler; + } else { + $this->previousSignalHandler[$signo] = true; + } + } else { + unset($this->previousSignalHandler[$signo]); + } + $this->signalLevelMap[$signo] = $level; + $this->signalRestartSyscalls[$signo] = $restartSyscalls; + + if (function_exists('pcntl_async_signals') && $async !== null) { + pcntl_async_signals($async); + } + + pcntl_signal($signo, array($this, 'handleSignal'), $restartSyscalls); + + return $this; + } + + public function handleSignal($signo, array $siginfo = null) + { + static $signals = array(); + + if (!$signals && extension_loaded('pcntl')) { + $pcntl = new ReflectionExtension('pcntl'); + $constants = $pcntl->getConstants(); + if (!$constants) { + // HHVM 3.24.2 returns an empty array. + $constants = get_defined_constants(true); + $constants = $constants['Core']; + } + foreach ($constants as $name => $value) { + if (substr($name, 0, 3) === 'SIG' && $name[3] !== '_' && is_int($value)) { + $signals[$value] = $name; + } + } + unset($constants); + } + + $level = isset($this->signalLevelMap[$signo]) ? $this->signalLevelMap[$signo] : LogLevel::CRITICAL; + $signal = isset($signals[$signo]) ? $signals[$signo] : $signo; + $context = isset($siginfo) ? $siginfo : array(); + $this->logger->log($level, sprintf('Program received signal %s', $signal), $context); + + if (!isset($this->previousSignalHandler[$signo])) { + return; + } + + if ($this->previousSignalHandler[$signo] === true || $this->previousSignalHandler[$signo] === SIG_DFL) { + if (extension_loaded('pcntl') && function_exists('pcntl_signal') && function_exists('pcntl_sigprocmask') && function_exists('pcntl_signal_dispatch') + && extension_loaded('posix') && function_exists('posix_getpid') && function_exists('posix_kill')) { + $restartSyscalls = isset($this->restartSyscalls[$signo]) ? $this->restartSyscalls[$signo] : true; + pcntl_signal($signo, SIG_DFL, $restartSyscalls); + pcntl_sigprocmask(SIG_UNBLOCK, array($signo), $oldset); + posix_kill(posix_getpid(), $signo); + pcntl_signal_dispatch(); + pcntl_sigprocmask(SIG_SETMASK, $oldset); + pcntl_signal($signo, array($this, 'handleSignal'), $restartSyscalls); + } + } elseif (is_callable($this->previousSignalHandler[$signo])) { + if (PHP_VERSION_ID >= 70100) { + $this->previousSignalHandler[$signo]($signo, $siginfo); + } else { + $this->previousSignalHandler[$signo]($signo); + } + } + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Utils.php b/vendor/monolog/monolog/src/Monolog/Utils.php new file mode 100644 index 00000000..eb9be863 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Utils.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +class Utils +{ + /** + * @internal + */ + public static function getClass($object) + { + $class = \get_class($object); + + return 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class; + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php index 622b2bae..fd36dbcf 100644 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php @@ -40,7 +40,7 @@ public function testFormat() $formatter = new FluentdFormatter(); $this->assertEquals( - '["test",0,{"message":"test","extra":[],"level":300,"level_name":"WARNING"}]', + '["test",0,{"message":"test","context":[],"extra":[],"level":300,"level_name":"WARNING"}]', $formatter->format($record) ); } @@ -55,7 +55,7 @@ public function testFormatWithTag() $formatter = new FluentdFormatter(true); $this->assertEquals( - '["test.error",0,{"message":"test","extra":[]}]', + '["test.error",0,{"message":"test","context":[],"extra":[]}]', $formatter->format($record) ); } diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php index c9445f36..24b06cc9 100644 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php @@ -180,4 +180,40 @@ private function formatException($exception, $previous = null) '}'; return $formattedException; } + + public function testNormalizeHandleLargeArraysWithExactly1000Items() + { + $formatter = new NormalizerFormatter(); + $largeArray = range(1, 1000); + + $res = $formatter->format(array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array($largeArray), + 'datetime' => new \DateTime, + 'extra' => array(), + )); + + $this->assertCount(1000, $res['context'][0]); + $this->assertArrayNotHasKey('...', $res['context'][0]); + } + + public function testNormalizeHandleLargeArrays() + { + $formatter = new NormalizerFormatter(); + $largeArray = range(1, 2000); + + $res = $formatter->format(array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array($largeArray), + 'datetime' => new \DateTime, + 'extra' => array(), + )); + + $this->assertCount(1001, $res['context'][0]); + $this->assertEquals('Over 1000 items (2000 total), aborting normalization', $res['context'][0]['...']); + } } diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php index 57bcdf98..bafd1c74 100644 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php @@ -193,6 +193,15 @@ public function testIgnoresRecursiveObjectReferences() $this->assertEquals(@json_encode(array($foo, $bar)), $res); } + public function testCanNormalizeReferences() + { + $formatter = new NormalizerFormatter(); + $x = array('foo' => 'bar'); + $y = array('x' => &$x); + $x['y'] = &$y; + $formatter->format($y); + } + public function testIgnoresInvalidTypes() { // set up the recursion @@ -217,6 +226,24 @@ public function testIgnoresInvalidTypes() $this->assertEquals(@json_encode(array($resource)), $res); } + public function testNormalizeHandleLargeArraysWithExactly1000Items() + { + $formatter = new NormalizerFormatter(); + $largeArray = range(1, 1000); + + $res = $formatter->format(array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array($largeArray), + 'datetime' => new \DateTime, + 'extra' => array(), + )); + + $this->assertCount(1000, $res['context'][0]); + $this->assertArrayNotHasKey('...', $res['context'][0]); + } + public function testNormalizeHandleLargeArrays() { $formatter = new NormalizerFormatter(); @@ -231,7 +258,7 @@ public function testNormalizeHandleLargeArrays() 'extra' => array(), )); - $this->assertCount(1000, $res['context'][0]); + $this->assertCount(1001, $res['context'][0]); $this->assertEquals('Over 1000 items (2000 total), aborting normalization', $res['context'][0]['...']); } @@ -380,6 +407,29 @@ public function testExceptionTraceWithArgs() $result['context']['exception']['trace'][0] ); } + + public function testExceptionTraceDoesNotLeakCallUserFuncArgs() + { + try { + $arg = new TestInfoLeak; + call_user_func(array($this, 'throwHelper'), $arg, $dt = new \DateTime()); + } catch (\Exception $e) { + } + + $formatter = new NormalizerFormatter(); + $record = array('context' => array('exception' => $e)); + $result = $formatter->format($record); + + $this->assertSame( + '{"function":"throwHelper","class":"Monolog\\\\Formatter\\\\NormalizerFormatterTest","type":"->","args":["[object] (Monolog\\\\Formatter\\\\TestInfoLeak)","'.$dt->format('Y-m-d H:i:s').'"]}', + $result['context']['exception']['trace'][0] + ); + } + + private function throwHelper($arg) + { + throw new \RuntimeException('Thrown'); + } } class TestFooNorm @@ -421,3 +471,11 @@ public function __toString() throw new \RuntimeException('Could not convert to string'); } } + +class TestInfoLeak +{ + public function __toString() + { + return 'Sensitive information'; + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php index ffb1d746..ffe45da2 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php @@ -21,7 +21,7 @@ class BrowserConsoleHandlerTest extends TestCase { protected function setUp() { - BrowserConsoleHandler::reset(); + BrowserConsoleHandler::resetStatic(); } protected function generateScript() diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php index 0449f8b1..421cc491 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php @@ -21,7 +21,7 @@ class ChromePHPHandlerTest extends TestCase { protected function setUp() { - TestChromePHPHandler::reset(); + TestChromePHPHandler::resetStatic(); $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0'; } @@ -136,7 +136,7 @@ class TestChromePHPHandler extends ChromePHPHandler { protected $headers = array(); - public static function reset() + public static function resetStatic() { self::$initialized = false; self::$overflowed = false; diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php index b92bf437..0ec36531 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php @@ -58,7 +58,7 @@ public function testHandleStopsBufferingAfterTrigger() * @covers Monolog\Handler\FingersCrossedHandler::activate * @covers Monolog\Handler\FingersCrossedHandler::reset */ - public function testHandleRestartBufferingAfterReset() + public function testHandleResetBufferingAfterReset() { $test = new TestHandler(); $handler = new FingersCrossedHandler($test); @@ -76,7 +76,7 @@ public function testHandleRestartBufferingAfterReset() * @covers Monolog\Handler\FingersCrossedHandler::handle * @covers Monolog\Handler\FingersCrossedHandler::activate */ - public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled() + public function testHandleResetBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled() { $test = new TestHandler(); $handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false); diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php index 0eb10a63..7a404e66 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php @@ -21,7 +21,7 @@ class FirePHPHandlerTest extends TestCase { public function setUp() { - TestFirePHPHandler::reset(); + TestFirePHPHandler::resetStatic(); $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0'; } @@ -77,7 +77,7 @@ class TestFirePHPHandler extends FirePHPHandler { protected $headers = array(); - public static function reset() + public static function resetStatic() { self::$initialized = false; self::$sendHeaders = true; diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/InsightOpsHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/InsightOpsHandlerTest.php new file mode 100644 index 00000000..97c18b59 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/InsightOpsHandlerTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + namespace Monolog\Handler; + + use Monolog\TestCase; + use Monolog\Logger; + +/** + * @author Robert Kaufmann III + * @author Gabriel Machado + */ +class InsightOpsHandlerTest extends TestCase +{ + /** + * @var resource + */ + private $resource; + + /** + * @var LogEntriesHandler + */ + private $handler; + + public function testWriteContent() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test')); + + fseek($this->resource, 0); + $content = fread($this->resource, 1024); + + $this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content); + } + + public function testWriteBatchContent() + { + $this->createHandler(); + $this->handler->handleBatch($this->getMultipleRecords()); + + fseek($this->resource, 0); + $content = fread($this->resource, 1024); + + $this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content); + } + + private function createHandler() + { + $useSSL = extension_loaded('openssl'); + $args = array('testToken', 'us', $useSSL, Logger::DEBUG, true); + $this->resource = fopen('php://memory', 'a'); + $this->handler = $this->getMock( + '\Monolog\Handler\InsightOpsHandler', + array('fsockopen', 'streamSetTimeout', 'closeSocket'), + $args + ); + + $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($this->handler, 'localhost:1234'); + + $this->handler->expects($this->any()) + ->method('fsockopen') + ->will($this->returnValue($this->resource)); + $this->handler->expects($this->any()) + ->method('streamSetTimeout') + ->will($this->returnValue(true)); + $this->handler->expects($this->any()) + ->method('closeSocket') + ->will($this->returnValue(true)); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php index f1feb228..c6f5fac9 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php @@ -191,6 +191,40 @@ public function filenameFormatProvider() ); } + /** + * @dataProvider rotationWhenSimilarFilesExistTests + */ + public function testRotationWhenSimilarFileNamesExist($dateFormat) + { + touch($old1 = __DIR__.'/Fixtures/foo-foo-'.date($dateFormat).'.rot'); + touch($old2 = __DIR__.'/Fixtures/foo-bar-'.date($dateFormat).'.rot'); + + $log = __DIR__.'/Fixtures/foo-'.date($dateFormat).'.rot'; + + $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->setFilenameFormat('{filename}-{date}', $dateFormat); + $handler->handle($this->getRecord()); + $handler->close(); + + $this->assertTrue(file_exists($log)); + } + + public function rotationWhenSimilarFilesExistTests() + { + + return array( + 'Rotation is triggered when the file of the current day is not present but similar exists' + => array(RotatingFileHandler::FILE_PER_DAY), + + 'Rotation is triggered when the file of the current month is not present but similar exists' + => array(RotatingFileHandler::FILE_PER_MONTH), + + 'Rotation is triggered when the file of the current year is not present but similar exists' + => array(RotatingFileHandler::FILE_PER_YEAR), + ); + } + public function testReuseCurrentFile() { $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/Slack/SlackRecordTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/Slack/SlackRecordTest.php index e1aa96d7..b9de7367 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/Slack/SlackRecordTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/Slack/SlackRecordTest.php @@ -320,12 +320,12 @@ public function testAddsLongAttachmentWithContextAndExtra() 'short' => false, ), array( - 'title' => 'tags', + 'title' => 'Tags', 'value' => sprintf('```%s```', json_encode($extra['tags'])), 'short' => false ), array( - 'title' => 'test', + 'title' => 'Test', 'value' => $context['test'], 'short' => false ) @@ -353,6 +353,14 @@ public function testAddsTimestampToAttachment() $this->assertSame($record['datetime']->getTimestamp(), $attachment['ts']); } + public function testContextHasException() + { + $record = $this->getRecord(Logger::CRITICAL, 'This is a critical message.', array('exception' => new \Exception())); + $slackRecord = new SlackRecord(null, null, true, null, false, true); + $data = $slackRecord->getSlackData($record); + $this->assertInternalType('string', $data['attachments'][0]['fields'][1]['value']); + } + public function testExcludeExtraAndContextFields() { $record = $this->getRecord( @@ -368,12 +376,12 @@ public function testExcludeExtraAndContextFields() $expected = array( array( - 'title' => 'info', + 'title' => 'Info', 'value' => sprintf('```%s```', json_encode(array('author' => 'Jordi'), $this->jsonPrettyPrintFlag)), 'short' => false ), array( - 'title' => 'tags', + 'title' => 'Tags', 'value' => sprintf('```%s```', json_encode(array('web'))), 'short' => false ), diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php index 1f9c1f28..1da987c9 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php @@ -77,6 +77,13 @@ public function testSetWritingTimeout() $this->assertEquals(10.25, $this->handler->getWritingTimeout()); } + public function testSetChunkSize() + { + $this->createHandler('localhost:1234'); + $this->handler->setChunkSize(1025); + $this->assertEquals(1025, $this->handler->getChunkSize()); + } + public function testSetConnectionString() { $this->createHandler('tcp://localhost:9090'); @@ -120,6 +127,19 @@ public function testExceptionIsThrownIfCannotSetTimeout() $this->writeRecord('Hello world'); } + /** + * @expectedException UnexpectedValueException + */ + public function testExceptionIsThrownIfCannotSetChunkSize() + { + $this->setMockHandler(array('streamSetChunkSize')); + $this->handler->setChunkSize(8192); + $this->handler->expects($this->once()) + ->method('streamSetChunkSize') + ->will($this->returnValue(false)); + $this->writeRecord('Hello world'); + } + /** * @expectedException RuntimeException */ @@ -304,6 +324,12 @@ private function setMockHandler(array $methods = array()) ->will($this->returnValue(true)); } + if (!in_array('streamSetChunkSize', $methods)) { + $this->handler->expects($this->any()) + ->method('streamSetChunkSize') + ->will($this->returnValue(8192)); + } + $this->handler->setFormatter($this->getIdentityFormatter()); } } diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php index bfb8d3df..a7c4fc98 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php @@ -54,6 +54,52 @@ public function testHandler($method, $level) $this->assertEquals(array($record), $records); } + public function testHandlerAssertEmptyContext() { + $handler = new TestHandler; + $record = $this->getRecord(Logger::WARNING, 'test', array()); + $this->assertFalse($handler->hasWarning(array( + 'message' => 'test', + 'context' => array(), + ))); + + $handler->handle($record); + + $this->assertTrue($handler->hasWarning(array( + 'message' => 'test', + 'context' => array(), + ))); + $this->assertFalse($handler->hasWarning(array( + 'message' => 'test', + 'context' => array( + 'foo' => 'bar' + ), + ))); + } + + public function testHandlerAssertNonEmptyContext() { + $handler = new TestHandler; + $record = $this->getRecord(Logger::WARNING, 'test', array('foo' => 'bar')); + $this->assertFalse($handler->hasWarning(array( + 'message' => 'test', + 'context' => array( + 'foo' => 'bar' + ), + ))); + + $handler->handle($record); + + $this->assertTrue($handler->hasWarning(array( + 'message' => 'test', + 'context' => array( + 'foo' => 'bar' + ), + ))); + $this->assertFalse($handler->hasWarning(array( + 'message' => 'test', + 'context' => array(), + ))); + } + public function methodProvider() { return array( diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php index 8d37a1fc..0594a232 100644 --- a/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php @@ -87,6 +87,29 @@ public function testHandleUsesProcessors() $this->assertTrue($records[0]['extra']['foo']); } + /** + * @covers Monolog\Handler\WhatFailureGroupHandler::handleBatch + */ + public function testHandleBatchUsesProcessors() + { + $testHandlers = array(new TestHandler(), new TestHandler()); + $handler = new WhatFailureGroupHandler($testHandlers); + $handler->pushProcessor(function ($record) { + $record['extra']['foo'] = true; + + return $record; + }); + $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO))); + foreach ($testHandlers as $test) { + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 2); + $records = $test->getRecords(); + $this->assertTrue($records[0]['extra']['foo']); + $this->assertTrue($records[1]['extra']['foo']); + } + } + /** * @covers Monolog\Handler\WhatFailureGroupHandler::handle */ diff --git a/vendor/monolog/monolog/tests/Monolog/LoggerTest.php b/vendor/monolog/monolog/tests/Monolog/LoggerTest.php index 1ecc34a0..442e87de 100644 --- a/vendor/monolog/monolog/tests/Monolog/LoggerTest.php +++ b/vendor/monolog/monolog/tests/Monolog/LoggerTest.php @@ -545,4 +545,146 @@ public function useMicrosecondTimestampsProvider() 'without microseconds' => array(false, PHP_VERSION_ID >= 70100 ? 'assertNotSame' : 'assertSame'), ); } + + /** + * @covers Monolog\Logger::setExceptionHandler + */ + public function testSetExceptionHandler() + { + $logger = new Logger(__METHOD__); + $this->assertNull($logger->getExceptionHandler()); + $callback = function ($ex) { + }; + $logger->setExceptionHandler($callback); + $this->assertEquals($callback, $logger->getExceptionHandler()); + } + + /** + * @covers Monolog\Logger::setExceptionHandler + * @expectedException InvalidArgumentException + */ + public function testBadExceptionHandlerType() + { + $logger = new Logger(__METHOD__); + $logger->setExceptionHandler(false); + } + + /** + * @covers Monolog\Logger::handleException + * @expectedException Exception + */ + public function testDefaultHandleException() + { + $logger = new Logger(__METHOD__); + $handler = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler->expects($this->any()) + ->method('handle') + ->will($this->throwException(new \Exception('Some handler exception'))) + ; + $logger->pushHandler($handler); + $logger->info('test'); + } + + /** + * @covers Monolog\Logger::handleException + * @covers Monolog\Logger::addRecord + */ + public function testCustomHandleException() + { + $logger = new Logger(__METHOD__); + $that = $this; + $logger->setExceptionHandler(function ($e, $record) use ($that) { + $that->assertEquals($e->getMessage(), 'Some handler exception'); + $that->assertTrue(is_array($record)); + $that->assertEquals($record['message'], 'test'); + }); + $handler = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler->expects($this->any()) + ->method('handle') + ->will($this->throwException(new \Exception('Some handler exception'))) + ; + $logger->pushHandler($handler); + $logger->info('test'); + } + + public function testReset() + { + $logger = new Logger('app'); + + $testHandler = new Handler\TestHandler(); + $bufferHandler = new Handler\BufferHandler($testHandler); + $groupHandler = new Handler\GroupHandler(array($bufferHandler)); + $fingersCrossedHandler = new Handler\FingersCrossedHandler($groupHandler); + + $logger->pushHandler($fingersCrossedHandler); + + $processorUid1 = new Processor\UidProcessor(10); + $uid1 = $processorUid1->getUid(); + $groupHandler->pushProcessor($processorUid1); + + $processorUid2 = new Processor\UidProcessor(5); + $uid2 = $processorUid2->getUid(); + $logger->pushProcessor($processorUid2); + + $getProperty = function ($object, $property) { + $reflectionProperty = new \ReflectionProperty(get_class($object), $property); + $reflectionProperty->setAccessible(true); + + return $reflectionProperty->getValue($object); + }; + $that = $this; + $assertBufferOfBufferHandlerEmpty = function () use ($getProperty, $bufferHandler, $that) { + $that->assertEmpty($getProperty($bufferHandler, 'buffer')); + }; + $assertBuffersEmpty = function() use ($assertBufferOfBufferHandlerEmpty, $getProperty, $fingersCrossedHandler, $that) { + $assertBufferOfBufferHandlerEmpty(); + $that->assertEmpty($getProperty($fingersCrossedHandler, 'buffer')); + }; + + $logger->debug('debug'); + $logger->reset(); + $assertBuffersEmpty(); + $this->assertFalse($testHandler->hasDebugRecords()); + $this->assertFalse($testHandler->hasErrorRecords()); + $this->assertNotSame($uid1, $uid1 = $processorUid1->getUid()); + $this->assertNotSame($uid2, $uid2 = $processorUid2->getUid()); + + $logger->debug('debug'); + $logger->error('error'); + $logger->reset(); + $assertBuffersEmpty(); + $this->assertTrue($testHandler->hasDebugRecords()); + $this->assertTrue($testHandler->hasErrorRecords()); + $this->assertNotSame($uid1, $uid1 = $processorUid1->getUid()); + $this->assertNotSame($uid2, $uid2 = $processorUid2->getUid()); + + $logger->info('info'); + $this->assertNotEmpty($getProperty($fingersCrossedHandler, 'buffer')); + $assertBufferOfBufferHandlerEmpty(); + $this->assertFalse($testHandler->hasInfoRecords()); + + $logger->reset(); + $assertBuffersEmpty(); + $this->assertFalse($testHandler->hasInfoRecords()); + $this->assertNotSame($uid1, $uid1 = $processorUid1->getUid()); + $this->assertNotSame($uid2, $uid2 = $processorUid2->getUid()); + + $logger->notice('notice'); + $logger->emergency('emergency'); + $logger->reset(); + $assertBuffersEmpty(); + $this->assertFalse($testHandler->hasInfoRecords()); + $this->assertTrue($testHandler->hasNoticeRecords()); + $this->assertTrue($testHandler->hasEmergencyRecords()); + $this->assertNotSame($uid1, $processorUid1->getUid()); + $this->assertNotSame($uid2, $processorUid2->getUid()); + } } diff --git a/vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php new file mode 100644 index 00000000..9fa07929 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/SignalHandlerTest.php @@ -0,0 +1,287 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Monolog\Handler\StreamHandler; +use Monolog\Handler\TestHandler; +use Psr\Log\LogLevel; + +/** + * @author Robert Gust-Bardon + * @covers Monolog\SignalHandler + */ +class SignalHandlerTest extends TestCase +{ + + private $asyncSignalHandling; + private $blockedSignals; + private $signalHandlers; + + protected function setUp() + { + $this->signalHandlers = array(); + if (extension_loaded('pcntl')) { + if (function_exists('pcntl_async_signals')) { + $this->asyncSignalHandling = pcntl_async_signals(); + } + if (function_exists('pcntl_sigprocmask')) { + pcntl_sigprocmask(SIG_BLOCK, array(), $this->blockedSignals); + } + } + } + + protected function tearDown() + { + if ($this->asyncSignalHandling !== null) { + pcntl_async_signals($this->asyncSignalHandling); + } + if ($this->blockedSignals !== null) { + pcntl_sigprocmask(SIG_SETMASK, $this->blockedSignals); + } + if ($this->signalHandlers) { + pcntl_signal_dispatch(); + foreach ($this->signalHandlers as $signo => $handler) { + pcntl_signal($signo, $handler); + } + } + } + + private function setSignalHandler($signo, $handler = SIG_DFL) { + if (function_exists('pcntl_signal_get_handler')) { + $this->signalHandlers[$signo] = pcntl_signal_get_handler($signo); + } else { + $this->signalHandlers[$signo] = SIG_DFL; + } + $this->assertTrue(pcntl_signal($signo, $handler)); + } + + public function testHandleSignal() + { + $logger = new Logger('test', array($handler = new TestHandler)); + $errHandler = new SignalHandler($logger); + $signo = 2; // SIGINT. + $siginfo = array('signo' => $signo, 'errno' => 0, 'code' => 0); + $errHandler->handleSignal($signo, $siginfo); + $this->assertCount(1, $handler->getRecords()); + $this->assertTrue($handler->hasCriticalRecords()); + $records = $handler->getRecords(); + $this->assertSame($siginfo, $records[0]['context']); + } + + /** + * @depends testHandleSignal + * @requires extension pcntl + * @requires extension posix + * @requires function pcntl_signal + * @requires function pcntl_signal_dispatch + * @requires function posix_getpid + * @requires function posix_kill + */ + public function testRegisterSignalHandler() + { + // SIGCONT and SIGURG should be ignored by default. + if (!defined('SIGCONT') || !defined('SIGURG')) { + $this->markTestSkipped('This test requires the SIGCONT and SIGURG pcntl constants.'); + } + + $this->setSignalHandler(SIGCONT, SIG_IGN); + $this->setSignalHandler(SIGURG, SIG_IGN); + + $logger = new Logger('test', array($handler = new TestHandler)); + $errHandler = new SignalHandler($logger); + $pid = posix_getpid(); + + $this->assertTrue(posix_kill($pid, SIGURG)); + $this->assertTrue(pcntl_signal_dispatch()); + $this->assertCount(0, $handler->getRecords()); + + $errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, false, false); + + $this->assertTrue(posix_kill($pid, SIGCONT)); + $this->assertTrue(pcntl_signal_dispatch()); + $this->assertCount(0, $handler->getRecords()); + + $this->assertTrue(posix_kill($pid, SIGURG)); + $this->assertTrue(pcntl_signal_dispatch()); + $this->assertCount(1, $handler->getRecords()); + $this->assertTrue($handler->hasInfoThatContains('SIGURG')); + } + + /** + * @dataProvider defaultPreviousProvider + * @depends testRegisterSignalHandler + * @requires function pcntl_fork + * @requires function pcntl_sigprocmask + * @requires function pcntl_waitpid + */ + public function testRegisterDefaultPreviousSignalHandler($signo, $callPrevious, $expected) + { + $this->setSignalHandler($signo, SIG_DFL); + + $path = tempnam(sys_get_temp_dir(), 'monolog-'); + $this->assertNotFalse($path); + + $pid = pcntl_fork(); + if ($pid === 0) { // Child. + $streamHandler = new StreamHandler($path); + $streamHandler->setFormatter($this->getIdentityFormatter()); + $logger = new Logger('test', array($streamHandler)); + $errHandler = new SignalHandler($logger); + $errHandler->registerSignalHandler($signo, LogLevel::INFO, $callPrevious, false, false); + pcntl_sigprocmask(SIG_SETMASK, array(SIGCONT)); + posix_kill(posix_getpid(), $signo); + pcntl_signal_dispatch(); + // If $callPrevious is true, SIGINT should terminate by this line. + pcntl_sigprocmask(SIG_BLOCK, array(), $oldset); + file_put_contents($path, implode(' ', $oldset), FILE_APPEND); + posix_kill(posix_getpid(), $signo); + pcntl_signal_dispatch(); + exit(); + } + + $this->assertNotSame(-1, $pid); + $this->assertNotSame(-1, pcntl_waitpid($pid, $status)); + $this->assertNotSame(-1, $status); + $this->assertSame($expected, file_get_contents($path)); + } + + public function defaultPreviousProvider() + { + if (!defined('SIGCONT') || !defined('SIGINT') || !defined('SIGURG')) { + return array(); + } + + return array( + array(SIGINT, false, 'Program received signal SIGINT'.SIGCONT.'Program received signal SIGINT'), + array(SIGINT, true, 'Program received signal SIGINT'), + array(SIGURG, false, 'Program received signal SIGURG'.SIGCONT.'Program received signal SIGURG'), + array(SIGURG, true, 'Program received signal SIGURG'.SIGCONT.'Program received signal SIGURG'), + ); + } + + /** + * @dataProvider callablePreviousProvider + * @depends testRegisterSignalHandler + * @requires function pcntl_signal_get_handler + */ + public function testRegisterCallablePreviousSignalHandler($callPrevious) + { + $this->setSignalHandler(SIGURG, SIG_IGN); + + $logger = new Logger('test', array($handler = new TestHandler)); + $errHandler = new SignalHandler($logger); + $previousCalled = 0; + pcntl_signal(SIGURG, function ($signo, array $siginfo = null) use (&$previousCalled) { + ++$previousCalled; + }); + $errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, $callPrevious, false, false); + $this->assertTrue(posix_kill(posix_getpid(), SIGURG)); + $this->assertTrue(pcntl_signal_dispatch()); + $this->assertCount(1, $handler->getRecords()); + $this->assertTrue($handler->hasInfoThatContains('SIGURG')); + $this->assertSame($callPrevious ? 1 : 0, $previousCalled); + } + + public function callablePreviousProvider() + { + return array( + array(false), + array(true), + ); + } + + /** + * @dataProvider restartSyscallsProvider + * @depends testRegisterDefaultPreviousSignalHandler + * @requires function pcntl_fork + * @requires function pcntl_waitpid + */ + public function testRegisterSyscallRestartingSignalHandler($restartSyscalls) + { + $this->setSignalHandler(SIGURG, SIG_IGN); + + $parentPid = posix_getpid(); + $microtime = microtime(true); + + $pid = pcntl_fork(); + if ($pid === 0) { // Child. + usleep(100000); + posix_kill($parentPid, SIGURG); + usleep(100000); + exit(); + } + + $this->assertNotSame(-1, $pid); + $logger = new Logger('test', array($handler = new TestHandler)); + $errHandler = new SignalHandler($logger); + $errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, $restartSyscalls, false); + if ($restartSyscalls) { + // pcntl_wait is expected to be restarted after the signal handler. + $this->assertNotSame(-1, pcntl_waitpid($pid, $status)); + } else { + // pcntl_wait is expected to be interrupted when the signal handler is invoked. + $this->assertSame(-1, pcntl_waitpid($pid, $status)); + } + $this->assertSame($restartSyscalls, microtime(true) - $microtime > 0.15); + $this->assertTrue(pcntl_signal_dispatch()); + $this->assertCount(1, $handler->getRecords()); + if ($restartSyscalls) { + // The child has already exited. + $this->assertSame(-1, pcntl_waitpid($pid, $status)); + } else { + // The child has not exited yet. + $this->assertNotSame(-1, pcntl_waitpid($pid, $status)); + } + } + + public function restartSyscallsProvider() + { + return array( + array(false), + array(true), + array(false), + array(true), + ); + } + + /** + * @dataProvider asyncProvider + * @depends testRegisterDefaultPreviousSignalHandler + * @requires function pcntl_async_signals + */ + public function testRegisterAsyncSignalHandler($initialAsync, $desiredAsync, $expectedBefore, $expectedAfter) + { + $this->setSignalHandler(SIGURG, SIG_IGN); + pcntl_async_signals($initialAsync); + + $logger = new Logger('test', array($handler = new TestHandler)); + $errHandler = new SignalHandler($logger); + $errHandler->registerSignalHandler(SIGURG, LogLevel::INFO, false, false, $desiredAsync); + $this->assertTrue(posix_kill(posix_getpid(), SIGURG)); + $this->assertCount($expectedBefore, $handler->getRecords()); + $this->assertTrue(pcntl_signal_dispatch()); + $this->assertCount($expectedAfter, $handler->getRecords()); + } + + public function asyncProvider() + { + return array( + array(false, false, 0, 1), + array(false, null, 0, 1), + array(false, true, 1, 1), + array(true, false, 0, 1), + array(true, null, 1, 1), + array(true, true, 1, 1), + ); + } + +} diff --git a/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php b/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php index a0391a52..4b861c3e 100644 --- a/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php +++ b/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php @@ -101,6 +101,9 @@ public function testObjectCastToString() public function testContextCanContainAnything() { + $closed = fopen('php://memory', 'r'); + fclose($closed); + $context = array( 'bool' => true, 'null' => null, @@ -110,6 +113,7 @@ public function testContextCanContainAnything() 'nested' => array('with object' => new DummyTest), 'object' => new \DateTime, 'resource' => fopen('php://memory', 'r'), + 'closed' => $closed, ); $this->getLogger()->warning('Crazy context data', $context); diff --git a/vendor/psr/log/Psr/Log/Test/TestLogger.php b/vendor/psr/log/Psr/Log/Test/TestLogger.php new file mode 100644 index 00000000..0cdffe4f --- /dev/null +++ b/vendor/psr/log/Psr/Log/Test/TestLogger.php @@ -0,0 +1,146 @@ + $level, + 'message' => $message, + 'context' => $context, + ]; + + $this->recordsByLevel[$record['level']][] = $record; + $this->records[] = $record; + } + + public function hasRecords($level) + { + return isset($this->recordsByLevel[$level]); + } + + public function hasRecord($record, $level) + { + if (is_string($record)) { + $record = ['message' => $record]; + } + return $this->hasRecordThatPasses(function ($rec) use ($record) { + if ($rec['message'] !== $record['message']) { + return false; + } + if (isset($record['context']) && $rec['context'] !== $record['context']) { + return false; + } + return true; + }, $level); + } + + public function hasRecordThatContains($message, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($message) { + return strpos($rec['message'], $message) !== false; + }, $level); + } + + public function hasRecordThatMatches($regex, $level) + { + return $this->hasRecordThatPasses(function ($rec) use ($regex) { + return preg_match($regex, $rec['message']) > 0; + }, $level); + } + + public function hasRecordThatPasses(callable $predicate, $level) + { + if (!isset($this->recordsByLevel[$level])) { + return false; + } + foreach ($this->recordsByLevel[$level] as $i => $rec) { + if (call_user_func($predicate, $rec, $i)) { + return true; + } + } + return false; + } + + public function __call($method, $args) + { + if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { + $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; + $level = strtolower($matches[2]); + if (method_exists($this, $genericMethod)) { + $args[] = $level; + return call_user_func_array([$this, $genericMethod], $args); + } + } + throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); + } + + public function reset() + { + $this->records = []; + } +} diff --git a/vendor/psr/log/README.md b/vendor/psr/log/README.md index 574bc1cb..5571a25e 100644 --- a/vendor/psr/log/README.md +++ b/vendor/psr/log/README.md @@ -7,6 +7,13 @@ This repository holds all interfaces/classes/traits related to Note that this is not a logger of its own. It is merely an interface that describes a logger. See the specification for more details. +Installation +------------ + +```bash +composer require psr/log +``` + Usage ----- diff --git a/vendor/rollbar/rollbar/.travis.yml b/vendor/rollbar/rollbar/.travis.yml index 2d3d5d9c..6681d24a 100644 --- a/vendor/rollbar/rollbar/.travis.yml +++ b/vendor/rollbar/rollbar/.travis.yml @@ -8,6 +8,8 @@ php: - 5.6 - 5.5 - 5.4 + - hhvm-3.6 + - hhvm-3.18 - hhvm matrix: include: @@ -22,5 +24,3 @@ script: composer test after_success: - vendor/bin/test-reporter - - diff --git a/vendor/rollbar/rollbar/README.md b/vendor/rollbar/rollbar/README.md index 506b8879..4aa469cd 100644 --- a/vendor/rollbar/rollbar/README.md +++ b/vendor/rollbar/rollbar/README.md @@ -2,7 +2,8 @@ This library detects errors and exceptions in your application and reports them to [Rollbar](https://rollbar.com) for alerts, reporting, and analysis. -Supported PHP versions: 5.3, 5.4, 5.5, 5.6, 7, 7.1, 7.2 and HHVM (currently tested on 3.6.6). +Supported PHP versions: 5.3, 5.4, 5.5, 5.6, 7, 7.1, 7.2 +Supported HHVM versions: 3.6, 3.18, 3.21, 3.24, 3.27 # Setup Instructions @@ -39,8 +40,6 @@ Yii2 package: [baibaratsky/yii2-rollbar](https://github.com/baibaratsky/yii2-rol If you run into any issues, please email us at [support@rollbar.com](mailto:support@rollbar.com) For bug reports, please [open an issue on GitHub](https://github.com/rollbar/rollbar-php/issues/new). -The best, configure your Rollbar with `verbosity` at level `\Psr\Log\LogLevel::DEBUG` and attach -the contents of your `sys_get_temp_dir() . '/rollbar.debug.log'` (usually `/tmp/rollbar.debug.log`). # Contributing diff --git a/vendor/rollbar/rollbar/src/Config.php b/vendor/rollbar/rollbar/src/Config.php index 0551de19..49f49d82 100644 --- a/vendor/rollbar/rollbar/src/Config.php +++ b/vendor/rollbar/rollbar/src/Config.php @@ -19,6 +19,7 @@ class Config 'allow_exec', 'endpoint', 'base_api_url', + 'autodetect_branch', 'branch', 'capture_error_stacktraces', 'check_ignore', @@ -54,7 +55,8 @@ class Config 'send_message_trace', 'include_raw_request_body', 'local_vars_dump', - 'verbosity' + 'max_nesting_depth', + 'max_items' ); private $accessToken; @@ -104,6 +106,8 @@ class Config private $batched = false; private $batchSize = 50; + private $maxNestingDepth = 10; + private $custom = array(); /** @@ -129,24 +133,21 @@ class Config */ private $sendMessageTrace = false; - /** - * @var string (One of the \Psr\Log\LogLevel constants) How much debugging - * info should be recorded in the Rollbar debug log file. - * ($rollbarLogger->getDebugLogFile() => commonly /tmp/rollbar.debug.log. - * Default: Psr\Log\LogLevel::ERROR - */ - private $verbosity; - /** * @var string (fully qualified class name) The name of the your custom * truncation strategy class. The class should inherit from * Rollbar\Truncation\AbstractStrategy. */ private $customTruncation; + + /** + * @var int The maximum number of items reported to Rollbar within one + * request. + */ + private $maxItems; public function __construct(array $configArray) { - $this->verbosity = \Rollbar\Defaults::get()->verbosity(); $this->includedErrno = \Rollbar\Defaults::get()->includedErrno(); $this->levelFactory = new LevelFactory(); @@ -215,11 +216,11 @@ protected function updateConfig($config) $this->setScrubber($config); $this->setBatched($config); $this->setBatchSize($config); + $this->setMaxNestingDepth($config); $this->setCustom($config); $this->setResponseHandler($config); $this->setCheckIgnoreFunction($config); $this->setSendMessageTrace($config); - $this->setVerbosity($config); if (isset($config['included_errno'])) { $this->includedErrno = $config['included_errno']; @@ -230,6 +231,11 @@ protected function updateConfig($config) $this->useErrorReporting = $config['use_error_reporting']; } + $this->maxItems = \Rollbar\Defaults::get()->maxItems(); + if (isset($config['max_items'])) { + $this->maxItems = $config['max_items']; + } + if (isset($config['custom_truncation'])) { $this->customTruncation = $config['custom_truncation']; } @@ -361,6 +367,13 @@ private function setBatchSize($config) } } + private function setMaxNestingDepth($config) + { + if (array_key_exists('max_nesting_depth', $config)) { + $this->maxNestingDepth = $config['max_nesting_depth']; + } + } + public function setCustom($config) { $this->dataBuilder->setCustom($config); @@ -381,6 +394,11 @@ public function getCustom() return $this->dataBuilder->getCustom(); } + public function getAllowedCircularReferenceTypes() + { + return $this->allowedCircularReferenceTypes; + } + public function setCustomTruncation($type) { $this->customTruncation = $type; @@ -475,20 +493,6 @@ private function setSendMessageTrace($config) $this->sendMessageTrace = $config['send_message_trace']; } - - private function setVerbosity($config) - { - if (!isset($config['verbosity'])) { - return; - } - - $this->verbosity = $config['verbosity']; - } - - public function getVerbosity() - { - return $this->verbosity; - } /** * Allows setting up configuration options that might be specified by class @@ -522,16 +526,16 @@ protected function setupWithOptions( $passWholeConfig = false ) { - $$keyName = isset($config[$keyName]) ? $config[$keyName] : null; + $class = isset($config[$keyName]) ? $config[$keyName] : null; - if (is_null($defaultClass) && is_null($$keyName)) { + if (is_null($defaultClass) && is_null($class)) { return; } - if (is_null($$keyName)) { - $$keyName = $defaultClass; + if (is_null($class)) { + $class = $defaultClass; } - if (is_string($$keyName)) { + if (is_string($class)) { if ($passWholeConfig) { $options = $config; } else { @@ -539,9 +543,9 @@ protected function setupWithOptions( $config[$keyName . "Options"] : array(); } - $this->$keyName = new $$keyName($options); + $this->$keyName = new $class($options); } else { - $this->$keyName = $$keyName; + $this->$keyName = $class; } if (!$this->$keyName instanceof $expectedType) { @@ -586,6 +590,16 @@ public function getBatchSize() return $this->batchSize; } + public function getMaxNestingDepth() + { + return $this->maxNestingDepth; + } + + public function getMaxItems() + { + return $this->maxItems; + } + /** * @param Payload $payload * @param Level $level diff --git a/vendor/rollbar/rollbar/src/DataBuilder.php b/vendor/rollbar/rollbar/src/DataBuilder.php index c40316c8..dd128726 100644 --- a/vendor/rollbar/rollbar/src/DataBuilder.php +++ b/vendor/rollbar/rollbar/src/DataBuilder.php @@ -259,11 +259,22 @@ protected function setServerBranch($config) if (!isset($fromConfig)) { $fromConfig = isset($config['branch']) ? $config['branch'] : null; } - $allowExec = isset($config['allow_exec']) ? $config['allow_exec'] : null; - if (!isset($allowExec)) { - $allowExec = true; + + $this->serverBranch = self::$defaults->branch($fromConfig); + + if ($this->serverBranch === null) { + $autodetectBranch = isset($config['autodetect_branch']) ? + $config['autodetect_branch'] : + self::$defaults->autodetectBranch(); + + if ($autodetectBranch) { + $allowExec = isset($config['allow_exec']) ? + $config['allow_exec'] : + self::$defaults->allowExec(); + + $this->serverBranch = $this->detectGitBranch($allowExec); + } } - $this->serverBranch = self::$defaults->gitBranch($fromConfig, $allowExec); } protected function setServerCodeVersion($config) @@ -390,9 +401,9 @@ protected function getBody($toLog, $context) } elseif ($toLog instanceof $baseException) { $content = $this->getExceptionTrace($toLog); } else { - $content = $this->getMessage($toLog, $context); + $content = $this->getMessage($toLog); } - return new Body($content); + return new Body($content, $context); } public function getErrorTrace(ErrorWrapper $error) @@ -520,11 +531,10 @@ private function getTrace($exc) } } - protected function getMessage($toLog, $context) + protected function getMessage($toLog) { return new Message( (string)$toLog, - $context, $this->sendMessageTrace ? debug_backtrace($this->localVarsDump ? 0 : DEBUG_BACKTRACE_IGNORE_ARGS) : null @@ -968,7 +978,7 @@ protected function getCustomForPayload($toLog, $context) unset($context['custom_data_method_context']); - return array_replace_recursive(array(), $context, $custom); + return $custom; } public function addCustom($key, $data) @@ -1132,4 +1142,34 @@ private function stripShutdownFrames($backTrace) return $backTrace; } + + public function detectGitBranch($allowExec = true) + { + if ($allowExec) { + static $cachedValue; + static $hasExecuted = false; + if (!$hasExecuted) { + $cachedValue = self::getGitBranch(); + $hasExecuted = true; + } + return $cachedValue; + } + return null; + } + + private static function getGitBranch() + { + try { + if (function_exists('shell_exec')) { + $stdRedirCmd = Utilities::isWindows() ? " > NUL" : " 2> /dev/null"; + $output = rtrim(shell_exec('git rev-parse --abbrev-ref HEAD' . $stdRedirCmd)); + if ($output) { + return $output; + } + } + return null; + } catch (\Exception $e) { + return null; + } + } } diff --git a/vendor/rollbar/rollbar/src/Defaults.php b/vendor/rollbar/rollbar/src/Defaults.php index 747b43d7..df7f6fb4 100644 --- a/vendor/rollbar/rollbar/src/Defaults.php +++ b/vendor/rollbar/rollbar/src/Defaults.php @@ -6,9 +6,6 @@ class Defaults { - private $utilities; - private $data; - private static $singleton = null; public static function get() { @@ -20,9 +17,7 @@ public static function get() public function __construct($utilities) { - $this->data = array(); - - $this->data['psrLevels'] = array( + $this->psrLevels = array( LogLevel::EMERGENCY => "critical", "emergency" => "critical", LogLevel::ALERT => "critical", @@ -40,7 +35,7 @@ public function __construct($utilities) LogLevel::DEBUG => "debug", "debug" => "debug" ); - $this->data['errorLevels'] = array( + $this->errorLevels = array( E_ERROR => "error", E_WARNING => "warning", E_PARSE => "critical", @@ -57,47 +52,7 @@ public function __construct($utilities) E_DEPRECATED => "info", E_USER_DEPRECATED => "info" ); - $this->data['gitHash'] = null; - $this->data['gitBranch'] = null; - $this->data['serverRoot'] = isset($_ENV["HEROKU_APP_DIR"]) ? $_ENV["HEROKU_APP_DIR"] : null; - $this->data['platform'] = php_uname('a'); - $this->data['notifier'] = Notifier::defaultNotifier(); - $this->data['baseException'] = version_compare(phpversion(), '7.0', '<') ? '\Exception' : '\Throwable'; - $this->data['codeVersion'] = ""; - $this->data['sendMessageTrace'] = false; - $this->data['includeCodeContext'] = false; - $this->data['includeExcCodeContext'] = false; - $this->data['rawRequestBody'] = false; - $this->data['localVarsDump'] = true; - $this->data['errorSampleRates'] = array(); - $this->data['exceptionSampleRates'] = array(); - $this->data['includedErrno'] = ROLLBAR_INCLUDED_ERRNO_BITMASK; - $this->data['includeErrorCodeContext'] = null; - $this->data['includeExceptionCodeContext'] = null; - $this->data['agentLogLocation'] = '/var/tmp'; - $this->data['allowExec'] = true; - $this->data['messageLevel'] = "warning"; - $this->data['exceptionLevel'] = "error"; - $this->data['endpoint'] = 'https://api.rollbar.com/api/1/'; - $this->data['captureErrorStacktraces'] = true; - $this->data['checkIgnore'] = null; - $this->data['custom'] = null; - $this->data['customDataMethod'] = null; - $this->data['enabled'] = true; - $this->data['environment'] = 'production'; - $this->data['fluentHost'] = '127.0.0.1'; - $this->data['fluentPort'] = 24224; - $this->data['fluentTag'] = 'rollbar'; - $this->data['handler'] = 'blocking'; - $this->data['host'] = null; - $this->data['timeout'] = 3; - $this->data['reportSuppressed'] = false; - $this->data['useErrorReporting'] = false; - $this->data['verbosity'] = \Psr\Log\LogLevel::ERROR; - $this->data['captureIP'] = true; - $this->data['captureEmail'] = false; - $this->data['captureUsername'] = false; - $this->data['scrubFields'] = array( + $this->scrubFields = array( 'passwd', 'password', 'secret', @@ -107,57 +62,300 @@ public function __construct($utilities) 'csrf_token', 'access_token' ); - $this->data['customTruncation'] = null; + $this->serverRoot = isset($_ENV["HEROKU_APP_DIR"]) ? $_ENV["HEROKU_APP_DIR"] : null; + $this->platform = php_uname('a'); + $this->notifier = Notifier::defaultNotifier(); + $this->baseException = version_compare(phpversion(), '7.0', '<') ? '\Exception' : '\Throwable'; + $this->errorSampleRates = array(); + $this->exceptionSampleRates = array(); $this->utilities = $utilities; } - public function __call($method, $args) + public function fromSnakeCase($option) { - if (!array_key_exists($method, $this->data)) { + $spaced = str_replace('_', ' ', $option); + $method = lcfirst(str_replace(' ', '', ucwords($spaced))); + + if (method_exists($this, $method)) { + return $this->$method(); + } else { throw new \Exception('No default value defined for property ' . $method . '.'); } - - return (isset($args[0]) && $args[0] !== null) ? $args[0] : $this->data[$method]; } - public function fromSnakeCase($option) + private $utilities; + private $data; + private static $singleton = null; + + public function psrLevels($value = null) { - $spaced = str_replace('_', ' ', $option); - $method = lcfirst(str_replace(' ', '', ucwords($spaced))); - return $this->$method(); + return $value !== null ? $value : $this->psrLevels; } - public function gitBranch($gitBranch = null, $allowExec = true) + public function errorLevels($value = null) { - if ($gitBranch) { - return $gitBranch; - } - if ($allowExec) { - static $cachedValue; - static $hasExecuted = false; - if (!$hasExecuted) { - $cachedValue = self::getGitBranch(); - $hasExecuted = true; - } - return $cachedValue; - } - return null; + return $value !== null ? $value : $this->errorLevels; + } + + public function autodetectBranch($value = null) + { + return $value !== null ? $value : $this->autodetectBranch; + } + + public function branch($value = null) + { + return $value !== null ? $value : $this->branch; + } + + public function serverRoot($value = null) + { + return $value !== null ? $value : $this->serverRoot; + } + + public function platform($value = null) + { + return $value !== null ? $value : $this->platform; + } + + public function notifier($value = null) + { + return $value !== null ? $value : $this->notifier; + } + + public function baseException($value = null) + { + return $value !== null ? $value : $this->baseException; + } + + public function codeVersion($value = null) + { + return $value !== null ? $value : $this->codeVersion; + } + + public function sendMessageTrace($value = null) + { + return $value !== null ? $value : $this->sendMessageTrace; + } + + public function includeCodeContext($value = null) + { + return $value !== null ? $value : $this->includeCodeContext; + } + + public function includeExcCodeContext($value = null) + { + return $value !== null ? $value : $this->includeExcCodeContext; + } + + public function rawRequestBody($value = null) + { + return $value !== null ? $value : $this->rawRequestBody; + } + + public function localVarsDump($value = null) + { + return $value !== null ? $value : $this->localVarsDump; + } + + public function errorSampleRates($value = null) + { + return $value !== null ? $value : $this->errorSampleRates; + } + + public function exceptionSampleRates($value = null) + { + return $value !== null ? $value : $this->exceptionSampleRates; + } + + public function includedErrno($value = null) + { + return $value !== null ? $value : $this->includedErrno; + } + + public function includeErrorCodeContext($value = null) + { + return $value !== null ? $value : $this->includeErrorCodeContext; + } + + public function includeExceptionCodeContext($value = null) + { + return $value !== null ? $value : $this->includeExceptionCodeContext; + } + + public function agentLogLocation($value = null) + { + return $value !== null ? $value : $this->agentLogLocation; + } + + public function allowExec($value = null) + { + return $value !== null ? $value : $this->allowExec; + } + + public function messageLevel($value = null) + { + return $value !== null ? $value : $this->messageLevel; + } + + public function exceptionLevel($value = null) + { + return $value !== null ? $value : $this->exceptionLevel; + } + + public function endpoint($value = null) + { + return $value !== null ? $value : $this->endpoint; + } + + public function captureErrorStacktraces($value = null) + { + return $value !== null ? $value : $this->captureErrorStacktraces; + } + + public function checkIgnore($value = null) + { + return $value !== null ? $value : $this->checkIgnore; + } + + public function custom($value = null) + { + return $value !== null ? $value : $this->custom; + } + + public function customDataMethod($value = null) + { + return $value !== null ? $value : $this->customDataMethod; + } + + public function enabled($value = null) + { + return $value !== null ? $value : $this->enabled; + } + + public function environment($value = null) + { + return $value !== null ? $value : $this->environment; + } + + public function fluentHost($value = null) + { + return $value !== null ? $value : $this->fluentHost; + } + + public function fluentPort($value = null) + { + return $value !== null ? $value : $this->fluentPort; + } + + public function fluentTag($value = null) + { + return $value !== null ? $value : $this->fluentTag; + } + + public function handler($value = null) + { + return $value !== null ? $value : $this->handler; + } + + public function host($value = null) + { + return $value !== null ? $value : $this->host; + } + + public function timeout($value = null) + { + return $value !== null ? $value : $this->timeout; + } + + public function reportSuppressed($value = null) + { + return $value !== null ? $value : $this->reportSuppressed; + } + + public function useErrorReporting($value = null) + { + return $value !== null ? $value : $this->useErrorReporting; + } + + public function captureIP($value = null) + { + return $value !== null ? $value : $this->captureIP; + } + + public function captureEmail($value = null) + { + return $value !== null ? $value : $this->captureEmail; + } + + public function captureUsername($value = null) + { + return $value !== null ? $value : $this->captureUsername; + } + + public function scrubFields($value = null) + { + return $value !== null ? $value : $this->scrubFields; + } + + public function customTruncation($value = null) + { + return $value !== null ? $value : $this->customTruncation; + } + + public function maxNestingDepth($value = null) + { + return $value !== null ? $value : $this->maxNestingDepth; } - private static function getGitBranch() - { - try { - if (function_exists('shell_exec')) { - $stdRedirCmd = Utilities::isWindows() ? " > NUL" : " 2> /dev/null"; - $output = rtrim(shell_exec('git rev-parse --abbrev-ref HEAD' . $stdRedirCmd)); - if ($output) { - return $output; - } - } - return null; - } catch (\Exception $e) { - return null; - } + public function maxItems($value = null) + { + return $value !== null ? $value : $this->maxItems; } + + private $psrLevels; + private $errorLevels; + private $autodetectBranch = false; + private $branch = null; + private $serverRoot; + private $platform; + private $notifier; + private $baseException; + private $codeVersion = ""; + private $sendMessageTrace = false; + private $includeCodeContext = false; + private $includeExcCodeContext = false; + private $rawRequestBody = false; + private $localVarsDump = true; + private $maxNestingDepth = -1; + private $errorSampleRates = array(); + private $exceptionSampleRates = array(); + private $includedErrno = ROLLBAR_INCLUDED_ERRNO_BITMASK; + private $includeErrorCodeContext = null; + private $includeExceptionCodeContext = null; + private $agentLogLocation = '/var/tmp'; + private $allowExec = true; + private $messageLevel = "warning"; + private $exceptionLevel = "error"; + private $endpoint = 'https://api.rollbar.com/api/1/'; + private $captureErrorStacktraces = true; + private $checkIgnore = null; + private $custom = null; + private $customDataMethod = null; + private $enabled = true; + private $environment = 'production'; + private $fluentHost = '127.0.0.1'; + private $fluentPort = 24224; + private $fluentTag = 'rollbar'; + private $handler = 'blocking'; + private $host = null; + private $timeout = 3; + private $reportSuppressed = false; + private $useErrorReporting = false; + private $captureIP = true; + private $captureEmail = false; + private $captureUsername = false; + private $scrubFields; + private $customTruncation = null; + private $maxItems = 10; } diff --git a/vendor/rollbar/rollbar/src/ErrorWrapper.php b/vendor/rollbar/rollbar/src/ErrorWrapper.php index 5ed219b7..6c0942e4 100644 --- a/vendor/rollbar/rollbar/src/ErrorWrapper.php +++ b/vendor/rollbar/rollbar/src/ErrorWrapper.php @@ -62,6 +62,6 @@ public function getBacktrace() public function getClassName() { $constName = self::getConstName($this->errorLevel) ?: "#$this->errorLevel"; - return "$constName: $this->errorMessage"; + return "$constName"; } } diff --git a/vendor/rollbar/rollbar/src/Payload/Body.php b/vendor/rollbar/rollbar/src/Payload/Body.php index 1d19c2a3..50fe2bb5 100644 --- a/vendor/rollbar/rollbar/src/Payload/Body.php +++ b/vendor/rollbar/rollbar/src/Payload/Body.php @@ -7,11 +7,13 @@ class Body implements \Serializable */ private $value; private $utilities; + private $extra; - public function __construct(ContentInterface $value) + public function __construct(ContentInterface $value, array $extra = array()) { $this->utilities = new \Rollbar\Utilities(); $this->setValue($value); + $this->setExtra($extra); } public function getValue() @@ -24,12 +26,34 @@ public function setValue(ContentInterface $value) $this->value = $value; return $this; } + + public function setExtra(array $extra) + { + $this->extra = $extra; + return $this; + } + + public function getExtra() + { + return $this->extra; + } public function serialize() { $result = array(); $result[$this->value->getKey()] = $this->value; - return $this->utilities->serializeForRollbar($result); + + if (!empty($this->extra)) { + $result['extra'] = $this->extra; + } + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar( + $result, + array('extra'), + $objectHashes + ); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Context.php b/vendor/rollbar/rollbar/src/Payload/Context.php index 98010246..aa94d499 100644 --- a/vendor/rollbar/rollbar/src/Payload/Context.php +++ b/vendor/rollbar/rollbar/src/Payload/Context.php @@ -41,7 +41,10 @@ public function serialize() "pre" => $this->pre, "post" => $this->post, ); - return $this->utilities->serializeForRollbar($result); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, null, $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Data.php b/vendor/rollbar/rollbar/src/Payload/Data.php index 68c3c70b..2b241cf4 100644 --- a/vendor/rollbar/rollbar/src/Payload/Data.php +++ b/vendor/rollbar/rollbar/src/Payload/Data.php @@ -250,7 +250,10 @@ public function serialize() "uuid" => $this->uuid, "notifier" => $this->notifier, ); - return $this->utilities->serializeForRollbar($result); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, null, $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/EncodedPayload.php b/vendor/rollbar/rollbar/src/Payload/EncodedPayload.php index d6cae625..9cb64288 100644 --- a/vendor/rollbar/rollbar/src/Payload/EncodedPayload.php +++ b/vendor/rollbar/rollbar/src/Payload/EncodedPayload.php @@ -23,7 +23,7 @@ public function size() public function decreaseSize($amount) { - $this->size =- $amount; + $this->size -= $amount; } public function encode($data = null) diff --git a/vendor/rollbar/rollbar/src/Payload/ExceptionInfo.php b/vendor/rollbar/rollbar/src/Payload/ExceptionInfo.php index 40e183b4..75c5d34b 100644 --- a/vendor/rollbar/rollbar/src/Payload/ExceptionInfo.php +++ b/vendor/rollbar/rollbar/src/Payload/ExceptionInfo.php @@ -55,7 +55,10 @@ public function serialize() "message" => $this->message, "description" => $this->description, ); - return $this->utilities->serializeForRollbar($result); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, null, $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Frame.php b/vendor/rollbar/rollbar/src/Payload/Frame.php index 029ddbee..4bd878f7 100644 --- a/vendor/rollbar/rollbar/src/Payload/Frame.php +++ b/vendor/rollbar/rollbar/src/Payload/Frame.php @@ -105,7 +105,10 @@ public function serialize() "context" => $this->context, "args" => $this->args ); - return $this->utilities->serializeForRollbar($result); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, null, $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Message.php b/vendor/rollbar/rollbar/src/Payload/Message.php index a2fb9178..6f93931c 100644 --- a/vendor/rollbar/rollbar/src/Payload/Message.php +++ b/vendor/rollbar/rollbar/src/Payload/Message.php @@ -3,19 +3,16 @@ class Message implements ContentInterface { private $body; - private $extra; private $backtrace; private $utilities; public function __construct( $body, - array $extra = null, $backtrace = null ) { $this->utilities = new \Rollbar\Utilities(); $this->setBody($body); $this->setBacktrace($backtrace); - $this->extra = $extra == null ? array() : $extra; } public function getKey() @@ -45,26 +42,13 @@ public function setBacktrace($backtrace) return $this; } - public function __set($key, $val) - { - $this->extra[$key] = $val; - } - - public function __get($key) - { - return isset($this->extra[$key]) ? $this->extra[$key] : null; - } - public function serialize() { $toSerialize = array( "body" => $this->getBody(), "backtrace" => $this->getBacktrace() ); - foreach ($this->extra as $key => $value) { - $toSerialize[$key] = $value; - } - return $this->utilities->serializeForRollbar($toSerialize, array_keys($this->extra)); + return $this->utilities->serializeForRollbar($toSerialize); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Notifier.php b/vendor/rollbar/rollbar/src/Payload/Notifier.php index 39560794..195cbcb3 100644 --- a/vendor/rollbar/rollbar/src/Payload/Notifier.php +++ b/vendor/rollbar/rollbar/src/Payload/Notifier.php @@ -3,7 +3,7 @@ class Notifier implements \Serializable { const NAME = "rollbar-php"; - const VERSION = "1.6.2"; + const VERSION = "1.7.4"; public static function defaultNotifier() { @@ -49,7 +49,10 @@ public function serialize() "name" => $this->name, "version" => $this->version, ); - return $this->utilities->serializeForRollbar($result); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, null, $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Payload.php b/vendor/rollbar/rollbar/src/Payload/Payload.php index 96b1edcf..61370bcd 100644 --- a/vendor/rollbar/rollbar/src/Payload/Payload.php +++ b/vendor/rollbar/rollbar/src/Payload/Payload.php @@ -41,13 +41,15 @@ public function setAccessToken($accessToken) return $this; } - public function serialize() + public function serialize($maxDepth = -1) { + $objectHashes = array(); $result = array( "data" => $this->data, "access_token" => $this->accessToken, ); - return $this->utilities->serializeForRollbar($result); + + return $this->utilities->serializeForRollbar($result, null, $objectHashes, $maxDepth); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Person.php b/vendor/rollbar/rollbar/src/Payload/Person.php index d41eb7a2..e103dba8 100644 --- a/vendor/rollbar/rollbar/src/Payload/Person.php +++ b/vendor/rollbar/rollbar/src/Payload/Person.php @@ -76,7 +76,10 @@ public function serialize() foreach ($this->extra as $key => $val) { $result[$key] = $val; } - return $this->utilities->serializeForRollbar($result, array_keys($this->extra)); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, array_keys($this->extra), $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Request.php b/vendor/rollbar/rollbar/src/Payload/Request.php index 6d86d33c..afa26aec 100644 --- a/vendor/rollbar/rollbar/src/Payload/Request.php +++ b/vendor/rollbar/rollbar/src/Payload/Request.php @@ -149,7 +149,10 @@ public function serialize() foreach ($this->extra as $key => $val) { $result[$key] = $val; } - return $this->utilities->serializeForRollbar($result, array_keys($this->extra)); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, array_keys($this->extra), $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/Payload/Server.php b/vendor/rollbar/rollbar/src/Payload/Server.php index 0dd8b099..2265ec12 100644 --- a/vendor/rollbar/rollbar/src/Payload/Server.php +++ b/vendor/rollbar/rollbar/src/Payload/Server.php @@ -84,7 +84,10 @@ public function serialize() foreach ($this->extra as $key => $val) { $result[$key] = $val; } - return $this->utilities->serializeForRollbar($result, array_keys($this->extra)); + + $objectHashes = \Rollbar\Utilities::getObjectHashes(); + + return $this->utilities->serializeForRollbar($result, array_keys($this->extra), $objectHashes); } public function unserialize($serialized) diff --git a/vendor/rollbar/rollbar/src/RollbarLogger.php b/vendor/rollbar/rollbar/src/RollbarLogger.php index bcd77bf9..02d26543 100644 --- a/vendor/rollbar/rollbar/src/RollbarLogger.php +++ b/vendor/rollbar/rollbar/src/RollbarLogger.php @@ -14,8 +14,7 @@ class RollbarLogger extends AbstractLogger private $levelFactory; private $truncation; private $queue; - private $debugLogger; - private $debugLogFile; + private $reportCount = 0; public function __construct(array $config) { @@ -23,13 +22,6 @@ public function __construct(array $config) $this->levelFactory = new LevelFactory(); $this->truncation = new Truncation($this->config); $this->queue = array(); - - $this->debugLogFile = sys_get_temp_dir() . '/rollbar.debug.log'; - $this->debugLogger = new MonologLogger("RollbarDebugLogger"); - $this->debugLogger->pushHandler(new StreamHandler( - $this->debugLogFile, - $this->config->getVerbosity() - )); } public function enable() @@ -100,21 +92,12 @@ public function log($level, $toLog, array $context = array(), $isUncaught = fals if ($this->config->checkIgnored($payload, $accessToken, $toLog, $isUncaught)) { $response = new Response(0, "Ignored"); } else { - $serialized = $payload->serialize(); + $serialized = $payload->serialize($this->config->getMaxNestingDepth()); $scrubbed = $this->scrub($serialized); $encoded = $this->encode($scrubbed); $truncated = $this->truncate($encoded); - $this->debugLogger->info( - "Payload scrubbed and ready to send to ". - $this->config->getSender()->toString() - ); - $this->debugLogger->debug($truncated); - $response = $this->send($truncated, $accessToken); - - $this->debugLogger->info("Received response from Rollbar API."); - $this->debugLogger->debug(print_r($response, true)); } $this->handleResponse($payload, $response); @@ -150,6 +133,17 @@ public function getQueueSize() protected function send(\Rollbar\Payload\EncodedPayload $payload, $accessToken) { + if ($this->reportCount >= $this->config->getMaxItems()) { + return new Response( + 0, + "Maximum number of items per request has been reached. If you " . + "want to report more items, please use `max_items` " . + "configuration option." + ); + } else { + $this->reportCount++; + } + if ($this->config->getBatched()) { $response = new Response(0, "Pending"); if ($this->getQueueSize() >= $this->config->getBatchSize()) { @@ -158,6 +152,7 @@ protected function send(\Rollbar\Payload\EncodedPayload $payload, $accessToken) $this->queue[] = $payload; return $response; } + return $this->config->send($payload, $accessToken); } @@ -177,11 +172,6 @@ public function getDataBuilder() { return $this->config->getDataBuilder(); } - - public function getDebugLogFile() - { - return $this->debugLogFile; - } protected function handleResponse($payload, $response) { diff --git a/vendor/rollbar/rollbar/src/Truncation/StringsStrategy.php b/vendor/rollbar/rollbar/src/Truncation/StringsStrategy.php index 71d05ede..104bf135 100644 --- a/vendor/rollbar/rollbar/src/Truncation/StringsStrategy.php +++ b/vendor/rollbar/rollbar/src/Truncation/StringsStrategy.php @@ -16,6 +16,8 @@ public function execute(EncodedPayload $payload) $modified = false; foreach (static::getThresholds() as $threshold) { + $maxPayloadSize = \Rollbar\Truncation\Truncation::MAX_PAYLOAD_SIZE; + if (!$this->truncation->needsTruncating($payload, $this)) { break; } @@ -38,9 +40,12 @@ protected function traverse(&$data, $threshold, $payload) foreach ($data as $key => &$value) { if (is_array($value)) { - return $this->traverse($value, $threshold, $payload); + if ($this->traverse($value, $threshold, $payload)) { + $modified = true; + } } else { - if (is_string($value) && $strlen = strlen($value) > $threshold) { + $strlen = strlen($value); + if (is_string($value) && $strlen > $threshold) { $value = substr($value, 0, $threshold); $modified = true; $payload->decreaseSize($strlen - $threshold); diff --git a/vendor/rollbar/rollbar/src/Truncation/Truncation.php b/vendor/rollbar/rollbar/src/Truncation/Truncation.php index 2840a7a7..4793bff3 100644 --- a/vendor/rollbar/rollbar/src/Truncation/Truncation.php +++ b/vendor/rollbar/rollbar/src/Truncation/Truncation.php @@ -5,7 +5,7 @@ class Truncation { - const MAX_PAYLOAD_SIZE = 524288; // 512 * 1024 + const MAX_PAYLOAD_SIZE = 131072; // 128 * 1024 protected static $truncationStrategies = array( "Rollbar\Truncation\FramesStrategy", diff --git a/vendor/rollbar/rollbar/src/Utilities.php b/vendor/rollbar/rollbar/src/Utilities.php index 6d716833..8027ff34 100644 --- a/vendor/rollbar/rollbar/src/Utilities.php +++ b/vendor/rollbar/rollbar/src/Utilities.php @@ -2,6 +2,13 @@ final class Utilities { + private static $ObjectHashes; + + public static function getObjectHashes() + { + return self::$ObjectHashes; + } + public static function isWindows() { return php_uname('s') == 'Windows NT'; @@ -72,19 +79,42 @@ public static function validateInteger( public static function serializeForRollbar( $obj, - array $customKeys = null + array $customKeys = null, + &$objectHashes = array(), + $maxDepth = -1, + $depth = 0 ) { + $returnVal = array(); + + if (is_object($obj)) { + if (self::serializedAlready($obj, $objectHashes)) { + return self::circularReferenceLabel($obj); + } else { + self::markSerialized($obj, $objectHashes); + } + } + + if ($maxDepth > 0 && $depth > $maxDepth) { + return null; + } foreach ($obj as $key => $val) { - if ($val instanceof \Serializable) { - $val = $val->serialize(); + if (is_object($val)) { + $val = self::serializeObject( + $val, + $customKeys, + $objectHashes, + $maxDepth, + $depth + ); } elseif (is_array($val)) { - $val = self::serializeForRollbar($val); - } elseif (is_object($val)) { - $val = array( - 'class' => get_class($val), - 'value' => $val + $val = self::serializeForRollbar( + $val, + $customKeys, + $objectHashes, + $maxDepth, + $depth+1 ); } @@ -97,7 +127,64 @@ public static function serializeForRollbar( return $returnVal; } - + + private static function serializeObject( + $obj, + array $customKeys = null, + &$objectHashes = array(), + $maxDepth = -1, + $depth = 0 + ) { + $serialized = null; + + if (self::serializedAlready($obj, $objectHashes)) { + $serialized = self::circularReferenceLabel($obj); + } else { + if ($obj instanceof \Serializable) { + self::markSerialized($obj, $objectHashes); + $serialized = $obj->serialize(); + } else { + $serialized = array( + 'class' => get_class($obj) + ); + + if ($obj instanceof \Iterator) { + $serialized['value'] = 'non-serializable'; + } else { + $serialized['value'] = self::serializeForRollbar( + $obj, + $customKeys, + $objectHashes, + $maxDepth, + $depth+1 + ); + } + } + } + + return $serialized; + } + + private static function serializedAlready($obj, &$objectHashes) + { + if (!isset($objectHashes[spl_object_hash($obj)])) { + return false; + } + + return true; + } + + private static function markSerialized($obj, &$objectHashes) + { + $objectHashes[spl_object_hash($obj)] = true; + self::$ObjectHashes = $objectHashes; + } + + private static function circularReferenceLabel($obj) + { + return ''; + } + // from http://www.php.net/manual/en/function.uniqid.php#94959 public static function uuid4() { diff --git a/vendor/rollbar/rollbar/tests/BodyTest.php b/vendor/rollbar/rollbar/tests/BodyTest.php index 7ddc1203..061bbe30 100644 --- a/vendor/rollbar/rollbar/tests/BodyTest.php +++ b/vendor/rollbar/rollbar/tests/BodyTest.php @@ -15,6 +15,21 @@ public function testBodyValue() $this->assertEquals($mock2, $body->setValue($mock2)->getValue()); } + public function testExtra() + { + $value = m::mock("Rollbar\Payload\ContentInterface") + ->shouldReceive("serialize") + ->andReturn("{CONTENT}") + ->shouldReceive("getKey") + ->andReturn("content_interface") + ->mock(); + $expected = array( + "hello" => "world" + ); + $body = new Body($value, $expected); + $this->assertEquals($body->getExtra(), $expected); + } + public function testSerialize() { $value = m::mock("Rollbar\Payload\ContentInterface") @@ -23,8 +38,11 @@ public function testSerialize() ->shouldReceive("getKey") ->andReturn("content_interface") ->mock(); - $body = new Body($value); + $body = new Body($value, array('foo' => 'bar')); $encoded = json_encode($body->serialize()); - $this->assertEquals("{\"content_interface\":\"{CONTENT}\"}", $encoded); + $this->assertEquals( + "{\"content_interface\":\"{CONTENT}\",\"extra\":{\"foo\":\"bar\"}}", + $encoded + ); } } diff --git a/vendor/rollbar/rollbar/tests/ConfigTest.php b/vendor/rollbar/rollbar/tests/ConfigTest.php index b7da3250..62d34acc 100644 --- a/vendor/rollbar/rollbar/tests/ConfigTest.php +++ b/vendor/rollbar/rollbar/tests/ConfigTest.php @@ -8,6 +8,7 @@ use Rollbar\Payload\Message; use Rollbar\Payload\Payload; use Rollbar\RollbarLogger; +use Rollbar\Defaults; use Rollbar\TestHelpers\Exceptions\SilentExceptionSampleRate; use Rollbar\TestHelpers\Exceptions\FiftyFiftyExceptionSampleRate; @@ -248,19 +249,6 @@ public function testEndpoint() $config->getSender()->getEndpoint() ); } - - public function testVerbosity() - { - $expected = 3; - - $config = new Config(array( - "access_token" => $this->getTestAccessToken(), - "environment" => $this->env, - "verbosity" => $expected - )); - - $this->assertEquals($expected, $config->getVerbosity()); - } public function testCustom() { @@ -287,6 +275,22 @@ public function testCustom() $this->assertEquals("buzz", $custom["fuzz"]); } + public function testMaxItems() + { + $config = new Config(array( + "access_token" => $this->getTestAccessToken() + )); + + $this->assertEquals(Defaults::get()->maxItems(), $config->getMaxItems()); + + $config = new Config(array( + "access_token" => $this->getTestAccessToken(), + "max_items" => Defaults::get()->maxItems()+1 + )); + + $this->assertEquals(Defaults::get()->maxItems()+1, $config->getMaxItems()); + } + public function testCustomDataMethod() { $logger = new RollbarLogger(array( diff --git a/vendor/rollbar/rollbar/tests/CurlSenderTest.php b/vendor/rollbar/rollbar/tests/CurlSenderTest.php index d67f9eb6..4f2e0d0b 100644 --- a/vendor/rollbar/rollbar/tests/CurlSenderTest.php +++ b/vendor/rollbar/rollbar/tests/CurlSenderTest.php @@ -21,7 +21,8 @@ public function testCurlError() $response->getInfo(), array( "Couldn't resolve host 'fake-endpointitem'", // hack for PHP 5.3 - "Could not resolve host: fake-endpointitem" + "Could not resolve host: fake-endpointitem", + "Empty reply from server" ) ) ); diff --git a/vendor/rollbar/rollbar/tests/DataBuilderTest.php b/vendor/rollbar/rollbar/tests/DataBuilderTest.php index 70167176..ae84c6c4 100644 --- a/vendor/rollbar/rollbar/tests/DataBuilderTest.php +++ b/vendor/rollbar/rollbar/tests/DataBuilderTest.php @@ -978,4 +978,29 @@ public function getUserIpProvider() ) ); } + + public function testGitBranch() + { + $config = new Config(array( + 'access_token' => $this->getTestAccessToken(), + 'environment' => 'tests' + )); + + $dataBuilder = $config->getDataBuilder(); + + $val = rtrim(shell_exec('git rev-parse --abbrev-ref HEAD')); + $this->assertEquals($val, $dataBuilder->detectGitBranch()); + } + + public function testGitBranchNoExec() + { + $config = new Config(array( + 'access_token' => $this->getTestAccessToken(), + 'environment' => 'tests' + )); + + $dataBuilder = $config->getDataBuilder(); + + $this->assertEquals(null, $dataBuilder->detectGitBranch(false)); + } } diff --git a/vendor/rollbar/rollbar/tests/DefaultsTest.php b/vendor/rollbar/rollbar/tests/DefaultsTest.php index 2a745dfa..9ba968d2 100644 --- a/vendor/rollbar/rollbar/tests/DefaultsTest.php +++ b/vendor/rollbar/rollbar/tests/DefaultsTest.php @@ -80,21 +80,10 @@ public function testPsrLevels() $this->assertEquals($expected, $this->defaults->psrLevels()); } - public function testGitBranch() - { - $val = rtrim(shell_exec('git rev-parse --abbrev-ref HEAD')); - $this->assertEquals($val, $this->defaults->gitBranch()); - } - - public function testGitBranchExplicit() + public function testBranch() { $val = 'some-branch'; - $this->assertEquals($val, $this->defaults->gitBranch($val)); - } - - public function testGitBranchNoExec() - { - $this->assertEquals(null, $this->defaults->gitBranch(null, false)); + $this->assertEquals($val, $this->defaults->branch($val)); } public function testServerRoot() @@ -258,6 +247,11 @@ public function testCaptureUsername() $this->assertFalse($this->defaults->captureUsername()); } + public function testMaxItems() + { + $this->assertEquals(10, $this->defaults->maxItems()); + } + public function testDefaultsForConfigOptions() { foreach (\Rollbar\Config::listOptions() as $option) { @@ -271,8 +265,6 @@ public function testDefaultsForConfigOptions() continue; } elseif ($option == 'base_api_url') { $option = 'endpoint'; - } elseif ($option == 'branch') { - $option = 'git_branch'; } elseif ($option == 'capture_ip') { $option = 'captureIP'; } elseif ($option == 'root') { diff --git a/vendor/rollbar/rollbar/tests/ErrorWrapperTest.php b/vendor/rollbar/rollbar/tests/ErrorWrapperTest.php index e7d5c77a..ae3dad07 100644 --- a/vendor/rollbar/rollbar/tests/ErrorWrapperTest.php +++ b/vendor/rollbar/rollbar/tests/ErrorWrapperTest.php @@ -27,7 +27,7 @@ public function testGetClassName() null, new Utilities ); - $this->assertEquals("E_ERROR: Message Content", $errWrapper->getClassName()); + $this->assertEquals("E_ERROR", $errWrapper->getClassName()); $errWrapper = new ErrorWrapper( 3, @@ -37,6 +37,6 @@ public function testGetClassName() null, new Utilities ); - $this->assertEquals("#3: Fake Error Number", $errWrapper->getClassName()); + $this->assertEquals("#3", $errWrapper->getClassName()); } } diff --git a/vendor/rollbar/rollbar/tests/MessageTest.php b/vendor/rollbar/rollbar/tests/MessageTest.php index 2ebbe3fb..902904ec 100644 --- a/vendor/rollbar/rollbar/tests/MessageTest.php +++ b/vendor/rollbar/rollbar/tests/MessageTest.php @@ -7,7 +7,7 @@ class MessageTest extends Rollbar\BaseRollbarTest public function testBacktrace() { $expected = array('trace 1' => 'value 1'); - $msg = new Message("Test", array(), $expected); + $msg = new Message("Test", $expected); $this->assertEquals($expected, $msg->getBacktrace()); } @@ -19,31 +19,6 @@ public function testBody() $this->assertEquals("Test2", $msg->setBody("Test2")->getBody()); } - public function testExtra() - { - $msg = new Message("M", array( - "hello" => "world" - )); - $this->assertEquals("world", $msg->hello); - $msg->hello = "Świat"; // Polish for "World" - $this->assertEquals("Świat", $msg->hello); - // Unicode Ś == u015a - $this->assertEquals('{"body":"M","hello":"\u015awiat"}', json_encode($msg->serialize())); - } - - public function testMessageCustom() - { - $msg = new Message("Test"); - $msg->CustomData = "custom data"; - $msg->whatever = 15; - - $this->assertEquals("custom data", $msg->CustomData); - $this->assertEquals(15, $msg->whatever); - - $expected = '{"body":"Test","CustomData":"custom data","whatever":15}'; - $this->assertEquals($expected, json_encode($msg->serialize())); - } - public function testMessageKey() { $msg = new Message("Test"); diff --git a/vendor/rollbar/rollbar/tests/NotifierTest.php b/vendor/rollbar/rollbar/tests/NotifierTest.php index ea5328d5..dacd3695 100644 --- a/vendor/rollbar/rollbar/tests/NotifierTest.php +++ b/vendor/rollbar/rollbar/tests/NotifierTest.php @@ -29,6 +29,6 @@ public function testEncode() { $notifier = Notifier::defaultNotifier(); $encoded = json_encode($notifier->serialize()); - $this->assertEquals('{"name":"rollbar-php","version":"1.6.2"}', $encoded); + $this->assertEquals('{"name":"rollbar-php","version":"1.7.4"}', $encoded); } } diff --git a/vendor/rollbar/rollbar/tests/RollbarLoggerTest.php b/vendor/rollbar/rollbar/tests/RollbarLoggerTest.php index bd252908..d7c2b7d9 100644 --- a/vendor/rollbar/rollbar/tests/RollbarLoggerTest.php +++ b/vendor/rollbar/rollbar/tests/RollbarLoggerTest.php @@ -13,6 +13,11 @@ public function setUp() $_SESSION = array(); } + public function tearDown() + { + Rollbar::destroy(); + } + public function testAddCustom() { $logger = new RollbarLogger(array( @@ -142,8 +147,7 @@ public function testLogMalformedPayloadData() $logger = new RollbarLogger(array( "access_token" => $this->getTestAccessToken(), "environment" => "testing-php", - "transformer" => '\Rollbar\TestHelpers\MalformedPayloadDataTransformer', - "verbosity" => \Psr\Log\LogLevel::DEBUG + "transformer" => '\Rollbar\TestHelpers\MalformedPayloadDataTransformer' )); $response = $logger->log( @@ -155,102 +159,6 @@ public function testLogMalformedPayloadData() $this->assertEquals(400, $response->getStatus()); } - /** - * @dataProvider debugLoggerProvider - */ - public function testDebugLogger($expected, $verbosity) - { - $logger = new RollbarLogger(array( - "access_token" => $this->getTestAccessToken(), - "environment" => "testing-php", - "verbosity" => $verbosity - )); - - @\unlink($logger->getDebugLogFile()); - - $response = $logger->log(Level::WARNING, "Testing PHP Notifier", array()); - - $result = @\file_get_contents($logger->getDebugLogFile()) ?: ""; - - if (isset($expected['regexp'])) { - foreach ($expected['regexp'] as $regexp) { - $this->assertRegExp($regexp, $result); - } - } - - if (isset($expected['notRegExp'])) { - foreach ($expected['notRegExp'] as $regexp) { - $this->assertNotRegExp($regexp, $result); - } - } - - @\unlink($logger->getDebugLogFile()); - } - - public function debugLoggerProvider() - { - return array( - array( - array( - 'notRegExp' => array( - - '/'. - '\[[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*\] '. - 'RollbarDebugLogger.DEBUG:'. - '/', - - '/'. - '\[[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*\] '. - 'RollbarDebugLogger.INFO:'. - '/' - - ) - ), - PsrLogLevel::ERROR // verbosity - ), - array( - array( - 'regexp' => array( - '/'. - '\[[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*\] '. - 'RollbarDebugLogger.INFO: '. - '.*'. - '\[\] \[\]'. - '/' - ), - 'notRegExp' => array( - '/'. - '\[[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*\] '. - 'RollbarDebugLogger.DEBUG:'. - '/' - ) - ), - PsrLogLevel::INFO // verbosity - ), - array( - array( - 'regexp' => array( - - '/'. - '\[[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*\] '. - 'RollbarDebugLogger.INFO: '. - '.*'. - '\[\] \[\]'. - '/', - - '/'. - '\[[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*\] '. - 'RollbarDebugLogger.DEBUG: '. - '.*'. - '\[\] \[\]'. - '/' - ) - ), - PsrLogLevel::DEBUG // verbosity - ) - ); - } - public function testContext() { $l = new RollbarLogger(array( @@ -550,7 +458,7 @@ public function testGetRequestScrubBodyContext($testData) $this->scrubTestAssert( "Request body context", - $result['data']['body']['message']['context1'] + $result['data']['body']['extra']['context1'] ); } @@ -693,4 +601,43 @@ public function testPsr3Debug() // Test that no \Psr\Log\InvalidArgumentException is thrown $l->debug("Testing PHP Notifier"); } + + /** + * @dataProvider maxItemsProvider + */ + public function testMaxItems($maxItemsConfig) + { + $config = array('access_token' => $this->getTestAccessToken()); + if ($maxItemsConfig !== null) { + $config['max_items'] = $maxItemsConfig; + } + + Rollbar::init($config); + $logger = Rollbar::logger(); + + $maxItems = $maxItemsConfig === null ? Defaults::get()->maxItems() : $maxItemsConfig; + + for ($i = 0; $i < $maxItems; $i++) { + $response = $logger->log(Level::INFO, 'testing info level'); + $this->assertEquals(200, $response->getStatus()); + } + + $response = $logger->log(Level::INFO, 'testing info level'); + + $this->assertEquals(0, $response->getStatus()); + $this->assertEquals( + "Maximum number of items per request has been reached. If you " . + "want to report more items, please use `max_items` " . + "configuration option.", + $response->getInfo() + ); + } + + public function maxItemsProvider() + { + return array( + 'use default max_items' => array(null), + 'use provided max_items' => array(3) + ); + } } diff --git a/vendor/rollbar/rollbar/tests/RollbarTest.php b/vendor/rollbar/rollbar/tests/RollbarTest.php index d0040a5c..726c32b4 100644 --- a/vendor/rollbar/rollbar/tests/RollbarTest.php +++ b/vendor/rollbar/rollbar/tests/RollbarTest.php @@ -12,12 +12,10 @@ class RollbarTest extends BaseRollbarTest { - public function __construct() + public function setUp() { self::$simpleConfig['access_token'] = $this->getTestAccessToken(); self::$simpleConfig['environment'] = 'test'; - - parent::__construct(); } private static $simpleConfig = array(); @@ -107,9 +105,11 @@ public function testLogExtraData() ) ); + $extra = $payload->getData()->getBody()->getExtra(); + $this->assertEquals( "some value", - $payload->getData()->getBody()->getValue()->some_key + $extra['some_key'] ); } diff --git a/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheck.php b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheck.php new file mode 100644 index 00000000..38701346 --- /dev/null +++ b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheck.php @@ -0,0 +1,11 @@ +parent = $parent; + } +} diff --git a/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheckSerializable.php b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheckSerializable.php new file mode 100644 index 00000000..d37be843 --- /dev/null +++ b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ChildCycleCheckSerializable.php @@ -0,0 +1,27 @@ +parent = $parent; + } + + public function serialize() + { + $objectHashes = \Rollbar\Utilities::GetObjectHashes(); + return array( + "parent" => \Rollbar\Utilities::serializeForRollbar( + $this->parent, + null, + $objectHashes + ) + ); + } + + public function unserialize($serialized) + { + } +} diff --git a/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheck.php b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheck.php new file mode 100644 index 00000000..edddf9be --- /dev/null +++ b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheck.php @@ -0,0 +1,11 @@ +child = new ChildCycleCheck($this); + } +} diff --git a/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheckSerializable.php b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheckSerializable.php new file mode 100644 index 00000000..233c15db --- /dev/null +++ b/vendor/rollbar/rollbar/tests/TestHelpers/CycleCheck/ParentCycleCheckSerializable.php @@ -0,0 +1,27 @@ +child = new ChildCycleCheck($this); + } + + public function serialize() + { + $objectHashes = \Rollbar\Utilities::GetObjectHashes(); + return array( + "child" => \Rollbar\Utilities::serializeForRollbar( + $this->child, + null, + $objectHashes + ) + ); + } + + public function unserialize($serialized) + { + } +} diff --git a/vendor/rollbar/rollbar/tests/Truncation/StringsStrategyTest.php b/vendor/rollbar/rollbar/tests/Truncation/StringsStrategyTest.php index 3e8ed441..14420e6f 100644 --- a/vendor/rollbar/rollbar/tests/Truncation/StringsStrategyTest.php +++ b/vendor/rollbar/rollbar/tests/Truncation/StringsStrategyTest.php @@ -8,10 +8,8 @@ class StringsStrategyTest extends BaseRollbarTest { - /** - * @dataProvider executeProvider - */ - public function testExecute($data, $expected) + + protected function execute($data) { $config = new Config(array('access_token' => $this->getTestAccessToken())); $truncation = new Truncation($config); @@ -21,12 +19,19 @@ public function testExecute($data, $expected) $data = new EncodedPayload($data); $data->encode(); - $result = $strategy->execute($data); - - $this->assertEquals($expected, $result->data()); + return $strategy->execute($data)->data(); + } + + /** + * @dataProvider executeTruncateNothingProvider + */ + public function testExecuteTruncateNothing($data, $expected) + { + $result = $this->execute($data); + $this->assertEquals($expected, $result); } - public function executeProvider() + public function executeTruncateNothingProvider() { $data = array(); @@ -35,6 +40,31 @@ public function executeProvider() $this->payloadStructureProvider(str_repeat("A", 10)) ); + return $data; + } + + /** + * @dataProvider executeArrayProvider + */ + public function testExecuteArray($data, $expectedThreshold) + { + $result = $this->execute($data); + + $resultAnalysis = array(); + + foreach ($result['data']['body']['message']['body']['value'] as $key => $toTrim) { + $this->assertTrue( + strlen($toTrim) <= $expectedThreshold, + "The string '$toTrim' was expected to be trimmed to " . $expectedThreshold . " characters. " . + "Actual length: " . strlen($toTrim) + ); + } + } + + public function executeArrayProvider() + { + $data = array(); + $thresholds = StringsStrategy::getThresholds(); foreach ($thresholds as $threshold) { $data['truncate strings to ' . $threshold] = $this->thresholdTestProvider($threshold); @@ -45,20 +75,19 @@ public function executeProvider() public function thresholdTestProvider($threshold) { - $stringLengthToTrim = $threshold+1; + $stringLengthToTrim = $threshold*2; $payload = $this->payloadStructureProvider(array()); - $expected = $this->payloadStructureProvider(array()); + $payload['data']['body']['message']['body']['value2'] = array(); - while (strlen(json_encode($payload)) < Truncation::MAX_PAYLOAD_SIZE) { + while (strlen(json_encode($payload)) <= Truncation::MAX_PAYLOAD_SIZE) { $payload['data']['body']['message']['body']['value'] []= str_repeat('A', $stringLengthToTrim); - - $expected['data']['body']['message']['body']['value'] []= - str_repeat('A', $threshold); + $payload['data']['body']['message']['body']['value2'] []= + str_repeat('A', $stringLengthToTrim); } - return array($payload,$expected); + return array($payload, $threshold); } public function payloadStructureProvider($message) diff --git a/vendor/rollbar/rollbar/tests/Truncation/TruncationTest.php b/vendor/rollbar/rollbar/tests/Truncation/TruncationTest.php index 581a7efc..9e9f8f3c 100644 --- a/vendor/rollbar/rollbar/tests/Truncation/TruncationTest.php +++ b/vendor/rollbar/rollbar/tests/Truncation/TruncationTest.php @@ -81,7 +81,8 @@ public function truncateProvider() } $data = array_merge( - $stringsTest->executeProvider(), + $stringsTest->executeTruncateNothingProvider(), + $stringsTest->executearrayProvider(), $framesTestData ); diff --git a/vendor/rollbar/rollbar/tests/UtilitiesTest.php b/vendor/rollbar/rollbar/tests/UtilitiesTest.php index c99ecf25..f004ac30 100644 --- a/vendor/rollbar/rollbar/tests/UtilitiesTest.php +++ b/vendor/rollbar/rollbar/tests/UtilitiesTest.php @@ -1,5 +1,10 @@ assertArrayNotHasKey("myNullValue", $result); $this->assertArrayNotHasKey("my_null_value", $result); } + + public function testSerializationCycleChecking() + { + $config = new Config(array("access_token"=>$this->getTestAccessToken())); + $data = $config->getRollbarData(\Rollbar\Payload\Level::WARNING, "String", array(new ParentCycleCheck())); + $payload = new \Rollbar\Payload\Payload($data, $this->getTestAccessToken()); + $obj = array( + "one_two" => array(1, 2), + "payload" => $payload, + "obj" => new ParentCycleCheck(), + "serializedObj" => new ParentCycleCheckSerializable(), + ); + $objectHashes = array(); + + $result = Utilities::serializeForRollbar($obj, null, $objectHashes); + + $this->assertRegExp( + '/assertRegExp( + '/assertRegExp( + '/ array( + 'two' => array( + 'three' => array( + 'four' => array(1, 2), + ), + ), + ), + ); + + $objectHashes = array(); + $result = Utilities::serializeForRollbar($obj, null, $objectHashes, 2); + $this->assertArrayHasKey('one', $result); + $this->assertArrayHasKey('two', $result['one']); + $this->assertArrayNotHasKey('three', $result['one']['two']); + + $objectHashes = array(); + $result = Utilities::serializeForRollbar($obj, null, $objectHashes, 3); + $this->assertArrayHasKey('one', $result); + $this->assertArrayHasKey('two', $result['one']); + $this->assertArrayHasKey('three', $result['one']['two']); + $this->assertArrayNotHasKey('four', $result['one']['two']['three']); + + $result = Utilities::serializeForRollbar($obj); + $this->assertArrayHasKey('one', $result); + $this->assertArrayHasKey('two', $result['one']); + $this->assertArrayHasKey('three', $result['one']['two']); + $this->assertArrayHasKey('four', $result['one']['two']['three']); + } } diff --git a/vendor/symfony/yaml/Inline.php b/vendor/symfony/yaml/Inline.php index 0aa7e9f4..42b6cb10 100644 --- a/vendor/symfony/yaml/Inline.php +++ b/vendor/symfony/yaml/Inline.php @@ -110,35 +110,37 @@ public static function parse($value, $flags = 0, $references = array()) mb_internal_encoding('ASCII'); } - $i = 0; - $tag = self::parseTag($value, $i, $flags); - switch ($value[$i]) { - case '[': - $result = self::parseSequence($value, $flags, $i, $references); - ++$i; - break; - case '{': - $result = self::parseMapping($value, $flags, $i, $references); - ++$i; - break; - default: - $result = self::parseScalar($value, $flags, null, $i, null === $tag, $references); - } + try { + $i = 0; + $tag = self::parseTag($value, $i, $flags); + switch ($value[$i]) { + case '[': + $result = self::parseSequence($value, $flags, $i, $references); + ++$i; + break; + case '{': + $result = self::parseMapping($value, $flags, $i, $references); + ++$i; + break; + default: + $result = self::parseScalar($value, $flags, null, $i, null === $tag, $references); + } - if (null !== $tag) { - return new TaggedValue($tag, $result); - } + if (null !== $tag) { + return new TaggedValue($tag, $result); + } - // some comments are allowed at the end - if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { - throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename); - } + // some comments are allowed at the end + if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { + throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename); + } - if (isset($mbEncoding)) { - mb_internal_encoding($mbEncoding); + return $result; + } finally { + if (isset($mbEncoding)) { + mb_internal_encoding($mbEncoding); + } } - - return $result; } /** @@ -325,7 +327,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i if (null !== $delimiters) { $tmp = ltrim(substr($scalar, $i), ' '); if ('' === $tmp) { - throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode($delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); + throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode('', $delimiters)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); } if (!\in_array($tmp[0], $delimiters)) { throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename); @@ -788,7 +790,7 @@ private static function evaluateScalar($scalar, $flags, $references = array()) * @param int &$i * @param int $flags * - * @return null|string + * @return string|null */ private static function parseTag($value, &$i, $flags) { diff --git a/vendor/symfony/yaml/LICENSE b/vendor/symfony/yaml/LICENSE index 21d7fb9e..a677f437 100644 --- a/vendor/symfony/yaml/LICENSE +++ b/vendor/symfony/yaml/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2018 Fabien Potencier +Copyright (c) 2004-2019 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/yaml/Parser.php b/vendor/symfony/yaml/Parser.php index 284af1f9..8b3b6992 100644 --- a/vendor/symfony/yaml/Parser.php +++ b/vendor/symfony/yaml/Parser.php @@ -35,6 +35,7 @@ class Parser private $refs = array(); private $skippedLineNumbers = array(); private $locallySkippedLineNumbers = array(); + private $refsBeingParsed = array(); public function __construct() { @@ -212,6 +213,7 @@ private function doParse($value, $flags) if (isset($values['value']) && self::preg_match('#^&(?P[^ ]+) *(?P.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; + $this->refsBeingParsed[] = $isRef; $values['value'] = $matches['value']; } @@ -244,6 +246,7 @@ private function doParse($value, $flags) } if ($isRef) { $this->refs[$isRef] = end($data); + array_pop($this->refsBeingParsed); } } elseif ( self::preg_match('#^(?P(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P.+))?$#u', rtrim($this->currentLine), $values) @@ -287,6 +290,10 @@ private function doParse($value, $flags) if (isset($values['value'][0]) && '*' === $values['value'][0]) { $refName = substr(rtrim($values['value']), 1); if (!array_key_exists($refName, $this->refs)) { + if (false !== $pos = array_search($refName, $this->refsBeingParsed, true)) { + throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $refName, $refName), $this->currentLineNb + 1, $this->currentLine, $this->filename); + } + throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename); } @@ -340,6 +347,7 @@ private function doParse($value, $flags) } } elseif ('<<' !== $key && isset($values['value']) && self::preg_match('#^&(?P[^ ]++) *+(?P.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; + $this->refsBeingParsed[] = $isRef; $values['value'] = $matches['value']; } @@ -395,6 +403,7 @@ private function doParse($value, $flags) } if ($isRef) { $this->refs[$isRef] = $data[$key]; + array_pop($this->refsBeingParsed); } } else { // multiple documents are not supported @@ -500,6 +509,7 @@ private function parseBlock($offset, $yaml, $flags) $parser->totalNumberOfLines = $this->totalNumberOfLines; $parser->skippedLineNumbers = $skippedLineNumbers; $parser->refs = &$this->refs; + $parser->refsBeingParsed = $this->refsBeingParsed; return $parser->doParse($yaml, $flags); } @@ -549,11 +559,6 @@ private function getCurrentLineIndentation() private function getNextEmbedBlock($indentation = null, $inSequence = false) { $oldLineIndentation = $this->getCurrentLineIndentation(); - $blockScalarIndentations = array(); - - if ($this->isBlockScalarHeader()) { - $blockScalarIndentations[] = $oldLineIndentation; - } if (!$this->moveToNextLine()) { return; @@ -612,30 +617,9 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem(); - if (empty($blockScalarIndentations) && $this->isBlockScalarHeader()) { - $blockScalarIndentations[] = $this->getCurrentLineIndentation(); - } - - $previousLineIndentation = $this->getCurrentLineIndentation(); - while ($this->moveToNextLine()) { $indent = $this->getCurrentLineIndentation(); - // terminate all block scalars that are more indented than the current line - if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && '' !== trim($this->currentLine)) { - foreach ($blockScalarIndentations as $key => $blockScalarIndentation) { - if ($blockScalarIndentation >= $indent) { - unset($blockScalarIndentations[$key]); - } - } - } - - if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) { - $blockScalarIndentations[] = $indent; - } - - $previousLineIndentation = $indent; - if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) { $this->moveToPreviousLine(); break; @@ -715,6 +699,10 @@ private function parseValue($value, $flags, $context) } if (!array_key_exists($value, $this->refs)) { + if (false !== $pos = array_search($value, $this->refsBeingParsed, true)) { + throw new ParseException(sprintf('Circular reference [%s, %s] detected for reference "%s".', implode(', ', \array_slice($this->refsBeingParsed, $pos)), $value, $value), $this->currentLineNb + 1, $this->currentLine, $this->filename); + } + throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename); } @@ -1054,16 +1042,6 @@ private function isStringUnIndentedCollectionItem() return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- '); } - /** - * Tests whether or not the current line is the header of a block scalar. - * - * @return bool - */ - private function isBlockScalarHeader() - { - return (bool) self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine); - } - /** * A local wrapper for `preg_match` which will throw a ParseException if there * is an internal error in the PCRE engine. diff --git a/vendor/symfony/yaml/Tests/ParserTest.php b/vendor/symfony/yaml/Tests/ParserTest.php index c9aff59f..38ed1b34 100644 --- a/vendor/symfony/yaml/Tests/ParserTest.php +++ b/vendor/symfony/yaml/Tests/ParserTest.php @@ -2099,6 +2099,10 @@ public function testParsingNotReadableFilesThrowsException() $this->markTestSkipped('chmod is not supported on Windows'); } + if (!getenv('USER') || 'root' === getenv('USER')) { + $this->markTestSkipped('This test will fail if run under superuser'); + } + $file = __DIR__.'/Fixtures/not_readable.yml'; chmod($file, 0200); @@ -2173,6 +2177,48 @@ public function testEvalRefException() $this->parser->parse($yaml); } + /** + * @dataProvider circularReferenceProvider + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage Circular reference [foo, bar, foo] detected + */ + public function testDetectCircularReferences($yaml) + { + $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS); + } + + public function circularReferenceProvider() + { + $tests = array(); + + $yaml = << - * $array = Yaml::parseFile('config.yml'); - * print_r($array); - * + * Usage: + * + * $array = Yaml::parseFile('config.yml'); + * print_r($array); * * @param string $filename The path to the YAML file to be parsed * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior diff --git a/vendor/symfony/yaml/phpunit.xml.dist b/vendor/symfony/yaml/phpunit.xml.dist index 7c732f8a..b5d4d914 100644 --- a/vendor/symfony/yaml/phpunit.xml.dist +++ b/vendor/symfony/yaml/phpunit.xml.dist @@ -1,7 +1,7 @@ __toString()); + } + return get_class($value); }