Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,20 @@
<?php namespace RainLab\Debugbar\Classes;

use Illuminate\Contracts\Http\Kernel;
use Barryvdh\Debugbar\ServiceProvider as BaseServiceProvider;

use RainLab\Debugbar\Middleware\InjectDebugbar;

class ServiceProvider extends BaseServiceProvider
{
/**
* Register the Debugbar Middleware
*
* @param string $middleware
*/
protected function registerMiddleware($middleware)
{
$kernel = $this->app[Kernel::class];
$kernel->pushMiddleware(InjectDebugbar::class);
}
}
@@ -19,7 +19,13 @@
}
],
"require": {
"php": ">=7.0.0",
"barryvdh/laravel-debugbar": "~3.0"
},
"extra": {
"laravel": {
"dont-discover": [
"barryvdh/laravel-debugbar"
]
}
}
}
@@ -4,7 +4,7 @@

/*
|--------------------------------------------------------------------------
| Debugbar Settings
| Debugbar Status
|--------------------------------------------------------------------------
|
| Debugbar is enabled by default, when debug is set to true in app.php.
@@ -13,6 +13,34 @@
*/

'enabled' => env('DEBUGBAR_ENABLED', null),

/*
|--------------------------------------------------------------------------
| Allow public access
|--------------------------------------------------------------------------
|
| By default the debugbar requires an authenticated backend user with the
| rainlab.debugbar.access_debugbar permission in order to view the debugbar
|
| Set this to true to bypass that authentication check.
|
| >**NOTE**: There is no way to bypass the permission check that controls
| access to viewing stored requests (rainlab.debugbar.access_stored_requests)
| as that can be abused to takeover accounts and steal sensitive information.
|
*/

'allow_public_access' => false,

/*
|--------------------------------------------------------------------------
| Routes to exclude
|--------------------------------------------------------------------------
|
| Specify the routes that the debugbar is not to be included on
|
*/

'except' => [
'telescope*'
],
@@ -117,13 +145,13 @@
'symfony_request' => true, // Only one can be enabled..
'mail' => true, // Catch mail messages
'laravel' => false, // Laravel version and environment
'events' => false, // All events fired
'events' => true, // All events fired
'default_request' => false, // Regular or special Symfony request logger
'logs' => false, // Add the latest log messages
'files' => false, // Show the included files
'config' => false, // Display config settings
'cache' => false, // Display cache events
'models' => false, // Display models
'models' => true, // Display models
],

/*
@@ -0,0 +1,8 @@
<?php return [
'plugin' => [
'name' => 'Debugbar',
'description' => 'Integrates the PHP Debugbar with October CMS',
'access_debugbar' => 'Access the debugbar',
'access_stored_requests' => 'Access stored requests (dangerous)'
],
];
@@ -0,0 +1,58 @@
<?php namespace RainLab\Debugbar\Middleware;

use Config;
use Request;
use Closure;
use Exception;
use BackendAuth;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Barryvdh\Debugbar\Middleware\InjectDebugbar as BaseMiddleware;

class InjectDebugbar extends BaseMiddleware
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->debugbar->isEnabled() || $this->inExceptArray($request)) {
return $next($request);
}

$this->debugbar->boot();

try {
/** @var \Illuminate\Http\Response $response */
$response = $next($request);
} catch (Exception $e) {
$response = $this->handleException($request, $e);
} catch (Error $error) {
$e = new FatalThrowableError($error);
$response = $this->handleException($request, $e);
}

$user = BackendAuth::getUser();

if (!$user || !$user->hasAccess('rainlab.debugbar.access_stored_requests')) {
// Disable stored requests
// Note: this will completely disable storing requests from any users
// without the required permission. If that functionality is desired again
// in the future then we can look at overriding the OpenHandler controller
$this->debugbar->setStorage(null);
}

// Modify the response to add the Debugbar if allowed
if (
($user && $user->hasAccess('rainlab.debugbar.access_debugbar')) ||
Config::get('rainlab.debugbar::allow_public_access', false)
) {
$this->debugbar->modifyResponse($request, $response);
}

return $response;
}
}
@@ -1,15 +1,16 @@
<?php namespace RainLab\Debugbar\Middleware;

use Request;
use Closure;
use Response;
use Exception;
use Illuminate\Foundation\Application;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Response;
use October\Rain\Exception\ErrorHandler;
use October\Rain\Exception\AjaxException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

class Debugbar implements Middleware
class InterpretsAjaxExceptions
{

/**
* The Laravel Application
*
@@ -39,19 +40,19 @@ public function handle($request, Closure $next)
{
/** @var \Barryvdh\Debugbar\LaravelDebugbar $debugbar */
$debugbar = $this->app['debugbar'];

try {
return $next($request);
} catch (\Exception $ex) {
if (!\Request::ajax()) {
} catch (Exception $ex) {
if (!Request::ajax()) {
throw $ex;
}
$debugbar->addException($ex);
$message = $ex instanceof AjaxException
? $ex->getContents() : \October\Rain\Exception\ErrorHandler::getDetailedMessage($ex);
? $ex->getContents() : ErrorHandler::getDetailedMessage($ex);

return \Response::make($message, $this->getStatusCode($ex), $debugbar->getDataAsHeaders());
return Response::make($message, $this->getStatusCode($ex), $debugbar->getDataAsHeaders());
}

}

/**
@@ -63,15 +64,12 @@ protected function getStatusCode($exception)
{
if ($exception instanceof HttpExceptionInterface) {
$code = $exception->getStatusCode();
}
elseif ($exception instanceof AjaxException) {
} elseif ($exception instanceof AjaxException) {
$code = 406;
}
else {
} else {
$code = 500;
}

return $code;
}

}
@@ -9,4 +9,5 @@
2.0.0: !!! Upgrade for compatibility with Laravel 5.5 (PHP 7+, October 420+)
2.0.1: Add config file to prevent exceptions from being thrown (credit alxy)
3.0.0: Switched vendor to RainLab from Bedard, upgraded for compatibility with Laravel 6.x
3.0.1: Fixed bug that caused 502 errors on AJAX requests
3.0.1: Fixed bug that caused 502 errors on AJAX requests
3.1.0: Important security update and improved styling.