update v1.0.7.9 R.C.

This is a Release Candidate. We are still testing.
This commit is contained in:
Sujit Prasad
2016-08-03 20:04:36 +05:30
parent 8b6b924d09
commit ffa56a43cb
3830 changed files with 181529 additions and 495353 deletions

View File

@@ -1,13 +0,0 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

View File

@@ -1,3 +0,0 @@
example/ export-ignore
tests/ export-ignore
phpunit.xml

View File

@@ -1,4 +0,0 @@
/vendor
/composer.lock
/composer.phar
/.idea

8
vendor/bugsnag/bugsnag/.styleci.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
disabled:
- align_double_arrow
- phpdoc_align
- short_array_syntax
enabled:
- long_array_syntax
- unalign_double_arrow

View File

@@ -1,10 +0,0 @@
sudo: false
language: php
php:
- 7.0
- 5.6
- 5.5
- 5.4
- 5.3
- 5.2
- hhvm

View File

@@ -1,239 +0,0 @@
Changelog
=========
## 2.7.1 (2016-06-02)
### Bug Fixes
* Fix failure to merge array due to type conflicts
[Jesse Collis](https://github.com/jessedc)
[#118](https://github.com/bugsnag/bugsnag-php/pull/118)
## 2.7.0 (2016-03-09)
### Enhancements
* Support `timeout` settings outside of cURL
[Ivan Shalganov](https://github.com/bzick)
[#111](https://github.com/bugsnag/bugsnag-php/pull/111)
* Support PUT request payloads
[forgadenny](https://github.com/forgandenny)
[#83](https://github.com/bugsnag/bugsnag-php/pull/83)
### Bug Fixes
* Remove exception code filtering
[Duncan Hewett](https://github.com/duncanhewett)
[#113](https://github.com/bugsnag/bugsnag-php/pull/113)
2.6.1 (2016-01-28)
-----
### Bug Fixes
* Fixes an error thrown when sending an `Error` instance using PHP 7
[Petr Bugyík](https://github.com/o5)
[#110](https://github.com/bugsnag/bugsnag-php/pull/110)
* Fix error which occurs when `$_SERVER['SERVER_PORT']` is unset
[Michael Curry](https://github.com/michaelcurry)
[#109](https://github.com/bugsnag/bugsnag-php/pull/109)
2.6.0 (2015-12-23)
-----
### Enhancements
* Add support for PHP 7's Throwable
[Chris Stone](https://github.com/cmstone)
[#106](https://github.com/bugsnag/bugsnag-php/pull/106)
* Fix errors which arise from from error payloads not encoded using UTF-8
[GaetanNaulin](https://github.com/GaetanNaulin)
[#104](https://github.com/bugsnag/bugsnag-php/pull/104)
[#105](https://github.com/bugsnag/bugsnag-php/pull/105)
2.5.6
-----
- Added a debug flag to help diagnose notification problems
2.5.5
-----
- Ensure no unnecessary code is executed when errors should be skipped
2.5.4
-----
- Fix HHVM support for release 2.5.3
2.5.3
-----
- Add support for custom curl options
2.5.2
-----
- Add support for setHostname
2.5.1
-----
- Extract file and line numbers better for crashes in eval'd code
2.5.0
-----
- Collect and send snippets of source code to Bugsnag for easier debugging
- Update `setEndpoint` to accept full URLs
- Add support for `Error#setGroupingHash` to customize error grouping in
`setBeforeNotify` functions
2.4.0
-----
- Don't send $_ENV by default
2.3.1
-----
- Warn if neither curl or fopen are available
2.3.0
-----
- Remove cURL requirement, fallback to using fopen() if cURL not available
2.2.10
------
- Remove default for `setProjectRoot` since it was sometimes overzealous
2.2.9
-----
- Fix boolean metadata handling
2.2.8
-----
- Fix various metadata-encoding bugs
2.2.7
-----
- Allow configuration of projectRoot stripping from stacktraces
2.2.6
-----
- Fix calling `mb_detect_encoding` on non-objects
2.2.5
-----
- Remove deprecated "fatal" severity state
2.2.4
-----
- Prepare 'severity' feature for release
2.2.3
-----
- Fix invalid utf-8 errors for people using iso-8859-1 by default.
2.2.2
-----
- Make frames public on the stacktrace.
2.2.1
-----
- Log any curl errors to the command line, increase default timeout to 10s
2.2.0
-----
- Support previous exceptions on PHP >= 5.3.0
- Allow overriding notifier
- Use manual loading in place of custom autoloading
2.1.4
-----
- Make cURL timeout configurable (thanks pauloschilling)
2.1.3
-----
- Fix crash during stacktrace generation that happened when a closure was
the first stackframe.
2.1.2
-----
- Add `ErrorTypes::getLevelsForSeverity` function to fetch an
`error_reporting` bitmask for a particular Bugsnag severity
2.1.1
-----
- Fix crash during stacktrace generation for frameworks that have their own
`shutdown_handler` method (eg. Laravel)
2.1.0
-----
- Add `setAppType` for sending app type (script, request, resque, etc)
- Add `setUser` for sending structured user data
- Automatically send the severity level of each PHP error
- Added ability to chain setters (eg $bugsnag->setUser(...)->setReleaseStage(...))
2.0.4
-----
- Add hostname collection to help with debugging
2.0.3
-----
- Add `setBatchSending` function to disable batch sending of errors at the
end of each request
2.0.2
-----
- Fix bug which caused `setNotifyReleaseStages` being ignored
2.0.1
-----
- Fix minor request meta-data issues introduced in 2.0.0
2.0.0
-----
- Backwards-incompatible rewrite (using non-static access)
- Full suite of tests and Travis CI testing on PHP 5.2+
- Add `setBeforeNotify` functionality to add meta-data or execute code
before each error is sent to Bugsnag
1.0.9
-----
- Add `setAutoNotify` function to allow disabling of automatic error handling
- Fix bug where error reporting level was being ignored for fatal errors
1.0.8
-----
- Added a `setMetaData` function for sending custom data with every error
1.0.7
-----
- Don't default `notifyReleaseStages` to anything to reduce confusion
1.0.6
-----
- Fix PHP 5.2 bug with missing constants
1.0.5
-----
- Protect against missing $_SERVER variables
1.0.4
-----
- Send JSON POST params to Bugsnag if available
- Send HTTP headers to Bugsnag if available
1.0.3
-----
- Remove unnecessary post to Bugsnag when error list is empty
1.0.2
-----
- Fix bug with 'internal' stacktrace lines (missing line/file)
1.0.1
-----
- Renamed default error classes for clarity
- Batch-send errors at the end of each request
- `Bugsnag::errorHandler` now respects PHP's `error_reporting` settings
- Added `setErrorReportingLevel` function to override PHP's error_reporting settings
1.0.0
-----
- First public release

View File

@@ -1,49 +0,0 @@
Contributing
============
- [Fork](https://help.github.com/articles/fork-a-repo) the [notifier on github](https://github.com/bugsnag/bugsnag-laravel)
- Build and test your changes. Run the tests using [phpunit](https://phpunit.de) (vendored to `vendor/bin/phpunit`)
- Commit and push until you are happy with your contribution
- [Make a pull request](https://help.github.com/articles/using-pull-requests)
- Thanks!
Example apps
============
Test the notifier by running the application locally.
[Install composer](http://getcomposer.org/doc/01-basic-usage.md), and then cd into `example/php` and start the server:
composer install
php index.php
Releasing
=========
1. Commit all outstanding changes
2. Bump the version in `src/Bugsnag/Configuration.php`.
3. Update the CHANGELOG.md, and README if appropriate.
4. Build a new phar package
* NB: You may need to set `phar.readonly = Off` in /usr/local/etc/php/5.4/php.ini
* If not located in /usr/local/etc, check /private/etc/php.ini
* If not in /private/etc/php.ini:
```
sudo cp /private/etc/php.ini.default /private/etc/php.ini
```
* Then:
```
composer install
php pharbuilder.php
```
5. Commit, tag push
```
git commit -am v2.x.x
git tag v2.x.x
git push origin master && git push --tags
```
6. Update the setup guides for PHP (and its frameworks) with any new content.

View File

@@ -1,479 +0,0 @@
Bugsnag Notifier for PHP <img src="https://travis-ci.org/bugsnag/bugsnag-php.svg?branch=master" alt="build status" class="build-status">
========================
The Bugsnag Notifier for PHP gives you instant notification of errors and
exceptions in your PHP applications.
[Bugsnag](https://bugsnag.com) captures errors in real-time from your web,
mobile and desktop applications, helping you to understand and resolve them
as fast as possible. [Create a free account](https://bugsnag.com) to start
capturing errors from your applications.
The Bugsnag Notifier for PHP supports PHP 5.2+.
How to Install
--------------
### Using [Composer](http://getcomposer.org/) (Recommended)
1. Install the `bugsnag/bugsnag-php` package:
```shell
$ composer require "bugsnag/bugsnag:2.*"
```
### Using Phar Package
1. Download the latest [bugsnag.phar](https://raw.github.com/bugsnag/bugsnag-php/master/build/bugsnag.phar)
to your PHP project.
2. Require it in your app.
```php
require_once "/path/to/bugsnag.phar";
```
### Manual Installation
1. Download and extract the [latest Bugsnag source code](https://github.com/bugsnag/bugsnag-php/archive/master.zip)
to your PHP project.
2. Require it in your app using the provided autoloader.
```php
require_once "/path/to/Bugsnag/Autoload.php";
```
Configuration
-------------
1. Configure Bugsnag with your API key:
```php
$bugsnag = new Bugsnag_Client('YOUR-API-KEY-HERE');
```
2. Enable automatic error and exception notification by attaching Bugsnag's
error and exception handlers:
```php
set_error_handler(array($bugsnag, 'errorHandler'));
set_exception_handler(array($bugsnag, 'exceptionHandler'));
```
If you app or PHP framework already has error handling functions, you can
also call `$bugsnag->errorHandler` and `$bugsnag->exceptionHandler`
directly from your existing functions, simply pass all parameters through.
Sending Custom Data With Exceptions
-----------------------------------
It is often useful to send additional meta-data about your app, such as
information about the currently logged in user, along with any
error or exceptions, to help debug problems.
Bugsnag supports sending user information, such as the user's name or email
address, by calling the [setUser](#setUser) function.
To send other custom data, you should define a *before-notify* function,
adding an array of "tabs" of custom data to the $metaData parameter.
For an example, see the [setBeforeNotifyFunction](#setbeforenotifyfunction)
documentation below.
Sending Custom Errors or Non-Fatal Exceptions
---------------------------------------------
You can easily tell Bugsnag about non-fatal or caught exceptions by
calling `notifyException`:
```php
$bugsnag->notifyException(new Exception('Something bad happened'));
```
You can also send custom errors to Bugsnag with `notifyError`:
```php
$bugsnag->notifyError('ErrorType', 'Something bad happened here too');
```
Both of these functions can also be passed an optional `$metaData` parameter,
which should take the following format:
```php
$metaData = array(
'account' => array(
'paying' => true,
'name' => 'Acme Co'
)
);
```
### Severity
You can set the severity of an error in Bugsnag by including the severity option as the fourth parameter when
notifying bugsnag of the error,
```php
$bugsnag->notifyError('ErrorType', 'Something bad happened here too', NULL, "error")
```
Valid severities are `error`, `warning` and `info`.
Severity is displayed in the dashboard and can be used to filter the error list.
By default all crashes (or unhandled exceptions) are set to `error` and all
`$bugsnag->notify` calls default to `warning`.
Additional Configuration
------------------------
###setUser
Bugsnag helps you understand how many of your users are affected by each
error, and allows you to search for which errors affect a particular user
using your Bugsnag dashboard. To send useful user-specific information you can
call `setUser`:
```php
$bugsnag->setUser(array(
'name' => 'Leeroy Jenkins',
'email' => 'leeeeroy@jenkins.com'
));
```
The `name`, `email` and `id` fields are searchable, and everything you send in
this array will be displayed on your Bugsnag dashboard.
The `id` field is used also used by Bugsnag to determine the number of
impacted users. By default, we use the IP address of the request as the `id`.
###setReleaseStage
If you would like to distinguish between errors that happen in different
stages of the application release process (development, production, etc)
you can set the `releaseStage` that is reported to Bugsnag.
```php
$bugsnag->setReleaseStage('development');
```
By default this is set to "production".
###setNotifyReleaseStages
By default, we will notify Bugsnag of errors that happen in *any*
`releaseStage` If you would like to change which release stages notify
Bugsnag of errors you can call `setNotifyReleaseStages`:
```php
$bugsnag->setNotifyReleaseStages(array('development', 'production'));
```
###setMetaData
Sets additional meta-data to send with every bugsnag notification,
for example:
```php
$bugsnag->setMetaData(array(
'account' => array(
'paying' => true,
'name' => 'Acme Co'
)
));
```
###setContext
Bugsnag uses the concept of "contexts" to help display and group your
errors. Contexts represent what was happening in your application at the
time an error occurs. By default this will be set to the current request
URL and HTTP method, eg "GET /pages/documentation".
If you would like to set the bugsnag context manually, you can call
`setContext`:
```php
$bugsnag->setContext('Backport Job');
```
###setType
You can set the type of application executing the current code by using
`setType`:
```php
$bugsnag->setType('resque');
```
This is usually used to represent if you are running plain PHP code "php", via
a framework, eg "laravel", or executing through delayed worker code,
eg "resque". By default this is `NULL`.
###setFilters
Sets the strings to filter out from the `metaData` arrays before sending
them to Bugsnag. Use this if you want to ensure you don't send
sensitive data such as passwords, and credit card numbers to our
servers. Any keys which contain these strings will be filtered.
```php
$bugsnag->setFilters(array('password', 'credit_card'));
```
By default, this is set to be `array("password")`.
###setEndpoint
Set the endpoint to send error reports to. By default we'll send reports to
the standard `https://notify.bugsnag.com` endpoint, but you can override this
if you are using [Bugsnag Enterprise](https://bugsnag.com/enterprise), to
point to your own Bugsnag endpoint:
```php
$bugsnag->setEndpoint("http://bugsnag.internal.example.com");
```
###setTimeout
Define a custom timeout in seconds for the connection when notifying bugsnag.com.
```php
$bugsnag->setTimeout(2);
```
By default, this is set to be `2`.
###setBeforeNotifyFunction
Set a custom function to call before notifying Bugsnag of an error.
You can use this to call your own error handling functions, to add custom
tabs of data to each error on your Bugsnag dashboard, or to modify the
stacktrace.
To add custom tabs of meta-data, simply add to the `$metaData` array
that is passed as the first parameter to your function, for example:
```php
$bugsnag->setBeforeNotifyFunction('before_bugsnag_notify');
function before_bugsnag_notify(Bugsnag_Error $error) {
// Do any custom error handling here
// Also add some meta data to each error
$error->setMetaData(array(
"user" => array(
"name" => "James",
"email" => "james@example.com"
)
));
}
```
If Bugsnag is called by a wrapper library, you can remove stack frames from the
back-trace. For example:
```php
function before_bugsnag_notify(Bugsnag_Error $error) {
$firstFrame = $error->stacktrace->frames[0];
if ($firstFrame && $firstFrame['file'] === 'My_Logger.php') {
array_splice($error->stacktrace->frames, 0, 1);
}
}
```
You can also return `FALSE` from your beforeNotifyFunction to stop this error
from being sent to bugsnag.
###setAutoNotify
Controls whether bugsnag should automatically notify about any errors it detects in
the PHP error handlers.
```php
$bugsnag->setAutoNotify(FALSE);
```
By default, this is set to `TRUE`.
###setErrorReportingLevel
Set the levels of PHP errors to report to Bugsnag, by default we'll use
the value of `error_reporting` from your `php.ini` or any value you set
at runtime using the `error_reporting(...)` function.
If you'd like to send different levels of errors to Bugsnag, you can call
`setErrorReportingLevel`:
```php
$bugsnag->setErrorReportingLevel(E_ALL & ~E_NOTICE);
```
See PHP's [error reporting documentation](http://php.net/manual/en/errorfunc.configuration.php#ini.error-reporting)
for allowed values.
<!-- Custom anchor for linking from alerts -->
<div id="set-project-root"></div>
###setProjectRoot
We mark stacktrace lines as in-project if they come from files inside your
`projectRoot`. By default this value is automatically set to be
`$_SERVER['DOCUMENT_ROOT']` but sometimes this can cause problems with
stacktrace highlighting. You can set this manually by calling `setProjectRoot`:
```php
$bugsnag->setProjectRoot('/path/to/your/app');
```
If your app has files in many different locations, you should consider using
[setProjectRootRegex](#setprojectrootregex) instead.
###setProjectRootRegex
If your app has files in many different locations, you can set the a regular
expression for matching filenames in stacktrace lines that are part of your
application:
```php
$bugsnag->setProjectRootRegex('('.preg_quote('/app').'|'.preg_quote('/libs').')');
```
###setProxySettings
> Note: Proxy configuration is only possible if the PHP cURL extension is installed.
If your server is behind a proxy server, you can configure this as well:
```php
$bugsnag->setProxySettings(array(
'host' => 'bugsnag.com',
'port' => 42,
'user' => 'username',
'password' => 'password123'
));
```
Other than the host, none of these settings are mandatory.
###setAppVersion
If you tag your app releases with version numbers, Bugsnag can display these
on your dashboard if you call `setAppVersion`:
```php
$bugsnag->setAppVersion('1.2.3');
```
###setSendEnvironment
Bugsnag can transmit your `$_ENV` environment to help diagnose issues. This can
contain private/sensitive information, so we do not transmit this by default. To
send your environment, you can call `setSendEnvironment`:
```php
$bugsnag->setSendEnvironment(true);
```
###setSendCode
Bugsnag automatically sends a small snippet of the code that crashed to help
you diagnose even faster from within your dashboard. If you don't want to send
this snippet, you can call `setSendCode`:
```php
$bugsnag->setSendCode(false);
```
###setGroupingHash
Sets the grouping hash of the error report. All errors with the same grouping hash are grouped together. This is an advanced usage of the library and mis-using it will cause your errors not to group properly in your dashboard.
```php
$error->setGroupingHash($exception->message . $exception->class);
```
PHP Frameworks
--------------
### Laravel
Check out the [bugsnag-laravel](https://github.com/bugsnag/bugsnag-laravel) plugin.
### WordPress
Check out the [WordPress Error Monitoring by Bugsnag](http://wordpress.org/plugins/bugsnag/) plugin.
### CakePHP
Check out the third-party [Label305/bugsnag-cakephp](https://github.com/Label305/bugsnag-cakephp) plugin.
### Magento
Check out the official [Bugsnag Magento Extension](http://www.magentocommerce.com/magento-connect/bugsnag-notifier.html).
### Symfony2
Check out the third-party [evolution7/Evolution7BugsnagBundle](https://github.com/evolution7/Evolution7BugsnagBundle) or [wrep/bugsnag-php-symfony](https://github.com/wrep/bugsnag-php-symfony) bundles.
### Monolog
Check out the 3rd party log handler for monolog: [meadsteve/MonoSnag/](https://github.com/meadsteve/MonoSnag/)
### Silverstripe
Check out the third-party [evolution7/silverstripe-bugsnag-logger](https://github.com/evolution7/silverstripe-bugsnag-logger) plugin.
### Zend Framework 2
Check out the third-party [nickurt/bugsnag-php](https://github.com/nickurt/zf-bugsnag) plugin.
Building a Phar from Source
---------------------------
- Install the composer dependencies
```shell
$ composer install
```
- Build the phar using `pharbuilder.php`. You may need to set `phar.readonly = Off` in your `php.ini`.
```shell
php pharbuilder.php
```
A new `bugsnag.phar` will be generated in the `build` folder.
Reporting Bugs or Feature Requests
----------------------------------
Please report any bugs or feature requests on the github issues page for this
project here:
<https://github.com/bugsnag/bugsnag-php/issues>
Contributing
------------
- [Fork](https://help.github.com/articles/fork-a-repo) the [notifier on github](https://github.com/bugsnag/bugsnag-php)
- Commit and push until you are happy with your contribution
- Run the tests to make sure they all pass: `composer install && vendor/bin/phpunit`
- [Make a pull request](https://help.github.com/articles/using-pull-requests)
- Thanks!
License
-------
The Bugsnag PHP notifier is free software released under the MIT License.
See [LICENSE.txt](https://github.com/bugsnag/bugsnag-php/blob/master/LICENSE.txt) for details.

Binary file not shown.

7
vendor/bugsnag/bugsnag/circle.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
machine:
php:
version: 7.0.4
dependencies:
cache_directories:
- ~/.composer/cache

View File

@@ -10,18 +10,20 @@
"email": "notifiers@bugsnag.com",
"homepage": "https://bugsnag.com"
}],
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8|~5.0"
},
"autoload": {
"psr-0" : {
"Bugsnag_" : "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
}
}
}

View File

@@ -0,0 +1,16 @@
- Install composer
<http://getcomposer.org/doc/01-basic-usage.md>
- Install bugsnag using composer
```shell
composer install
```
- Add your API key to the example script
- Run the example script
```shell
php index.php
```

View File

@@ -0,0 +1,5 @@
{
"require": {
"bugsnag/bugsnag": "^2.7"
}
}

View File

@@ -0,0 +1,6 @@
<?php
require_once '../../build/bugsnag.phar';
$bugsnag = new Bugsnag_Client('YOUR-API-KEY-HERE');
$bugsnag->notifyError('Broken', 'Something broke', array('tab' => array('paying' => true, 'object' => (object) array('key' => 'value'), 'null' => null, 'string' => 'test', 'int' => 4)));

View File

@@ -1,12 +0,0 @@
<?php
function build_phar()
{
$phar = new Phar('build/bugsnag.phar');
$phar->buildFromDirectory(dirname(__FILE__) . '/src','/\.php$/');
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
$phar->setStub($phar->createDefaultStub('Bugsnag/Autoload.php'));
}
build_phar();

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
bootstrap="./src/Bugsnag/Autoload.php">
<testsuites>
<testsuite name="Bugsnag tests">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@@ -1,15 +1,15 @@
<?php
# We used to have an autoloader, but it caused problems in some
# environments. So now we manually load the entire library upfront.
#
# The file is still called Autoload so that existing integration
# instructions continue to work.
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."Client.php";
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."Configuration.php";
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."Diagnostics.php";
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."Error.php";
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."ErrorTypes.php";
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."Notification.php";
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."Request.php";
require_once dirname(__FILE__).DIRECTORY_SEPARATOR."Stacktrace.php";
// We used to have an autoloader, but it caused problems in some
// environments. So now we manually load the entire library upfront.
//
// The file is still called Autoload so that existing integration
// instructions continue to work.
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Client.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Configuration.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Diagnostics.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Error.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'ErrorTypes.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Notification.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Request.php';
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'Stacktrace.php';

View File

@@ -2,15 +2,28 @@
class Bugsnag_Client
{
/**
* The config instance.
*
* @var Bugsnag_Configuration
*/
private $config;
/** @var Bugsnag_Notification|null */
/**
* The notification instance.
*
* @var Bugsnag_Notification|null
*/
private $notification;
/**
* Initialize Bugsnag
* Initialize Bugsnag.
*
* @param string $apiKey your Bugsnag API key
*
* @param String $apiKey your Bugsnag API key
* @throws Exception
*
* @return void
*/
public function __construct($apiKey)
{
@@ -32,9 +45,10 @@ class Bugsnag_Client
}
/**
* Set your release stage, eg "production" or "development"
* Set your release stage, eg "production" or "development".
*
* @param string $releaseStage the app's current release stage
*
* @param String $releaseStage the app's current release stage
* @return $this
*/
public function setReleaseStage($releaseStage)
@@ -45,9 +59,10 @@ class Bugsnag_Client
}
/**
* Set your app's semantic version, eg "1.2.3"
* Set your app's semantic version, eg "1.2.3".
*
* @param string $appVersion the app's version
*
* @param String $appVersion the app's version
* @return $this
*/
public function setAppVersion($appVersion)
@@ -58,9 +73,10 @@ class Bugsnag_Client
}
/**
* Set the host name
* Set the host name.
*
* @param string $hostname the host name
*
* @param String $hostname the host name
* @return $this
*/
public function setHostname($hostname)
@@ -71,10 +87,12 @@ class Bugsnag_Client
}
/**
* Set which release stages should be allowed to notify Bugsnag
* eg array("production", "development")
* Set which release stages should be allowed to notify Bugsnag.
*
* Eg array("production", "development").
*
* @param array $notifyReleaseStages array of release stages to notify for
*
* @param Array $notifyReleaseStages array of release stages to notify for
* @return $this
*/
public function setNotifyReleaseStages(array $notifyReleaseStages)
@@ -87,7 +105,8 @@ class Bugsnag_Client
/**
* Set which Bugsnag endpoint to send errors to.
*
* @param String $endpoint endpoint URL
* @param string $endpoint endpoint URL
*
* @return $this
*/
public function setEndpoint($endpoint)
@@ -100,7 +119,8 @@ class Bugsnag_Client
/**
* Enable debug mode to help diagnose problems.
*
* @param Boolean $debug whether to enable debug mode
* @param bool $debug whether to enable debug mode
*
* @return $this
*/
public function setDebug($debug)
@@ -111,11 +131,13 @@ class Bugsnag_Client
}
/**
* Set whether or not to use SSL when notifying bugsnag
* Set whether or not to use SSL when notifying bugsnag.
*
* @param bool $useSSL whether to use SSL
*
* @param Boolean $useSSL whether to use SSL
* @deprecated you can now pass full URLs to setEndpoint
* @return $this
*
* @deprecated since version 2.5. Pass full URLs to setEndpoint.
*/
public function setUseSSL($useSSL)
{
@@ -125,9 +147,10 @@ class Bugsnag_Client
}
/**
* Set the desired timeout for cURL connection when notifying bugsnag
* Set the desired timeout for cURL connection when notifying bugsnag.
*
* @param int $timeout the desired timeout in seconds
*
* @param Integer $timeout the desired timeout in seconds
* @return $this
*/
public function setTimeout($timeout)
@@ -139,10 +162,12 @@ class Bugsnag_Client
/**
* Set the absolute path to the root of your application.
*
* We use this to help with error grouping and to highlight "in project"
* stacktrace lines.
*
* @param String $projectRoot the root path for your application
* @param string $projectRoot the root path for your application
*
* @return $this
*/
public function setProjectRoot($projectRoot)
@@ -153,11 +178,14 @@ class Bugsnag_Client
}
/**
* Set the path that should be stripped from the beginning of
* any stacktrace file line. This helps to normalise filenames
* for grouping and reduces the noise in stack traces.
* Set the absolute split path.
*
* This is the path that should be stripped from the beginning of any
* stacktrace file line. This helps to normalise filenames for grouping
* and reduces the noise in stack traces.
*
* @param string $stripPath the path to strip from filenames
*
* @param String $stripPath the path to strip from filenames
* @return $this
*/
public function setStripPath($stripPath)
@@ -168,10 +196,10 @@ class Bugsnag_Client
}
/**
* Set the a regular expression for matching filenames in stacktrace lines
* that are part of your application.
* Set the a regular expression for matching filenames in stacktrace lines.
*
* @param string $projectRootRegex regex matching paths belong to your project
*
* @param String $projectRootRegex regex matching paths belong to your project
* @return $this
*/
public function setProjectRootRegex($projectRootRegex)
@@ -182,10 +210,12 @@ class Bugsnag_Client
}
/**
* Set the strings to filter out from metaData arrays before sending then
* to Bugsnag. Eg. array("password", "credit_card")
* Set the strings to filter out from metaData arrays before sending then.
*
* Eg. array("password", "credit_card").
*
* @param array $filters an array of metaData filters
*
* @param Array $filters an array of metaData filters
* @return $this
*/
public function setFilters(array $filters)
@@ -196,14 +226,14 @@ class Bugsnag_Client
}
/**
* Set information about the current user of your app, including
* id, name and email.
* Set information about the current user of your app, including id, name and email.
*
* @param Array $user an array of user information. Eg:
* @param array $user an array of user information. Eg:
* array(
* 'name' => 'Bob Hoskins',
* 'email' => 'bob@hoskins.com'
* )
*
* @return $this
*/
public function setUser(array $user)
@@ -214,9 +244,11 @@ class Bugsnag_Client
}
/**
* @deprecated deprecated since version 2.1
* @param $userId
*
* @return $this
*
* @deprecated since version 2.1. Use setUser instead.
*/
public function setUserId($userId)
{
@@ -232,7 +264,8 @@ class Bugsnag_Client
/**
* Set a context representing the current type of request, or location in code.
*
* @param String $context the current context
* @param string $context the current context
*
* @return $this
*/
public function setContext($context)
@@ -243,11 +276,14 @@ class Bugsnag_Client
}
/**
* Set the type of application executing the code. This is usually used to
* represent if you are running plain PHP code "php", via a framework,
* eg "laravel", or executing through delayed worker code, eg "resque".
* Set the type of application executing the code.
*
* This is usually used to represent if you are running plain PHP code
* "php", via a framework, eg "laravel", or executing through delayed
* worker code, eg "resque".
*
* @param string $type the current type
*
* @param String $type the current type
* @return $this
*/
public function setType($type)
@@ -258,35 +294,44 @@ class Bugsnag_Client
}
/**
* Set custom metadata to send to Bugsnag with every error. You can use
* this to add custom tabs of data to each error on your Bugsnag dashboard
* Set custom metadata to send to Bugsnag with every error.
*
* @param Array $metaData an array of arrays of custom data. Eg:
* You can use this to add custom tabs of data to each error on your
* Bugsnag dashboard.
*
* @param array $metaData an array of arrays of custom data. Eg:
* array(
* "user" => array(
* "name" => "James",
* "email" => "james@example.com"
* )
* )
* @param bool $merge optionally merge the meta data
*
* @return $this
*/
public function setMetaData(array $metaData)
public function setMetaData(array $metaData, $merge = false)
{
$this->config->metaData = $metaData;
if ($merge) {
$this->config->metaData = array_merge_recursive((array) $this->config->metaData, $metaData);
} else {
$this->config->metaData = $metaData;
}
return $this;
}
/**
* Set proxy configuration
* Set proxy configuration.
*
* @param Array $proxySettings an array with proxy settings. Eg:
* @param array $proxySettings an array with proxy settings. Eg:
* array(
* 'host' => "bugsnag.com",
* 'port' => 42,
* 'user' => "username"
* 'password' => "password123"
* )
* )
*
* @return $this
*/
public function setProxySettings(array $proxySettings)
@@ -297,12 +342,13 @@ class Bugsnag_Client
}
/**
* Set custom curl options
* Set custom curl options.
*
* @param Array $curlOptions an array with curl options. Eg:
* @param array $curlOptions an array with curl options. Eg:
* array(
* CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4
* )
* )
*
* @return $this
*/
public function setCurlOptions(array $curlOptions)
@@ -314,6 +360,7 @@ class Bugsnag_Client
/**
* Set a custom function to call before notifying Bugsnag of an error.
*
* You can use this to call your own error handling functions, or to add
* custom tabs of data to each error on your Bugsnag dashboard.
*
@@ -326,7 +373,9 @@ class Bugsnag_Client
* ));
* }
* $bugsnag->setBeforeNotifyFunction("before_bugsnag_notify");
*
* @param callable $beforeNotifyFunction
*
* @return $this
*/
public function setBeforeNotifyFunction($beforeNotifyFunction)
@@ -338,11 +387,13 @@ class Bugsnag_Client
/**
* Set Bugsnag's error reporting level.
*
* If this is not set, we'll use your current PHP error_reporting value
* from your ini file or error_reporting(...) calls.
*
* @param Integer $errorReportingLevel the error reporting level integer
* @param int $errorReportingLevel the error reporting level integer
* exactly as you would pass to PHP's error_reporting
*
* @return $this
*/
public function setErrorReportingLevel($errorReportingLevel)
@@ -353,10 +404,10 @@ class Bugsnag_Client
}
/**
* Sets whether Bugsnag should be automatically notified of unhandled
* exceptions and errors.
* Sets whether Bugsnag should be automatically notified of unhandled exceptions and errors.
*
* @param bool $autoNotify whether to auto notify or not
*
* @param Boolean $autoNotify whether to auto notify or not
* @return $this
*/
public function setAutoNotify($autoNotify)
@@ -367,10 +418,10 @@ class Bugsnag_Client
}
/**
* Sets whether errors should be batched together and send at the end of
* each request.
* Sets whether errors should be batched together and send at the end of each request.
*
* @param bool $batchSending whether to batch together errors
*
* @param Boolean $batchSending whether to batch together errors
* @return $this
*/
public function setBatchSending($batchSending)
@@ -381,10 +432,12 @@ class Bugsnag_Client
}
/**
* Sets the notifier to report as to Bugsnag. This should only be
* set by other notifier libraries.
* Sets the notifier to report as to Bugsnag.
*
* This should only be set by other notifier libraries.
*
* @param array $notifier an array of name, version, url.
*
* @param Array $notifier an array of name, version, url.
* @return $this
*/
public function setNotifier($notifier)
@@ -397,7 +450,8 @@ class Bugsnag_Client
/**
* Sets whether Bugsnag should send $_ENV with each error.
*
* @param Boolean $sendEnvironment whether to send the environment
* @param bool $sendEnvironment whether to send the environment
*
* @return $this
*/
public function setSendEnvironment($sendEnvironment)
@@ -410,7 +464,8 @@ class Bugsnag_Client
/**
* Sets whether Bugsnag should send $_COOKIE with each error.
*
* @param Boolean $sendCookies whether to send the environment
* @param bool $sendCookies whether to send the environment
*
* @return $this
*/
public function setSendCookies($sendCookies)
@@ -423,7 +478,8 @@ class Bugsnag_Client
/**
* Sets whether Bugsnag should send $_SESSION with each error.
*
* @param Boolean $sendSession whether to send the environment
* @param bool $sendSession whether to send the environment
*
* @return $this
*/
public function setSendSession($sendSession)
@@ -434,10 +490,12 @@ class Bugsnag_Client
}
/**
* Should we send a small snippet of the code that crashed to help you
* diagnose even faster from within your dashboard.
* Should we send a small snippet of the code that crashed.
*
* This can help you diagnose even faster from within your dashboard.
*
* @param bool $sendCode whether to send code to Bugsnag
*
* @param Boolean $sendCode whether to send code to Bugsnag
* @return $this
*/
public function setSendCode($sendCode)
@@ -448,11 +506,13 @@ class Bugsnag_Client
}
/**
* Notify Bugsnag of a non-fatal/handled throwable
* Notify Bugsnag of a non-fatal/handled throwable.
*
* @param Throwable $throwable the throwable to notify Bugsnag about
* @param Array $metaData optional metaData to send with this error
* @param String $severity optional severity of this error (fatal/error/warning/info)
* @param array $metaData optional metaData to send with this error
* @param string $severity optional severity of this error (fatal/error/warning/info)
*
* @return void
*/
public function notifyException($throwable, array $metaData = null, $severity = null)
{
@@ -465,12 +525,14 @@ class Bugsnag_Client
}
/**
* Notify Bugsnag of a non-fatal/handled error
* Notify Bugsnag of a non-fatal/handled error.
*
* @param String $name the name of the error, a short (1 word) string
* @param String $message the error message
* @param Array $metaData optional metaData to send with this error
* @param String $severity optional severity of this error (fatal/error/warning/info)
* @param string $name the name of the error, a short (1 word) string
* @param string $message the error message
* @param array $metaData optional metaData to send with this error
* @param string $severity optional severity of this error (fatal/error/warning/info)
*
* @return void
*/
public function notifyError($name, $message, array $metaData = null, $severity = null)
{
@@ -480,22 +542,41 @@ class Bugsnag_Client
$this->notify($error, $metaData);
}
// Exception handler callback, should only be called internally by PHP's set_exception_handler
/**
* Exception handler callback.
*
* Should only be called internally by PHP's set_exception_handler.
*
* @param Throwable $throwable the exception was was thrown
*
* @return void
*/
public function exceptionHandler($throwable)
{
if(!$this->config->autoNotify) {
if (!$this->config->autoNotify) {
return;
}
$error = Bugsnag_Error::fromPHPThrowable($this->config, $this->diagnostics, $throwable);
$error->setSeverity("error");
$error->setSeverity('error');
$this->notify($error);
}
// Exception handler callback, should only be called internally by PHP's set_error_handler
/**
* Error handler callback.
*
* Should only be called internally by PHP's set_error_handler.
*
* @param int $errno the level of the error raised
* @param string $errstr the error message
* @param string $errfile the filename that the error was raised in
* @param int $errline the line number the error was raised at
*
* @return void
*/
public function errorHandler($errno, $errstr, $errfile = '', $errline = 0)
{
if(!$this->config->autoNotify || $this->config->shouldIgnoreErrorCode($errno)) {
if (!$this->config->autoNotify || $this->config->shouldIgnoreErrorCode($errno)) {
return;
}
@@ -503,8 +584,19 @@ class Bugsnag_Client
$this->notify($error);
}
// Shutdown handler callback, called when the PHP process has finished running
// Should only be called internally by PHP's register_shutdown_function
/**
* Shutdown handler callback.
*
* Called when the PHP process has finished running. Should only be called
* internally by PHP's register_shutdown_function.
*
* @param int $errno the level of the error raised
* @param string $errstr the error message
* @param string $errfile the filename that the error was raised in
* @param int $errline the line number the error was raised at
*
* @return void
*/
public function shutdownHandler()
{
// Get last error
@@ -513,7 +605,7 @@ class Bugsnag_Client
// Check if a fatal error caused this shutdown
if (!is_null($lastError) && Bugsnag_ErrorTypes::isFatal($lastError['type']) && $this->config->autoNotify && !$this->config->shouldIgnoreErrorCode($lastError['type'])) {
$error = Bugsnag_Error::fromPHPError($this->config, $this->diagnostics, $lastError['type'], $lastError['message'], $lastError['file'], $lastError['line'], true);
$error->setSeverity("error");
$error->setSeverity('error');
$this->notify($error);
}
@@ -525,10 +617,12 @@ class Bugsnag_Client
}
/**
* Batches up errors into notifications for later sending
* Batches up errors into notifications for later sending.
*
* @param Bugsnag_Error $error the error to batch up
* @param array $metaData optional meta data to send with the error
*
* @return void
*/
public function notify(Bugsnag_Error $error, $metaData = array())
{
@@ -549,7 +643,11 @@ class Bugsnag_Client
}
}
// Should we send errors immediately or on shutdown
/**
* Should we send errors immediately, or on shutdown?
*
* @return bool
*/
private function sendErrorsOnShutdown()
{
return $this->config->batchSending && Bugsnag_Request::isRequest();

View File

@@ -17,9 +17,9 @@ class Bugsnag_Configuration
public $projectRootRegex;
public $proxySettings = array();
public $notifier = array(
'name' => 'Bugsnag PHP (Official)',
'version' => '2.7.1',
'url' => 'https://bugsnag.com',
'name' => 'Bugsnag PHP (Official)',
'version' => '2.8.0',
'url' => 'https://bugsnag.com',
);
public $sendEnvironment = false;
public $sendCookies = true;
@@ -45,17 +45,17 @@ class Bugsnag_Configuration
public function __construct()
{
$this->timeout = Bugsnag_Configuration::$DEFAULT_TIMEOUT;
$this->timeout = self::$DEFAULT_TIMEOUT;
}
public function getNotifyEndpoint()
{
if (is_null($this->endpoint)) {
return $this->useSSL ? Bugsnag_Configuration::$DEFAULT_ENDPOINT : Bugsnag_Configuration::$DEFAULT_NON_SSL_ENDPOINT;
return $this->useSSL ? self::$DEFAULT_ENDPOINT : self::$DEFAULT_NON_SSL_ENDPOINT;
} elseif (preg_match('/^(http:\/\/|https:\/\/)/', $this->endpoint)) {
return $this->endpoint;
} else {
return ($this->useSSL ? "https" : "http")."://".$this->endpoint;
return ($this->useSSL ? 'https' : 'http').'://'.$this->endpoint;
}
}
@@ -76,7 +76,7 @@ class Bugsnag_Configuration
public function setProjectRoot($projectRoot)
{
$this->projectRoot = $projectRoot;
$this->projectRootRegex = '/'.preg_quote($projectRoot, '/')."[\\/]?/i";
$this->projectRootRegex = '/'.preg_quote($projectRoot, '/').'[\\/]?/i';
if (is_null($this->stripPath)) {
$this->setStripPath($projectRoot);
}
@@ -85,7 +85,7 @@ class Bugsnag_Configuration
public function setStripPath($stripPath)
{
$this->stripPath = $stripPath;
$this->stripPathRegex = '/'.preg_quote($stripPath, '/')."[\\/]?/i";
$this->stripPathRegex = '/'.preg_quote($stripPath, '/').'[\\/]?/i';
}
public function get($prop, $default = null)

View File

@@ -31,7 +31,7 @@ class Bugsnag_Diagnostics
public function getDeviceData()
{
return array(
'hostname' => $this->config->get('hostname', php_uname('n')),
'hostname' => $this->config->get('hostname', gethostname()),
);
}

View File

@@ -9,9 +9,9 @@ class Bugsnag_Error
);
public $name;
public $payloadVersion = "2";
public $payloadVersion = '2';
public $message;
public $severity = "warning";
public $severity = 'warning';
/** @var Bugsnag_Stacktrace */
public $stacktrace;
public $metaData = array();
@@ -24,7 +24,7 @@ class Bugsnag_Error
// Static error creation methods, to ensure that Error object is always complete
public static function fromPHPError(Bugsnag_Configuration $config, Bugsnag_Diagnostics $diagnostics, $code, $message, $file, $line, $fatal = false)
{
$error = new Bugsnag_Error($config, $diagnostics);
$error = new self($config, $diagnostics);
$error->setPHPError($code, $message, $file, $line, $fatal);
return $error;
@@ -32,7 +32,7 @@ class Bugsnag_Error
public static function fromPHPThrowable(Bugsnag_Configuration $config, Bugsnag_Diagnostics $diagnostics, $throwable)
{
$error = new Bugsnag_Error($config, $diagnostics);
$error = new self($config, $diagnostics);
$error->setPHPException($throwable);
return $error;
@@ -40,7 +40,7 @@ class Bugsnag_Error
public static function fromNamedError(Bugsnag_Configuration $config, Bugsnag_Diagnostics $diagnostics, $name, $message = null)
{
$error = new Bugsnag_Error($config, $diagnostics);
$error = new self($config, $diagnostics);
$error->setName($name)
->setMessage($message)
->setStacktrace(Bugsnag_Stacktrace::generate($config));
@@ -57,14 +57,24 @@ class Bugsnag_Error
public function setName($name)
{
$this->name = $name;
if (is_scalar($name) || method_exists($name, '__toString')) {
$this->name = (string) $name;
} else {
throw new InvalidArgumentException('Name must be a string.');
}
return $this;
}
public function setMessage($message)
{
$this->message = $message;
if ($message === null) {
$this->message = null;
} elseif (is_scalar($message) || method_exists($message, '__toString')) {
$this->message = (string) $message;
} else {
throw new InvalidArgumentException('Message must be a string.');
}
return $this;
}
@@ -86,7 +96,7 @@ class Bugsnag_Error
public function setSeverity($severity)
{
if (!is_null($severity)) {
if (in_array($severity, Bugsnag_Error::$VALID_SEVERITIES)) {
if (in_array($severity, self::$VALID_SEVERITIES)) {
$this->severity = $severity;
} else {
error_log('Bugsnag Warning: Tried to set error severity to '.$severity.' which is not allowed.');
@@ -99,13 +109,15 @@ class Bugsnag_Error
public function setPHPException($exception)
{
if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
if (!$exception instanceof \Throwable) {
error_log('Bugsnag Warning: Exception must implement interface \Throwable.');
if (!$exception instanceof Throwable) {
error_log('Bugsnag Warning: The exception must implement Throwable.');
return;
}
} else {
if (!$exception instanceof \Exception) {
error_log('Bugsnag Warning: Exception must be instance of \Exception.');
if (!$exception instanceof Exception) {
error_log('Bugsnag Warning: The exception must be an Exception.');
return;
}
}
@@ -155,7 +167,7 @@ class Bugsnag_Error
public function setPrevious($exception)
{
if ($exception) {
$this->previous = Bugsnag_Error::fromPHPThrowable($this->config, $this->diagnostics, $exception);
$this->previous = self::fromPHPThrowable($this->config, $this->diagnostics, $exception);
}
return $this;
@@ -175,7 +187,7 @@ class Bugsnag_Error
);
if (isset($this->groupingHash)) {
$errorArray['groupingHash'] = $this->groupingHash;
$errorArray['groupingHash'] = $this->groupingHash;
}
return $errorArray;
@@ -201,7 +213,7 @@ class Bugsnag_Error
private function cleanupObj($obj, $isMetaData)
{
if (is_null($obj)) {
return null;
return;
}
if (is_array($obj)) {

View File

@@ -91,7 +91,7 @@ class Bugsnag_ErrorTypes
if (array_key_exists($code, self::$ERROR_TYPES)) {
return self::$ERROR_TYPES[$code]['name'];
} else {
return "Unknown";
return 'Unknown';
}
}
@@ -100,14 +100,14 @@ class Bugsnag_ErrorTypes
if (array_key_exists($code, self::$ERROR_TYPES)) {
return self::$ERROR_TYPES[$code]['severity'];
} else {
return "error";
return 'error';
}
}
public static function getLevelsForSeverity($severity)
{
$levels = 0;
foreach (Bugsnag_ErrorTypes::$ERROR_TYPES as $level => $info) {
foreach (self::$ERROR_TYPES as $level => $info) {
if ($info['severity'] == $severity) {
$levels |= $level;
}

View File

@@ -40,7 +40,7 @@ class Bugsnag_Notification
// Add environment meta-data to error
if ($this->config->sendEnvironment && !empty($_ENV)) {
$error->setMetaData(array("Environment" => $_ENV));
$error->setMetaData(array('Environment' => $_ENV));
}
// Add user-specified meta-data to error
@@ -113,7 +113,7 @@ class Bugsnag_Notification
curl_setopt($http, CURLOPT_HEADER, false);
curl_setopt($http, CURLOPT_RETURNTRANSFER, true);
curl_setopt($http, CURLOPT_POST, true);
curl_setopt($http, CURLOPT_HTTPHEADER, array(Bugsnag_Notification::$CONTENT_TYPE_HEADER));
curl_setopt($http, CURLOPT_HTTPHEADER, array(self::$CONTENT_TYPE_HEADER, 'Expect:'));
curl_setopt($http, CURLOPT_POSTFIELDS, $body);
curl_setopt($http, CURLOPT_CONNECTTIMEOUT, $this->config->timeout);
curl_setopt($http, CURLOPT_SSL_VERIFYPEER, false);
@@ -125,7 +125,7 @@ class Bugsnag_Notification
}
if (!empty($this->config->curlOptions)) {
foreach ($this->config->curlOptions as $option => $value) {
foreach ($this->config->curlOptions as $option => $value) {
curl_setopt($http, $option, $value);
}
}
@@ -151,7 +151,7 @@ class Bugsnag_Notification
if ($statusCode > 200) {
error_log('Bugsnag Warning: Couldn\'t notify ('.$responseBody.')');
if($this->config->debug) {
if ($this->config->debug) {
error_log('Bugsnag Debug: Attempted to post to URL - "'.$url.'"');
error_log('Bugsnag Debug: Attempted to post payload - "'.$body.'"');
}
@@ -175,9 +175,9 @@ class Bugsnag_Notification
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => Bugsnag_Notification::$CONTENT_TYPE_HEADER.'\r\n',
'header' => self::$CONTENT_TYPE_HEADER.'\r\n',
'content' => $body,
'timeout' => $this->config->timeout
'timeout' => $this->config->timeout,
),
'ssl' => array(
'verify_peer' => false,

View File

@@ -23,25 +23,21 @@ class Bugsnag_Request
if (!empty($_POST)) {
$requestData['request']['params'] = $_POST;
} else {
if (isset($_SERVER['CONTENT_TYPE']) && stripos($_SERVER['CONTENT_TYPE'], 'application/json') === 0) {
$requestData['request']['params'] = json_decode(file_get_contents('php://input'), true);
}
if (isset($_SERVER['REQUEST_METHOD']) && in_array(strtoupper($_SERVER['REQUEST_METHOD']), $methodsWithPayload)) {
parse_str(file_get_contents('php://input'),$params);
if (isset($requestData['request']['params']) && is_array($requestData['request']['params']))
{
$requestData['request']['params'] = array_merge($requestData['request']['params'],$params);
}
else
{
parse_str(file_get_contents('php://input'), $params);
if (isset($requestData['request']['params']) && is_array($requestData['request']['params'])) {
$requestData['request']['params'] = array_merge($requestData['request']['params'], $params);
} else {
$requestData['request']['params'] = $params;
}
}
}
$requestData['request']['ip'] = self::getRequestIp();
$requestData['request']['clientIp'] = self::getRequestIp();
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$requestData['request']['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
}
@@ -56,10 +52,10 @@ class Bugsnag_Request
public static function getContext()
{
if (self::isRequest() && isset($_SERVER['REQUEST_METHOD']) && isset($_SERVER["REQUEST_URI"])) {
return $_SERVER['REQUEST_METHOD'].' '.strtok($_SERVER["REQUEST_URI"], '?');
if (self::isRequest() && isset($_SERVER['REQUEST_METHOD']) && isset($_SERVER['REQUEST_URI'])) {
return $_SERVER['REQUEST_METHOD'].' '.strtok($_SERVER['REQUEST_URI'], '?');
} else {
return null;
return;
}
}
@@ -68,7 +64,7 @@ class Bugsnag_Request
if (self::isRequest()) {
return self::getRequestIp();
} else {
return null;
return;
}
}

View File

@@ -19,20 +19,20 @@ class Bugsnag_Stacktrace
$backtrace = debug_backtrace();
}
return self::fromBacktrace($config, $backtrace, "[generator]", 0);
return self::fromBacktrace($config, $backtrace, '[generator]', 0);
}
public static function fromFrame($config, $file, $line)
{
$stacktrace = new Bugsnag_Stacktrace($config);
$stacktrace->addFrame($file, $line, "[unknown]");
$stacktrace = new self($config);
$stacktrace->addFrame($file, $line, '[unknown]');
return $stacktrace;
}
public static function fromBacktrace($config, $backtrace, $topFile, $topLine)
{
$stacktrace = new Bugsnag_Stacktrace($config);
$stacktrace = new self($config);
// PHP backtrace's are misaligned, we need to shift the file/line down a frame
foreach ($backtrace as $frame) {
@@ -49,7 +49,7 @@ class Bugsnag_Stacktrace
$topFile = $frame['file'];
$topLine = $frame['line'];
} else {
$topFile = "[internal]";
$topFile = '[internal]';
$topLine = 0;
}
}
@@ -86,13 +86,13 @@ class Bugsnag_Stacktrace
// Construct the frame
$frame = array(
'lineNumber' => $line,
'lineNumber' => (int) $line,
'method' => $class ? "$class::$method" : $method,
);
// Attach some lines of code for context
if($this->config->sendCode) {
$frame['code'] = $this->getCode($file, $line, Bugsnag_Stacktrace::$DEFAULT_NUM_LINES);
if ($this->config->sendCode) {
$frame['code'] = $this->getCode($file, $line, self::$DEFAULT_NUM_LINES);
}
// Check if this frame is inProject
@@ -111,7 +111,7 @@ class Bugsnag_Stacktrace
private function getCode($path, $line, $numLines)
{
if (empty($path) || empty($line) || !file_exists($path)) {
return NULL;
return;
}
try {
@@ -133,13 +133,13 @@ class Bugsnag_Stacktrace
$file->seek($start - 1);
while ($file->key() < $end) {
$code[$file->key() + 1] = rtrim(substr($file->current(), 0, Bugsnag_Stacktrace::$MAX_LINE_LENGTH));
$code[$file->key() + 1] = rtrim(substr($file->current(), 0, self::$MAX_LINE_LENGTH));
$file->next();
}
return $code;
} catch (RuntimeException $ex) {
return null;
return;
}
}
}