From 618911a182495e8e39903b4c2a7976c84d1b7bdc Mon Sep 17 00:00:00 2001 From: Pascal Baljet Date: Mon, 7 Dec 2020 11:54:58 +0100 Subject: [PATCH 001/404] Enable PHP 8.0 build (#1129) * WIP * Trigger notification * Update run-integration-tests.yml * Update composer.json * Update run-integration-tests.yml --- .github/workflows/run-integration-tests.yml | 13 ++++++++++--- .github/workflows/run-tests.yml | 4 ++-- composer.json | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 6e626fb24..fb2edd370 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -18,8 +18,15 @@ jobs: COMPOSER_NO_INTERACTION: 1 strategy: matrix: - php: [7.4, 7.3, 7.2] - lumen: [7.*, 6.*] + php: [8.0, 7.4, 7.3, 7.2] + lumen: [8.*, 7.*, 6.*] + exclude: + - lumen: 8.* + php: 7.2 + - lumen: 7.* + php: 8.0 + - lumen: 6.* + php: 8.0 name: P${{ matrix.php }} - Lumen${{ matrix.lumen }} steps: - name: Checkout code @@ -61,7 +68,7 @@ jobs: COMPOSER_NO_INTERACTION: 1 strategy: matrix: - php: [7.4, 7.3, 7.2] + php: [8.0, 7.4, 7.3, 7.2] laravel: [8.*, 7.*, 6.*] exclude: - laravel: 8.* diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a6787b5f5..bf46843bd 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - php: [7.4, 7.3, 7.2] + php: [8.0, 7.4, 7.3, 7.2] laravel: [8.*, 6.*, 7.*] dependency-version: [prefer-lowest, prefer-stable] exclude: @@ -38,7 +38,7 @@ jobs: php-version: ${{ matrix.php }} coverage: none tools: composer:v2 - + - name: Install dependencies run: | composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update diff --git a/composer.json b/composer.json index bb508768e..2c312022e 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "symfony/finder": "^4.3|^5" }, "require-dev": { + "mockery/mockery": "^1.3.3", "orchestra/testbench-dusk": "^4|^5|^6", "phpunit/phpunit": "^8.5|^9.0", "squizlabs/php_codesniffer": "^3.5" From 66ce2a74c97a2ba37e0b8c7bd4963c612734919b Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Mon, 7 Dec 2020 10:56:03 +0000 Subject: [PATCH 002/404] composer fix-style --- src/DataCollector/LogsCollector.php | 4 ++-- src/DataCollector/ViewCollector.php | 2 +- src/ServiceProvider.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DataCollector/LogsCollector.php b/src/DataCollector/LogsCollector.php index 28ed6e14f..ca2b3bcb8 100644 --- a/src/DataCollector/LogsCollector.php +++ b/src/DataCollector/LogsCollector.php @@ -27,12 +27,12 @@ public function getLogsFile() { // default daily rotating logs (Laravel 5.0) $path = storage_path() . '/logs/laravel-' . date('Y-m-d') . '.log'; - + // single file logs if (!file_exists($path)) { $path = storage_path() . '/logs/laravel.log'; } - + return $path; } diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index 46a33166b..7af996665 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -55,7 +55,7 @@ public function addView(View $view) { $name = $view->getName(); $path = $view->getPath(); - + if (!is_object($path)) { if ($path) { $path = ltrim(str_replace(base_path(), '', realpath($path)), '/'); diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 02a5af486..1ebd08229 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -29,7 +29,7 @@ public function register() { $configPath = __DIR__ . '/../config/debugbar.php'; $this->mergeConfigFrom($configPath, 'debugbar'); - + $this->loadRoutesFrom(realpath(__DIR__ . '/debugbar-routes.php')); $this->app->alias( From 759f2df890a2da62440f147bbfc046071842ef27 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 21 Dec 2020 09:30:32 +0100 Subject: [PATCH 003/404] Add extensions to php test (#1139) Add extensions to Github actions --- .github/workflows/run-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bf46843bd..a18e01f92 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -38,6 +38,7 @@ jobs: php-version: ${{ matrix.php }} coverage: none tools: composer:v2 + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif - name: Install dependencies run: | From d6fe211b8f2d36ade3357df2a8576f1ae3103420 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 6 Jan 2021 11:19:00 +0100 Subject: [PATCH 004/404] Add AppStorage driver (#1141) * Add AppStorage driver * Rename storage driver to SocketStorage --- config/debugbar.php | 4 +- src/LaravelDebugbar.php | 6 ++ src/Storage/SocketStorage.php | 100 ++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/Storage/SocketStorage.php diff --git a/config/debugbar.php b/config/debugbar.php index ada83c6d3..37c2f6891 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -34,10 +34,12 @@ */ 'storage' => [ 'enabled' => true, - 'driver' => 'file', // redis, file, pdo, custom + 'driver' => 'file', // redis, file, pdo, socket, custom 'path' => storage_path('debugbar'), // For file driver 'connection' => null, // Leave null for default connection (Redis/PDO) 'provider' => '', // Instance of StorageInterface for custom driver + 'hostname' => '127.0.0.1', // Hostname to use with the "socket" driver + 'port' => 2304, // Port to use with the "socket" driver ], /* diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 79b849431..bb9691a2f 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -15,6 +15,7 @@ use Barryvdh\Debugbar\DataCollector\SessionCollector; use Barryvdh\Debugbar\DataCollector\RequestCollector; use Barryvdh\Debugbar\DataCollector\ViewCollector; +use Barryvdh\Debugbar\Storage\SocketStorage; use Barryvdh\Debugbar\Storage\FilesystemStorage; use DebugBar\Bridge\MonologCollector; use DebugBar\Bridge\SwiftMailer\SwiftLogCollector; @@ -1099,6 +1100,11 @@ protected function selectStorage(DebugBar $debugbar) $class = $config->get('debugbar.storage.provider'); $storage = $this->app->make($class); break; + case 'app': + $hostname = $config->get('debugbar.storage.hostname', '127.0.0.1'); + $port = $config->get('debugbar.storage.port', 2304); + $storage = new SocketStorage($hostname, $port); + break; case 'file': default: $path = $config->get('debugbar.storage.path'); diff --git a/src/Storage/SocketStorage.php b/src/Storage/SocketStorage.php new file mode 100644 index 000000000..04334d0f2 --- /dev/null +++ b/src/Storage/SocketStorage.php @@ -0,0 +1,100 @@ +hostname = $hostname; + $this->port = $port; + } + + /** + * @inheritDoc + */ + function save($id, $data) + { + $socketIsFresh = !$this->socket; + + if (!$this->socket = $this->socket ?: $this->createSocket()) { + return false; + } + + $encodedPayload = json_encode([ + 'id' => $id, + 'base_path' => base_path(), + 'app' => config('app.name'), + 'data' => $data, + ]); + + $encodedPayload = strlen($encodedPayload).'#'.$encodedPayload; + + set_error_handler([self::class, 'nullErrorHandler']); + try { + if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { + return true; + } + if (!$socketIsFresh) { + stream_socket_shutdown($this->socket, \STREAM_SHUT_RDWR); + fclose($this->socket); + $this->socket = $this->createSocket(); + } + if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { + return true; + } + } finally { + restore_error_handler(); + } + } + + private static function nullErrorHandler($t, $m) + { + // no-op + } + + protected function createSocket() + { + set_error_handler([self::class, 'nullErrorHandler']); + try { + return stream_socket_client("tcp://{$this->hostname}:{$this->port}"); + } finally { + restore_error_handler(); + } + } + + /** + * @inheritDoc + */ + function get($id) + { + // + } + + /** + * @inheritDoc + */ + function find(array $filters = array(), $max = 20, $offset = 0) + { + // + } + + /** + * @inheritDoc + */ + function clear() + { + // + } +} \ No newline at end of file From ef326fdd9ea83910b13840b918b69c580f897a61 Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Wed, 6 Jan 2021 10:20:43 +0000 Subject: [PATCH 005/404] composer fix-style --- src/Storage/SocketStorage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Storage/SocketStorage.php b/src/Storage/SocketStorage.php index 04334d0f2..6b242b2f7 100644 --- a/src/Storage/SocketStorage.php +++ b/src/Storage/SocketStorage.php @@ -39,7 +39,7 @@ function save($id, $data) 'data' => $data, ]); - $encodedPayload = strlen($encodedPayload).'#'.$encodedPayload; + $encodedPayload = strlen($encodedPayload) . '#' . $encodedPayload; set_error_handler([self::class, 'nullErrorHandler']); try { @@ -97,4 +97,4 @@ function clear() { // } -} \ No newline at end of file +} From cae0a8d1cb89b0f0522f65e60465e16d738e069b Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 6 Jan 2021 15:21:44 +0100 Subject: [PATCH 006/404] Fix storage name when creating the storage instance (#1143) --- src/LaravelDebugbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index bb9691a2f..eda8c9281 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -1100,7 +1100,7 @@ protected function selectStorage(DebugBar $debugbar) $class = $config->get('debugbar.storage.provider'); $storage = $this->app->make($class); break; - case 'app': + case 'socket': $hostname = $config->get('debugbar.storage.hostname', '127.0.0.1'); $port = $config->get('debugbar.storage.port', 2304); $storage = new SocketStorage($hostname, $port); From bfd60f1262580bdd838160f64c02f93081e5f712 Mon Sep 17 00:00:00 2001 From: Ahmed Mohamed Abd El Ftah Date: Mon, 5 Apr 2021 19:24:22 +0200 Subject: [PATCH 007/404] Laravel Octane Compatibility (#1165) * Add octane compatibility * Modify bindings --- src/ServiceProvider.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 1ebd08229..066031e69 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -37,11 +37,11 @@ public function register() DataFormatterInterface::class ); - $this->app->singleton(LaravelDebugbar::class, function () { - $debugbar = new LaravelDebugbar($this->app); + $this->app->singleton(LaravelDebugbar::class, function ($app) { + $debugbar = new LaravelDebugbar($app); - if ($this->app->bound(SessionManager::class)) { - $sessionManager = $this->app->make(SessionManager::class); + if ($app->bound(SessionManager::class)) { + $sessionManager = $app->make(SessionManager::class); $httpDriver = new SymfonyHttpDriver($sessionManager); $debugbar->setHttpDriver($httpDriver); } From e120edf2b936d3ce8e25d55f9fa12e221109d2ba Mon Sep 17 00:00:00 2001 From: Daniel Alm Date: Mon, 5 Apr 2021 19:44:47 +0200 Subject: [PATCH 008/404] Add a few more secret keys to possibly sanitize. (#1164) --- src/DataCollector/RequestCollector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataCollector/RequestCollector.php b/src/DataCollector/RequestCollector.php index 25760a4e2..cc3fe866f 100644 --- a/src/DataCollector/RequestCollector.php +++ b/src/DataCollector/RequestCollector.php @@ -119,6 +119,7 @@ public function collect() if ( Str::is('*_KEY', $key) || Str::is('*_PASSWORD', $key) || Str::is('*_SECRET', $key) || Str::is('*_PW', $key) + || Str::is('*_TOKEN', $key) || Str::is('*_PASS', $key) ) { $data['request_server'][$key] = '******'; } From 9c5f09bac42e83efc5ccfa4c705b5a184d834ac1 Mon Sep 17 00:00:00 2001 From: Kyrax324 <72662771+Kyrax324@users.noreply.github.com> Date: Tue, 6 Apr 2021 01:45:15 +0800 Subject: [PATCH 009/404] Update debugbar.php (#1160) - allow to set debugbar theme in env --- config/debugbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/debugbar.php b/config/debugbar.php index 37c2f6891..19e2fb0e0 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -214,5 +214,5 @@ | Switches between light and dark theme. If set to auto it will respect system preferences | Possible values: auto, light, dark */ - 'theme' => 'auto', + 'theme' => env('DEBUGBAR_THEME', 'auto'), ]; From a0895370f3655e6a65744d048c40e676be949f10 Mon Sep 17 00:00:00 2001 From: Supian M Date: Tue, 6 Apr 2021 01:47:14 +0800 Subject: [PATCH 010/404] Fix Closure Middleware Can't Converted As String (#1146) --- src/DataCollector/RouteCollector.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/RouteCollector.php b/src/DataCollector/RouteCollector.php index 53c9b673b..9e17b8fb3 100644 --- a/src/DataCollector/RouteCollector.php +++ b/src/DataCollector/RouteCollector.php @@ -2,6 +2,7 @@ namespace Barryvdh\Debugbar\DataCollector; +use Closure; use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; use Illuminate\Http\Request; @@ -95,7 +96,9 @@ protected function getRouteInformation($route) */ protected function getMiddleware($route) { - return implode(', ', $route->middleware()); + return implode(', ', array_map(function ($middleware) { + return $middleware instanceof Closure ? 'Closure' : $middleware; + }, $route->middleware())); } /** From 5b75044d45650843a186b7e733ff037dca9d5f50 Mon Sep 17 00:00:00 2001 From: BinotaLIU Date: Tue, 6 Apr 2021 01:47:44 +0800 Subject: [PATCH 011/404] Exclude higher order proxy by default (#1135) --- src/DataCollector/QueryCollector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 19db0f84e..3e56eff9b 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -21,6 +21,7 @@ class QueryCollector extends PDOCollector protected $showCopyButton = false; protected $reflection = []; protected $backtraceExcludePaths = [ + '/vendor/laravel/framework/src/Illuminate/Support/HigherOrderTapProxy', '/vendor/laravel/framework/src/Illuminate/Database', '/vendor/laravel/framework/src/Illuminate/Events', '/vendor/barryvdh/laravel-debugbar', From b8af309dea71eab3f2c942652969f518130228ee Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 6 Apr 2021 20:11:42 +0200 Subject: [PATCH 012/404] Use request instance --- src/Controllers/OpenHandlerController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index c2e95b300..02cc3c61d 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -4,15 +4,16 @@ use Barryvdh\Debugbar\Support\Clockwork\Converter; use DebugBar\OpenHandler; +use Illuminate\Http\Request; use Illuminate\Http\Response; class OpenHandlerController extends BaseController { - public function handle() + public function handle(Request $request) { $openHandler = new OpenHandler($this->debugbar); - $data = $openHandler->handle(null, false, false); + $data = $openHandler->handle($request->input(), false, false); return new Response( $data, From 6420113d90bb746423fa70b9940e9e7c26ebc121 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 7 Apr 2021 13:19:20 +0200 Subject: [PATCH 013/404] Fix duration for Octane with Swoole Fixes https://github.com/barryvdh/laravel-debugbar/issues/1166 --- src/LaravelDebugbar.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index eda8c9281..79c2541d6 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -147,15 +147,13 @@ public function boot() } if ($this->shouldCollect('time', true)) { - $this->addCollector(new TimeDataCollector()); + $startTime = $app['request']->server('REQUEST_TIME_FLOAT'); + $this->addCollector(new TimeDataCollector($startTime)); - if (! $this->isLumen()) { + if (! $this->isLumen() && $startTime) { $this->app->booted( - function () use ($debugbar) { - $startTime = $this->app['request']->server('REQUEST_TIME_FLOAT'); - if ($startTime) { - $debugbar['time']->addMeasure('Booting', $startTime, microtime(true)); - } + function () use ($debugbar, $startTime) { + $debugbar['time']->addMeasure('Booting', $startTime, microtime(true)); } ); } From 6a4bf30a965447268aa23bc4b2456e021762134a Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 12 May 2021 21:59:24 +0100 Subject: [PATCH 014/404] fix: db collector octane compatibility (#1179) This patch should address #1174, although it does so rather crudely. A better solution might be to re-register the event listeners on each request or re-bind the closures somehow, although I'm interested to hear any feedback on this. --- src/LaravelDebugbar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 79c2541d6..164587d61 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -342,7 +342,7 @@ function ( $db, $queryCollector ) { - if (!$this->shouldCollect('db', true)) { + if (!app(static::class)->shouldCollect('db', true)) { return; // Issue 776 : We've turned off collecting after the listener was attached } // Laravel 5.2 changed the way some core events worked. We must account for @@ -359,7 +359,7 @@ function ( } //allow collecting only queries slower than a specified amount of milliseconds - $threshold = $this->app['config']->get('debugbar.options.db.slow_threshold', false); + $threshold = app('config')->get('debugbar.options.db.slow_threshold', false); if (!$threshold || $time > $threshold) { $queryCollector->addQuery((string)$query, $bindings, $time, $connection); } From 81d3370a7eac3f614a357a87f8f9e7b6e0e61f7f Mon Sep 17 00:00:00 2001 From: Muhittin Tan Date: Thu, 13 May 2021 10:01:12 +0300 Subject: [PATCH 015/404] Remove unnecessary, deprecated defer codes (#1138) Since Laravel 5.8 , deferred providers should implement DeferrableProvider contract instead of using $defer . $defer is deprecated. https://laravel.com/docs/5.8/upgrade#deferred-service-providers Also since this provider is not deferred It is unnecessary to have a provides method Ref : https://laravel.com/docs/8.x/providers#deferred-providers --- src/ServiceProvider.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 066031e69..7f3dd7464 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -13,13 +13,6 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider { - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = false; - /** * Register the service provider. * @@ -119,14 +112,4 @@ protected function registerMiddleware($middleware) $kernel = $this->app[Kernel::class]; $kernel->pushMiddleware($middleware); } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return ['debugbar', 'command.debugbar.clear', DataFormatterInterface::class, LaravelDebugbar::class]; - } } From 455e5f09ade861ec35788174386f8635c583e0ee Mon Sep 17 00:00:00 2001 From: James Anelay Date: Thu, 13 May 2021 08:01:29 +0100 Subject: [PATCH 016/404] Add expanation of how AJAX requests are identified. (#1134) --- config/debugbar.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/debugbar.php b/config/debugbar.php index 19e2fb0e0..dea925c14 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -67,6 +67,9 @@ | you can use this option to disable sending the data through the headers. | | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools. + | + | Note for your request to be identified as ajax requests they must either send the header + | X-Requested-With with the value XMLHttpRequest (most JS libraries send this), or have application/json as a Accept header. */ 'capture_ajax' => true, From 49c1e07a86eaa6c908b787d05bd8cab57ff86bb6 Mon Sep 17 00:00:00 2001 From: Igor Date: Thu, 13 May 2021 09:01:57 +0200 Subject: [PATCH 017/404] Refactor `OpenHandlerController::handle()` (#1120) --- src/Controllers/OpenHandlerController.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index 02cc3c61d..5563c2945 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -15,13 +15,7 @@ public function handle(Request $request) $openHandler = new OpenHandler($this->debugbar); $data = $openHandler->handle($request->input(), false, false); - return new Response( - $data, - 200, - [ - 'Content-Type' => 'application/json' - ] - ); + return response()->json($data); } /** From fb5383132f3775cfcf859e4c77b74427d0158d9b Mon Sep 17 00:00:00 2001 From: Pataar Date: Thu, 13 May 2021 09:04:33 +0200 Subject: [PATCH 018/404] Add debug_backtrace_limit configuration option (#1114) * Add debug_backtrace_limit configuration option * Fix whitespace Co-authored-by: Barry vd. Heuvel --- config/debugbar.php | 10 ++++++++++ src/DataCollector/QueryCollector.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config/debugbar.php b/config/debugbar.php index dea925c14..2ab294b67 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -218,4 +218,14 @@ | Possible values: auto, light, dark */ 'theme' => env('DEBUGBAR_THEME', 'auto'), + + /* + |-------------------------------------------------------------------------- + | Backtrace stack limit + |-------------------------------------------------------------------------- + | + | By default, the DebugBar limits the number of frames returned by the 'debug_backtrace()' function. + | If you need larger stacktraces, you can increase this number. Setting it to 0 will result in no limit. + */ + 'debug_backtrace_limit' => 50, ]; diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 3e56eff9b..0b2e6e64d 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -246,7 +246,7 @@ protected function performQueryAnalysis($query) */ protected function findSource() { - $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT, 50); + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT, app('config')->get('debugbar.debug_backtrace_limit', 50)); $sources = []; From 88fd9cfa144b06b2549e9d487fdaec68265e791e Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 13 May 2021 22:18:35 +0200 Subject: [PATCH 019/404] Revert "Refactor `OpenHandlerController::handle()` (#1120)" (#1183) This reverts commit 49c1e07a86eaa6c908b787d05bd8cab57ff86bb6. --- src/Controllers/OpenHandlerController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index 5563c2945..02cc3c61d 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -15,7 +15,13 @@ public function handle(Request $request) $openHandler = new OpenHandler($this->debugbar); $data = $openHandler->handle($request->input(), false, false); - return response()->json($data); + return new Response( + $data, + 200, + [ + 'Content-Type' => 'application/json' + ] + ); } /** From eb61c2f6c5b61a969e66bc1df36ef5568ecad9a0 Mon Sep 17 00:00:00 2001 From: Denis Chmel Date: Tue, 1 Jun 2021 04:19:47 -0400 Subject: [PATCH 020/404] Queries tab: show duration as a progressbar on a background (#1190) --- src/DataCollector/QueryCollector.php | 15 ++++++++++++++- src/Resources/laravel-debugbar.css | 16 ++++++++++++++++ src/Resources/sqlqueries/widget.js | 8 ++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 0b2e6e64d..2039f987d 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -207,7 +207,7 @@ protected function emulateQuote($value) * @version $Id$ * @access public * @param string $query - * @return string + * @return string[] */ protected function performQueryAnalysis($query) { @@ -492,6 +492,19 @@ public function collect() } } + if ($totalTime > 0) { + // For showing background measure on Queries tab + $start_percent = 0; + foreach ($statements as $i => $statement) { + $width_percent = $statement['duration'] / $totalTime * 100; + $statements[$i] = array_merge($statement, [ + 'start_percent' => round($start_percent, 3), + 'width_percent' => round($width_percent, 3), + ]); + $start_percent += $width_percent; + } + } + $nb_statements = array_filter($queries, function ($query) { return $query['type'] == 'query'; }); diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index db2cc92c2..62170efa3 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -777,3 +777,19 @@ div.phpdebugbar-widgets-sqlqueries span.phpdebugbar-widgets-stmt-id:before, div.phpdebugbar-widgets-templates span.phpdebugbar-widgets-param-count:before { margin-right: 6px!important; } + +.phpdebugbar-widgets-list-item .phpdebugbar-widgets-bg-measure { + position: absolute; + top: 0; + width: 100%; + height: 100%; + overflow: hidden; + pointer-events: none; +} + +.phpdebugbar-widgets-bg-measure .phpdebugbar-widgets-value { + position: absolute; + height: 100%; + opacity: 0.2; + background: red; +} diff --git a/src/Resources/sqlqueries/widget.js b/src/Resources/sqlqueries/widget.js index 189da8cb0..988dc2da9 100644 --- a/src/Resources/sqlqueries/widget.js +++ b/src/Resources/sqlqueries/widget.js @@ -65,6 +65,14 @@ } else { $('').addClass(csscls('sql')).html(PhpDebugBar.Widgets.highlight(stmt.sql, 'sql')).appendTo(li); } + if (stmt.width_percent) { + $('
').addClass(csscls('bg-measure')).append( + $('
').addClass(csscls('value')).css({ + left: stmt.start_percent + '%', + width: Math.max(stmt.width_percent, 0.01) + '%', + }) + ).appendTo(li); + } if (stmt.duration_str) { $('').addClass(csscls('duration')).text(stmt.duration_str).appendTo(li); } From 4c5f34a6f84ffac3f29a7c23c2192a06c0dd785d Mon Sep 17 00:00:00 2001 From: Victor Dauchy <26772554+vdauchy@users.noreply.github.com> Date: Tue, 1 Jun 2021 10:30:18 +0200 Subject: [PATCH 021/404] Add view generation time to timeline tab when 'time' and 'view' collectors are enabled. (#1178) * Add view 'time' when 'time' and 'view' collectors are enabled. * Use Debugbar instance to activate the tracking. * Update debugbar.php * Update ServiceProvider.php Co-authored-by: Barry vd. Heuvel --- config/debugbar.php | 1 + src/DebugbarViewEngine.php | 53 ++++++++++++++++++++++++++++++++++++++ src/ServiceProvider.php | 40 ++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 src/DebugbarViewEngine.php diff --git a/config/debugbar.php b/config/debugbar.php index 2ab294b67..019280127 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -161,6 +161,7 @@ 'full_log' => false, ], 'views' => [ + 'timeline' => false, // Add the views to the timeline (Experimental) 'data' => false, //Note: Can slow down the application, because the data can be quite large.. ], 'route' => [ diff --git a/src/DebugbarViewEngine.php b/src/DebugbarViewEngine.php new file mode 100644 index 000000000..7e8dc7c18 --- /dev/null +++ b/src/DebugbarViewEngine.php @@ -0,0 +1,53 @@ +engine = $engine; + $this->laravelDebugbar = $laravelDebugbar; + } + + /** + * @param string $path + * @param array $data + * @return string + */ + public function get($path, array $data = []) + { + return $this->laravelDebugbar->measure($path, function () use ($path, $data) { + return $this->engine->get($path, $data); + }); + } + + /** + * NOTE: This is done to support other Engine swap (example: Livewire). + * @param $name + * @param $arguments + * @return mixed + */ + public function __call($name, $arguments) + { + return $this->engine->$name(...$arguments); + } +} diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 7f3dd7464..82aed0955 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -7,9 +7,12 @@ use DebugBar\DataFormatter\DataFormatter; use DebugBar\DataFormatter\DataFormatterInterface; use Illuminate\Contracts\Http\Kernel; +use Illuminate\Foundation\Application; use Illuminate\Routing\Router; use Illuminate\Session\SessionManager; use Illuminate\Support\Collection; +use Illuminate\View\Engines\EngineResolver; +use Barryvdh\Debugbar\Facade as DebugBar; class ServiceProvider extends \Illuminate\Support\ServiceProvider { @@ -51,6 +54,43 @@ function ($app) { } ); + $this->app->extend( + 'view.engine.resolver', + function (EngineResolver $resolver, Application $application): EngineResolver { + $laravelDebugbar = $application->make(LaravelDebugbar::class); + + $shouldTrackViewTime = $laravelDebugbar->isEnabled() && + $laravelDebugbar->shouldCollect('time', true) && + $laravelDebugbar->shouldCollect('views', true) && + $application['config']->get('debugbar.options.views.timeline', false); + + if (! $shouldTrackViewTime) { + /* Do not swap the engine to save performance */ + return $resolver; + } + + return new class($resolver, $laravelDebugbar) extends EngineResolver { + + private $laravelDebugbar; + + public function __construct(EngineResolver $resolver, LaravelDebugbar $laravelDebugbar) + { + foreach ($resolver->resolvers as $engine => $resolver) { + $this->register($engine, $resolver); + } + $this->laravelDebugbar = $laravelDebugbar; + } + + public function register($engine, \Closure $resolver) + { + parent::register($engine, function () use ($resolver) { + return new DebugbarViewEngine($resolver(), $this->laravelDebugbar); + }); + } + }; + } + ); + $this->commands(['command.debugbar.clear']); Collection::macro('debug', function () { From fbc8bd2c0ac268cea68aa57355c21d827832657c Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Tue, 1 Jun 2021 08:31:01 +0000 Subject: [PATCH 022/404] composer fix-style --- src/ServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 82aed0955..08e2107c2 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -61,7 +61,7 @@ function (EngineResolver $resolver, Application $application): EngineResolver { $shouldTrackViewTime = $laravelDebugbar->isEnabled() && $laravelDebugbar->shouldCollect('time', true) && - $laravelDebugbar->shouldCollect('views', true) && + $laravelDebugbar->shouldCollect('views', true) && $application['config']->get('debugbar.options.views.timeline', false); if (! $shouldTrackViewTime) { @@ -69,7 +69,7 @@ function (EngineResolver $resolver, Application $application): EngineResolver { return $resolver; } - return new class($resolver, $laravelDebugbar) extends EngineResolver { + return new class ($resolver, $laravelDebugbar) extends EngineResolver { private $laravelDebugbar; From b8914ce1c60117d175242de46758e45f87d68827 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 1 Jun 2021 10:44:22 +0200 Subject: [PATCH 023/404] Shorten path --- src/DebugbarViewEngine.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DebugbarViewEngine.php b/src/DebugbarViewEngine.php index 7e8dc7c18..d808193ae 100644 --- a/src/DebugbarViewEngine.php +++ b/src/DebugbarViewEngine.php @@ -35,7 +35,9 @@ public function __construct(Engine $engine, LaravelDebugbar $laravelDebugbar) */ public function get($path, array $data = []) { - return $this->laravelDebugbar->measure($path, function () use ($path, $data) { + $shortPath = ltrim(str_replace(base_path(), '', realpath($path)), '/'); + + return $this->laravelDebugbar->measure($shortPath, function () use ($path, $data) { return $this->engine->get($path, $data); }); } From bc99f4c52aec0636ecb3aae4576ce84c5773bae2 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 1 Jun 2021 10:46:17 +0200 Subject: [PATCH 024/404] Limit query in timeline to 100 chars --- src/DataCollector/QueryCollector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 2039f987d..cd6a2d9ac 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -4,6 +4,7 @@ use DebugBar\DataCollector\PDO\PDOCollector; use DebugBar\DataCollector\TimeDataCollector; +use Illuminate\Support\Str; /** * Collects data about SQL statements executed with PDO @@ -178,7 +179,7 @@ public function addQuery($query, $bindings, $time, $connection) ]; if ($this->timeCollector !== null) { - $this->timeCollector->addMeasure($query, $startTime, $endTime); + $this->timeCollector->addMeasure(Str::limit($query, 100), $startTime, $endTime); } } From 977670923c57d53e250cfb0eda3c4dbdf6844017 Mon Sep 17 00:00:00 2001 From: Lorenzo Kniss <59545226+lrnz-nabooki@users.noreply.github.com> Date: Wed, 2 Jun 2021 16:40:25 +1000 Subject: [PATCH 025/404] Fix: Skip the loop when the 'duration' key is not set in the '' array. That key is not present when the statement is of type 'explain' (#1192) --- src/DataCollector/QueryCollector.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index cd6a2d9ac..4d2aa6d57 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -481,7 +481,7 @@ public function collect() 'connection' => $query['connection'], ]; - //Add the results from the explain as new rows + // Add the results from the explain as new rows foreach ($query['explain'] as $explain) { $statements[] = [ 'sql' => " - EXPLAIN # {$explain->id}: `{$explain->table}` ({$explain->select_type})", @@ -496,18 +496,26 @@ public function collect() if ($totalTime > 0) { // For showing background measure on Queries tab $start_percent = 0; + foreach ($statements as $i => $statement) { + + if (! isset($statement['duration'])) { + continue; + } + $width_percent = $statement['duration'] / $totalTime * 100; + $statements[$i] = array_merge($statement, [ 'start_percent' => round($start_percent, 3), 'width_percent' => round($width_percent, 3), ]); + $start_percent += $width_percent; } } $nb_statements = array_filter($queries, function ($query) { - return $query['type'] == 'query'; + return $query['type'] === 'query'; }); $data = [ From f6f0f895a33cac801286a74355d146bb5384a5da Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Wed, 2 Jun 2021 06:42:22 +0000 Subject: [PATCH 026/404] composer fix-style --- src/DataCollector/QueryCollector.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 4d2aa6d57..aafc6b4c1 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -498,11 +498,10 @@ public function collect() $start_percent = 0; foreach ($statements as $i => $statement) { - if (! isset($statement['duration'])) { continue; } - + $width_percent = $statement['duration'] / $totalTime * 100; $statements[$i] = array_merge($statement, [ From e207604767a29f0d4d2baeeca75776fd66d208a9 Mon Sep 17 00:00:00 2001 From: Laravel Freelancer NL <36150929+LaravelFreelancerNL@users.noreply.github.com> Date: Sat, 5 Jun 2021 14:08:41 +0200 Subject: [PATCH 027/404] Handle array and object bindings (#1194) * Format array and object bindings to strings * Format Array & Object bindings to string --- src/DataFormatter/QueryFormatter.php | 10 +++++ tests/DataFormatter/QueryFormatterTest.php | 49 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/DataFormatter/QueryFormatterTest.php diff --git a/src/DataFormatter/QueryFormatter.php b/src/DataFormatter/QueryFormatter.php index 8b77c6144..e536f4584 100644 --- a/src/DataFormatter/QueryFormatter.php +++ b/src/DataFormatter/QueryFormatter.php @@ -33,6 +33,16 @@ public function checkBindings($bindings) if (is_string($binding) && !mb_check_encoding($binding, 'UTF-8')) { $binding = '[BINARY DATA]'; } + + if (is_array($binding)) { + $binding = $this->checkBindings($binding); + $binding = '[' . implode(',', $binding) . ']'; + } + + if (is_object($binding)) { + $binding = json_encode($binding); + } + } return $bindings; diff --git a/tests/DataFormatter/QueryFormatterTest.php b/tests/DataFormatter/QueryFormatterTest.php new file mode 100644 index 000000000..2451f78aa --- /dev/null +++ b/tests/DataFormatter/QueryFormatterTest.php @@ -0,0 +1,49 @@ +checkBindings($bindings); + + $this->assertSame($output, ["some string", "[string,Another ' string,[nested,array]]"]); + } + + public function testItFormatsObjectBindings() + { + $object = new \StdClass; + $object->attribute1 = 'test'; + + $bindings = [ + 'some string', + $object + ]; + + $queryFormatter = new QueryFormatter; + + $output = $queryFormatter->checkBindings($bindings); + + $this->assertSame($output, ['some string', '{"attribute1":"test"}']); + } + +} \ No newline at end of file From ee3313c9dc4e2386c3662984913f53d4236d0418 Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Sat, 5 Jun 2021 12:09:56 +0000 Subject: [PATCH 028/404] composer fix-style --- src/DataFormatter/QueryFormatter.php | 1 - tests/DataFormatter/QueryFormatterTest.php | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/DataFormatter/QueryFormatter.php b/src/DataFormatter/QueryFormatter.php index e536f4584..7a94e40f2 100644 --- a/src/DataFormatter/QueryFormatter.php +++ b/src/DataFormatter/QueryFormatter.php @@ -42,7 +42,6 @@ public function checkBindings($bindings) if (is_object($binding)) { $binding = json_encode($binding); } - } return $bindings; diff --git a/tests/DataFormatter/QueryFormatterTest.php b/tests/DataFormatter/QueryFormatterTest.php index 2451f78aa..fbffa0f03 100644 --- a/tests/DataFormatter/QueryFormatterTest.php +++ b/tests/DataFormatter/QueryFormatterTest.php @@ -22,7 +22,7 @@ public function testItFormatsArrayBindings() ], ]; - $queryFormatter = new QueryFormatter; + $queryFormatter = new QueryFormatter(); $output = $queryFormatter->checkBindings($bindings); @@ -31,7 +31,7 @@ public function testItFormatsArrayBindings() public function testItFormatsObjectBindings() { - $object = new \StdClass; + $object = new \StdClass(); $object->attribute1 = 'test'; $bindings = [ @@ -39,11 +39,10 @@ public function testItFormatsObjectBindings() $object ]; - $queryFormatter = new QueryFormatter; + $queryFormatter = new QueryFormatter(); $output = $queryFormatter->checkBindings($bindings); $this->assertSame($output, ['some string', '{"attribute1":"test"}']); } - -} \ No newline at end of file +} From 7904e3b31659ce1cb37bc4a9b0d7b44579456d74 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sat, 12 Jun 2021 10:09:17 +0200 Subject: [PATCH 029/404] Update FUNDING.yml --- .github/FUNDING.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 798753326..41f9ae41c 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,12 +1,5 @@ # These are supported funding model platforms github: barryvdh -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +custom: ['https://fruitcake.nl/'] + From 70b89754913fd89fef16d0170a91dbc2a5cd633a Mon Sep 17 00:00:00 2001 From: Tadhg Boyle Date: Mon, 14 Jun 2021 07:29:26 -0700 Subject: [PATCH 030/404] Add option to toggle query background on/off (#1196) * Add option to toggle query background on/off * provide Application instance to QueryCollector * Implement requested changes --- config/debugbar.php | 1 + src/DataCollector/QueryCollector.php | 39 ++++++++++++++++++---------- src/LaravelDebugbar.php | 2 ++ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/config/debugbar.php b/config/debugbar.php index 019280127..e7f6b0999 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -150,6 +150,7 @@ 'backtrace' => true, // Use a backtrace to find the origin of the query in your files. 'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults) 'timeline' => false, // Add the queries to the timeline + 'duration_background' => true, // Show shaded background on each query relative to how long it took to execute. 'explain' => [ // Show EXPLAIN output on queries 'enabled' => false, 'types' => ['SELECT'], // Deprecated setting, is always only SELECT diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index aafc6b4c1..f75d6ef63 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -16,6 +16,7 @@ class QueryCollector extends PDOCollector protected $renderSqlWithParams = false; protected $findSource = false; protected $middleware = []; + protected $durationBackground = true; protected $explainQuery = false; protected $explainTypes = ['SELECT']; // ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+ protected $showHints = false; @@ -89,6 +90,16 @@ public function mergeBacktraceExcludePaths(array $excludePaths) $this->backtraceExcludePaths = array_merge($this->backtraceExcludePaths, $excludePaths); } + /** + * Enable/disable the shaded duration background on queries + * + * @param bool $enabled + */ + public function setDurationBackground($enabled) + { + $this->durationBackground = $enabled; + } + /** * Enable/disable the EXPLAIN queries * @@ -493,23 +504,25 @@ public function collect() } } - if ($totalTime > 0) { - // For showing background measure on Queries tab - $start_percent = 0; + if ($this->durationBackground) { + if ($totalTime > 0) { + // For showing background measure on Queries tab + $start_percent = 0; - foreach ($statements as $i => $statement) { - if (! isset($statement['duration'])) { - continue; - } + foreach ($statements as $i => $statement) { + if (!isset($statement['duration'])) { + continue; + } - $width_percent = $statement['duration'] / $totalTime * 100; + $width_percent = $statement['duration'] / $totalTime * 100; - $statements[$i] = array_merge($statement, [ - 'start_percent' => round($start_percent, 3), - 'width_percent' => round($width_percent, 3), - ]); + $statements[$i] = array_merge($statement, [ + 'start_percent' => round($start_percent, 3), + 'width_percent' => round($width_percent, 3), + ]); - $start_percent += $width_percent; + $start_percent += $width_percent; + } } } diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 164587d61..4c69f06c2 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -316,6 +316,8 @@ function ($level, $message = null, $context = null) use ($logger) { $queryCollector->mergeBacktraceExcludePaths($excludePaths); } + $queryCollector->setDurationBackground($this->app['config']->get('debugbar.options.db.duration_background')); + if ($this->app['config']->get('debugbar.options.db.explain.enabled')) { $types = $this->app['config']->get('debugbar.options.db.explain.types'); $queryCollector->setExplainSource(true, $types); From 032b5ffa0833473535e3f00c208c071679c01b8b Mon Sep 17 00:00:00 2001 From: Martin Krisell Date: Mon, 21 Jun 2021 09:15:38 +0200 Subject: [PATCH 031/404] Fix binding with dollar not presented correctly in query (#1199) --- src/DataCollector/QueryCollector.php | 2 +- tests/DataCollector/QueryCollectorTest.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index f75d6ef63..898cd0c0c 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -164,7 +164,7 @@ public function addQuery($query, $bindings, $time, $connection) } } - $query = preg_replace($regex, $binding, $query, 1); + $query = preg_replace($regex, addcslashes($binding, '$'), $query, 1); } } diff --git a/tests/DataCollector/QueryCollectorTest.php b/tests/DataCollector/QueryCollectorTest.php index c27dbb338..58ceaabef 100644 --- a/tests/DataCollector/QueryCollectorTest.php +++ b/tests/DataCollector/QueryCollectorTest.php @@ -37,4 +37,25 @@ public function testItReplacesQuestionMarksBindingsCorrectly() }); }); } + + public function testDollarBindingsArePresentedCorrectly() + { + debugbar()->boot(); + + /** @var \Barryvdh\Debugbar\DataCollector\QueryCollector $collector */ + $collector = debugbar()->getCollector('queries'); + $collector->addQuery( + "SELECT a FROM b WHERE c = ? AND d = ? AND e = ?", + ['$10', '$2y$10_DUMMY_BCRYPT_HASH', '$_$$_$$$_$2_$3'], + 0, + $this->app['db']->connection() + ); + + tap(Arr::first($collector->collect()['statements']), function (array $statement) { + $this->assertEquals( + "SELECT a FROM b WHERE c = '$10' AND d = '$2y$10_DUMMY_BCRYPT_HASH' AND e = '\$_$\$_$$\$_$2_$3'", + $statement['sql'] + ); + }); + } } From dc0df2d90ec63921cfa7518a539088dc2d2108d8 Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Mon, 21 Jun 2021 07:19:42 +0000 Subject: [PATCH 032/404] composer fix-style --- tests/DataCollector/QueryCollectorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/DataCollector/QueryCollectorTest.php b/tests/DataCollector/QueryCollectorTest.php index 58ceaabef..878fa20d3 100644 --- a/tests/DataCollector/QueryCollectorTest.php +++ b/tests/DataCollector/QueryCollectorTest.php @@ -53,7 +53,7 @@ public function testDollarBindingsArePresentedCorrectly() tap(Arr::first($collector->collect()['statements']), function (array $statement) { $this->assertEquals( - "SELECT a FROM b WHERE c = '$10' AND d = '$2y$10_DUMMY_BCRYPT_HASH' AND e = '\$_$\$_$$\$_$2_$3'", + "SELECT a FROM b WHERE c = '$10' AND d = '$2y$10_DUMMY_BCRYPT_HASH' AND e = '\$_$\$_$$\$_$2_$3'", $statement['sql'] ); }); From a75a2ee197587071ec40058a295810a0b59cef2b Mon Sep 17 00:00:00 2001 From: Jacob Baker-Kretzmar Date: Mon, 23 Aug 2021 12:07:53 -0400 Subject: [PATCH 033/404] Register Telescope route only if Telescope is installed (#1203) --- src/debugbar-routes.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/debugbar-routes.php b/src/debugbar-routes.php index 663b4ddbc..c8c87301f 100644 --- a/src/debugbar-routes.php +++ b/src/debugbar-routes.php @@ -18,10 +18,12 @@ 'as' => 'debugbar.clockwork', ]); - $router->get('telescope/{id}', [ - 'uses' => 'TelescopeController@show', - 'as' => 'debugbar.telescope', - ]); + if (class_exists(\Laravel\Telescope\Telescope::class)) { + $router->get('telescope/{id}', [ + 'uses' => 'TelescopeController@show', + 'as' => 'debugbar.telescope', + ]); + } $router->get('assets/stylesheets', [ 'uses' => 'AssetController@css', From a552b6892743310fe72be2af65cae9406955efd4 Mon Sep 17 00:00:00 2001 From: Ziding Zhang Date: Mon, 13 Sep 2021 18:44:48 +0100 Subject: [PATCH 034/404] Create SECURITY.md (#1227) A simple instruction for security researchers. Closes #1226 --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..c6138bc29 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report security issues to `barryvdh@gmail.com` From d3ba4f64e5142ced75d0d8262e2454a75257895a Mon Sep 17 00:00:00 2001 From: Henrique Date: Sun, 19 Sep 2021 05:06:07 +0900 Subject: [PATCH 035/404] Add information about Laravel Octane (#1229) Not including the LaravelDebugbar in the "flush" list results in the debugbar displaying data for older requests. (When using the Swoole driver) I have not tested with Roadrunner but it should avoid any eventual problems there as well. --- readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/readme.md b/readme.md index ed4291a9e..ecd61a60b 100644 --- a/readme.md +++ b/readme.md @@ -78,6 +78,16 @@ You can also only display the js or css vendors, by setting it to 'js' or 'css'. php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider" ``` +### Laravel with Octane: + +Make sure to add LaravelDebugbar to your flush list in `config/octane.php`. + +```php + 'flush' => [ + \Barryvdh\Debugbar\LaravelDebugbar::class, + ], +``` + ### Lumen: For Lumen, register a different Provider in `bootstrap/app.php`: From fc69fd6293e4e9d0f0181bb56219e9b3b3c4dd1f Mon Sep 17 00:00:00 2001 From: Julian Hundeloh Date: Wed, 22 Sep 2021 14:28:00 +0200 Subject: [PATCH 036/404] fix: support explain with pgsql (#1207) * fix: support explain with pgsql * fix: record driver in transactions --- src/DataCollector/QueryCollector.php | 31 +++++++++++++++++++++------- src/LaravelDebugbar.php | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 898cd0c0c..c2ee9bffa 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -185,6 +185,7 @@ public function addQuery($query, $bindings, $time, $connection) 'source' => $source, 'explain' => $explainResults, 'connection' => $connection->getDatabaseName(), + 'driver' => $connection->getConfig('driver'), 'hints' => $this->showHints ? $hints : null, 'show_copy' => $this->showCopyButton, ]; @@ -453,6 +454,7 @@ public function collectTransactionEvent($event, $connection) 'source' => $source, 'explain' => [], 'connection' => $connection->getDatabaseName(), + 'driver' => $connection->getConfig('driver'), 'hints' => null, 'show_copy' => false, ]; @@ -493,14 +495,27 @@ public function collect() ]; // Add the results from the explain as new rows - foreach ($query['explain'] as $explain) { - $statements[] = [ - 'sql' => " - EXPLAIN # {$explain->id}: `{$explain->table}` ({$explain->select_type})", - 'type' => 'explain', - 'params' => $explain, - 'row_count' => $explain->rows, - 'stmt_id' => $explain->id, - ]; + if ($query['driver'] === 'pgsql') { + $explainer = trim(implode("\n", array_map(function ($explain) { + return $explain->{'QUERY PLAN'}; + }, $query['explain']))); + + if ($explainer) { + $statements[] = [ + 'sql' => " - EXPLAIN: {$explainer}", + 'type' => 'explain', + ]; + } + } else { + foreach ($query['explain'] as $explain) { + $statements[] = [ + 'sql' => " - EXPLAIN # {$explain->id}: `{$explain->table}` ({$explain->select_type})", + 'type' => 'explain', + 'params' => $explain, + 'row_count' => $explain->rows, + 'stmt_id' => $explain->id, + ]; + } } } diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 4c69f06c2..61e168e7a 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -1137,7 +1137,7 @@ protected function addServerTimingHeaders(Response $response) $headers = []; foreach ($collector->collect()['measures'] as $k => $m) { - $headers[] = sprintf('app;desc="%s";dur=%F', str_replace('"', "'", $m['label']), $m['duration'] * 1000); + $headers[] = sprintf('app;desc="%s";dur=%F', str_replace(array("\n", "\r"), ' ', str_replace('"', "'", $m['label'])), $m['duration'] * 1000); } $response->headers->set('Server-Timing', $headers, false); From 665e514f209eb0e30618d6b25aafc9da38354a64 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 21 Oct 2021 12:56:47 +0200 Subject: [PATCH 037/404] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2c312022e..595a81a75 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "prefer-stable": true, "extra": { "branch-alias": { - "dev-master": "3.5-dev" + "dev-master": "3.6-dev" }, "laravel": { "providers": [ From 3c2d678269ba60e178bcd93e36f6a91c36b727f1 Mon Sep 17 00:00:00 2001 From: Ahmed shamim Date: Thu, 21 Oct 2021 16:57:31 +0600 Subject: [PATCH 038/404] fix: #1236 maximebf/debugbar version issue (#1237) * fix: #1236 maximebf/debugbar version issue * Update composer.json Co-authored-by: Barry vd. Heuvel --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 595a81a75..fff17ea4b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=7.2", - "maximebf/debugbar": "^1.16.3", + "maximebf/debugbar": "^1.17.2", "illuminate/routing": "^6|^7|^8", "illuminate/session": "^6|^7|^8", "illuminate/support": "^6|^7|^8", From eee8bcc68c268b03f89765ccc0d9730a8c997fed Mon Sep 17 00:00:00 2001 From: Henrique Date: Thu, 28 Oct 2021 19:13:40 +0900 Subject: [PATCH 039/404] Avoid passing null to functions as it is deprecated in PHP 8.1 (#1249) https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg --- src/JavascriptRenderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JavascriptRenderer.php b/src/JavascriptRenderer.php index ee30c8e86..56c3a8c02 100644 --- a/src/JavascriptRenderer.php +++ b/src/JavascriptRenderer.php @@ -147,7 +147,7 @@ protected function makeUriRelativeTo($uri, $root) return $uris; } - if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) { + if (substr($uri ?? '', 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri ?? '')) { return $uri; } return rtrim($root, '/') . "/$uri"; From 62b2749a4737e95d0e4f76823348d60881a6ffcc Mon Sep 17 00:00:00 2001 From: Steven Kemp Date: Thu, 4 Nov 2021 08:30:48 -0400 Subject: [PATCH 040/404] Return the result from the callback in `measure` helper (#1251) --- src/helpers.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helpers.php b/src/helpers.php index 0cd00444f..69e6e3e61 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -73,9 +73,10 @@ function add_measure($label, $start, $end) * * @param string $label * @param \Closure $closure + * @return mixed */ function measure($label, \Closure $closure) { - debugbar()->measure($label, $closure); + return debugbar()->measure($label, $closure); } } From 7c05586a546092dc977b7685a0dc5a29ee6c6bee Mon Sep 17 00:00:00 2001 From: Andrew Minion Date: Thu, 4 Nov 2021 07:31:23 -0500 Subject: [PATCH 041/404] Feature/ide links full path (#1224) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use absolute path to file * add the actual change đŸ¤¦ --- src/DataCollector/ViewCollector.php | 2 +- tests/DataCollector/ViewCollectorTest.php | 30 +++++++++++++++++++++++ tests/TestCase.php | 6 +++++ tests/resources/views/dashboard.blade.php | 3 +++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tests/DataCollector/ViewCollectorTest.php create mode 100644 tests/resources/views/dashboard.blade.php diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index 7af996665..7a1b0c577 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -89,7 +89,7 @@ public function addView(View $view) ]; if ($this->getXdebugLink($path)) { - $template['xdebug_link'] = $this->getXdebugLink($path); + $template['xdebug_link'] = $this->getXdebugLink(realpath($view->getPath())); } $this->templates[] = $template; diff --git a/tests/DataCollector/ViewCollectorTest.php b/tests/DataCollector/ViewCollectorTest.php new file mode 100644 index 000000000..c4a98b20e --- /dev/null +++ b/tests/DataCollector/ViewCollectorTest.php @@ -0,0 +1,30 @@ +boot(); + + /** @var \Barryvdh\Debugbar\DataCollector\ViewCollector $collector */ + $collector = debugbar()->getCollector('views'); + $collector->addView( + view('dashboard') + ); + + tap(Arr::first($collector->collect()['templates']), function (array $template) { + $this->assertEquals( + 'vscode://file/'.realpath(__DIR__.'/../resources/views/dashboard.blade.php').':1', + $template['xdebug_link']['url'], + ); + }); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 207bc78f5..00e478eff 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -48,6 +48,7 @@ protected function getEnvironmentSetUp($app) $this->addWebRoutes($router); $this->addApiRoutes($router); + $this->addViewPaths(); } /** @@ -79,4 +80,9 @@ protected function addApiRoutes(Router $router) } ]); } + + protected function addViewPaths() + { + config(['view.paths' => array_merge(config('view.paths'), [__DIR__.'/resources/views'])]); + } } diff --git a/tests/resources/views/dashboard.blade.php b/tests/resources/views/dashboard.blade.php new file mode 100644 index 000000000..ddb34bc29 --- /dev/null +++ b/tests/resources/views/dashboard.blade.php @@ -0,0 +1,3 @@ +
+

Basic view

+
From 69f44e74f4a73fac35510029727a04f0f081af24 Mon Sep 17 00:00:00 2001 From: Maritaria Date: Thu, 4 Nov 2021 13:31:37 +0100 Subject: [PATCH 042/404] Document `Debugbar::measure` on the facade. (#1217) --- src/Facade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Facade.php b/src/Facade.php index a4e15b4b1..12b457fad 100644 --- a/src/Facade.php +++ b/src/Facade.php @@ -18,6 +18,7 @@ * @method static void log(mixed $message) * @method static void notice(mixed $message) * @method static void warning(mixed $message) + * @method static mixed measure(string $label, \Closure $closure) * * @see \Barryvdh\Debugbar\LaravelDebugbar */ From 3e72847500b6ca8529b358be6d187ce03a1b0f28 Mon Sep 17 00:00:00 2001 From: Maritaria Date: Thu, 4 Nov 2021 13:32:31 +0100 Subject: [PATCH 043/404] Rename Facade to Debugbar (#1218) Creating the facade as a class named Debugbar enables better auto completion for IDEs and the like. To avoid naming conflicts it exists in a separate folder Facades. For backwards compatibility of existing code the current Facade persists as a class that extends the Debugbar facade class. This should allow for a minor update to the package with a deprecation notice on existing code importing the Facade explicitly. --- composer.json | 2 +- readme.md | 4 ++-- src/Facade.php | 12 ++++-------- src/Facades/Debugbar.php | 33 +++++++++++++++++++++++++++++++++ tests/BrowserTestCase.php | 4 ++-- tests/TestCase.php | 4 ++-- 6 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 src/Facades/Debugbar.php diff --git a/composer.json b/composer.json index fff17ea4b..65bb34dc2 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "Barryvdh\\Debugbar\\ServiceProvider" ], "aliases": { - "Debugbar": "Barryvdh\\Debugbar\\Facade" + "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" } } }, diff --git a/readme.md b/readme.md index ecd61a60b..a87deac8f 100644 --- a/readme.md +++ b/readme.md @@ -38,7 +38,7 @@ And the default collectors: - MemoryCollector - ExceptionsCollector -It also provides a Facade interface for easy logging Messages, Exceptions and Time +It also provides a facade interface (`Debugbar`) for easy logging Messages, Exceptions and Time ## Installation @@ -65,7 +65,7 @@ Barryvdh\Debugbar\ServiceProvider::class, If you want to use the facade to log messages, add this to your facades in app.php: ```php -'Debugbar' => Barryvdh\Debugbar\Facade::class, +'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class, ``` The profiler is enabled by default, if you have APP_DEBUG=true. You can override that in the config (`debugbar.enabled`) or by setting `DEBUGBAR_ENABLED` in your `.env`. See more options in `config/debugbar.php` diff --git a/src/Facade.php b/src/Facade.php index 12b457fad..933040d63 100644 --- a/src/Facade.php +++ b/src/Facade.php @@ -20,15 +20,11 @@ * @method static void warning(mixed $message) * @method static mixed measure(string $label, \Closure $closure) * + * @deprecated Renamed to \Barryvdh\Debugbar\Facades\Debugbar + * @see \Barryvdh\Debugbar\Facades\Debugbar + * * @see \Barryvdh\Debugbar\LaravelDebugbar */ -class Facade extends \Illuminate\Support\Facades\Facade +class Facade extends \Barryvdh\Debugbar\Facades\Debugbar { - /** - * {@inheritDoc} - */ - protected static function getFacadeAccessor() - { - return LaravelDebugbar::class; - } } diff --git a/src/Facades/Debugbar.php b/src/Facades/Debugbar.php new file mode 100644 index 000000000..3e7929b9f --- /dev/null +++ b/src/Facades/Debugbar.php @@ -0,0 +1,33 @@ + Facade::class]; + return ['Debugbar' => Debugbar::class]; } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 00e478eff..ceac18d5e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,7 @@ namespace Barryvdh\Debugbar\Tests; -use Barryvdh\Debugbar\Facade; +use Barryvdh\Debugbar\Facades\Debugbar; use Barryvdh\Debugbar\ServiceProvider; use Illuminate\Routing\Router; use Orchestra\Testbench\TestCase as Orchestra; @@ -31,7 +31,7 @@ protected function getPackageProviders($app) */ protected function getPackageAliases($app) { - return ['Debugbar' => Facade::class]; + return ['Debugbar' => Debugbar::class]; } /** From 1dbe9893e809d7f5f9d4f238ef1db2f022c29f7d Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Thu, 4 Nov 2021 12:35:25 +0000 Subject: [PATCH 044/404] composer fix-style --- tests/DataCollector/ViewCollectorTest.php | 2 +- tests/TestCase.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/DataCollector/ViewCollectorTest.php b/tests/DataCollector/ViewCollectorTest.php index c4a98b20e..1b3c6a31f 100644 --- a/tests/DataCollector/ViewCollectorTest.php +++ b/tests/DataCollector/ViewCollectorTest.php @@ -22,7 +22,7 @@ public function testIdeLinksAreAbsolutePaths() tap(Arr::first($collector->collect()['templates']), function (array $template) { $this->assertEquals( - 'vscode://file/'.realpath(__DIR__.'/../resources/views/dashboard.blade.php').':1', + 'vscode://file/' . realpath(__DIR__ . '/../resources/views/dashboard.blade.php') . ':1', $template['xdebug_link']['url'], ); }); diff --git a/tests/TestCase.php b/tests/TestCase.php index ceac18d5e..c3335f35f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -83,6 +83,6 @@ protected function addApiRoutes(Router $router) protected function addViewPaths() { - config(['view.paths' => array_merge(config('view.paths'), [__DIR__.'/resources/views'])]); + config(['view.paths' => array_merge(config('view.paths'), [__DIR__ . '/resources/views'])]); } } From b44c9c4ea799da95a6e68285c3d202a0b370ae76 Mon Sep 17 00:00:00 2001 From: Bennett Date: Thu, 11 Nov 2021 15:49:57 -0600 Subject: [PATCH 045/404] PDO Exception Fix (#1254) Prevent PDO Exception for drivers that don't support quoting (DB2 for IBM iSeries). --- src/DataCollector/QueryCollector.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index c2ee9bffa..30a71d333 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -158,7 +158,10 @@ public function addQuery($query, $bindings, $time, $connection) // Mimic bindValue and only quote non-integer and non-float data types if (!is_int($binding) && !is_float($binding)) { if ($pdo) { - $binding = $pdo->quote($binding); + try{ + $binding = $pdo->quote($binding); + } catch(\Exception $e) { + } } else { $binding = $this->emulateQuote($binding); } From e06041c79c5914057fecff6773bb294eae18fd7e Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Thu, 11 Nov 2021 21:51:53 +0000 Subject: [PATCH 046/404] composer fix-style --- src/DataCollector/QueryCollector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 30a71d333..94ff9d4ff 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -158,9 +158,9 @@ public function addQuery($query, $bindings, $time, $connection) // Mimic bindValue and only quote non-integer and non-float data types if (!is_int($binding) && !is_float($binding)) { if ($pdo) { - try{ + try { $binding = $pdo->quote($binding); - } catch(\Exception $e) { + } catch (\Exception $e) { } } else { $binding = $this->emulateQuote($binding); From 0f12adcffff17e4012763b6655d93882c194d3a7 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 12 Nov 2021 09:12:57 +0100 Subject: [PATCH 047/404] Check test for xdebug (#1256) * Update ViewCollectorTest.php * Update ViewCollectorTest.php --- tests/DataCollector/ViewCollectorTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/DataCollector/ViewCollectorTest.php b/tests/DataCollector/ViewCollectorTest.php index 1b3c6a31f..676738470 100644 --- a/tests/DataCollector/ViewCollectorTest.php +++ b/tests/DataCollector/ViewCollectorTest.php @@ -12,6 +12,13 @@ class ViewCollectorTest extends TestCase public function testIdeLinksAreAbsolutePaths() { + if (!ini_get('xdebug.file_link_format')) { + $this->markTestSkipped( + 'The Xdebug extension is not available.' + ); + return; + } + debugbar()->boot(); /** @var \Barryvdh\Debugbar\DataCollector\ViewCollector $collector */ @@ -23,7 +30,7 @@ public function testIdeLinksAreAbsolutePaths() tap(Arr::first($collector->collect()['templates']), function (array $template) { $this->assertEquals( 'vscode://file/' . realpath(__DIR__ . '/../resources/views/dashboard.blade.php') . ':1', - $template['xdebug_link']['url'], + $template['xdebug_link']['url'] ); }); } From 9853edfc6c980d7af7264f1acf6146b292636470 Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Fri, 12 Nov 2021 08:13:49 +0000 Subject: [PATCH 048/404] composer fix-style --- tests/DataCollector/ViewCollectorTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/DataCollector/ViewCollectorTest.php b/tests/DataCollector/ViewCollectorTest.php index 676738470..bea31f9aa 100644 --- a/tests/DataCollector/ViewCollectorTest.php +++ b/tests/DataCollector/ViewCollectorTest.php @@ -12,13 +12,13 @@ class ViewCollectorTest extends TestCase public function testIdeLinksAreAbsolutePaths() { - if (!ini_get('xdebug.file_link_format')) { + if (!ini_get('xdebug.file_link_format')) { $this->markTestSkipped( - 'The Xdebug extension is not available.' + 'The Xdebug extension is not available.' ); return; } - + debugbar()->boot(); /** @var \Barryvdh\Debugbar\DataCollector\ViewCollector $collector */ From 1ede251f9f58c226f33f6acc9da34855dd4eb17c Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 18 Nov 2021 15:19:47 +0200 Subject: [PATCH 049/404] Add support editor to use when clicking file name. (#1258) Co-authored-by: Viktor Mazur --- config/debugbar.php | 41 +++++++++++++++ src/DataCollector/RouteCollector.php | 74 +++++++++++++++++++++++++++- 2 files changed, 113 insertions(+), 2 deletions(-) diff --git a/config/debugbar.php b/config/debugbar.php index e7f6b0999..bcfc11fe0 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -42,6 +42,47 @@ 'port' => 2304, // Port to use with the "socket" driver ], + /* + |-------------------------------------------------------------------------- + | Editor + |-------------------------------------------------------------------------- + | + | Choose your preferred editor to use when clicking file name. + | + | Supported: "phpstorm", "vscode", "vscode-insiders", "vscodium", "textmate", "emacs", + | "sublime", "atom", "nova", "macvim", "idea", "netbeans", + | "xdebug", "espresso" + | + */ + + 'editor' => env('DEBUGBAR_EDITOR', 'phpstorm'), + + /* + |-------------------------------------------------------------------------- + | Remote Path Mapping + |-------------------------------------------------------------------------- + | + | If you are using a remote dev server, like Laravel Homestead, Docker, or + | even a remote VPS, it will be necessary to specify your path mapping. + | + | Leaving one, or both of these, empty or null will not trigger the remote + | URL changes and Debugbar will treat your editor links as local files. + | + | "remote_sites_path" is an absolute base path for your sites or projects + | in Homestead, Vagrant, Docker, or another remote development server. + | + | Example value: "/home/vagrant/Code" + | + | "local_sites_path" is an absolute base path for your sites or projects + | on your local computer where your IDE or code editor is running on. + | + | Example values: "/Users//Code", "C:\Users\\Documents\Code" + | + */ + + 'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH', ''), + 'local_sites_path' => env('DEBUGBAR_LOCAL_SITES_PATH', ''), + /* |-------------------------------------------------------------------------- | Vendors diff --git a/src/DataCollector/RouteCollector.php b/src/DataCollector/RouteCollector.php index 9e17b8fb3..5e947e188 100644 --- a/src/DataCollector/RouteCollector.php +++ b/src/DataCollector/RouteCollector.php @@ -9,6 +9,7 @@ use Illuminate\Routing\Route; use Illuminate\Routing\Router; use Illuminate\Support\Facades\Config; +use InvalidArgumentException; /** * Based on Illuminate\Foundation\Console\RoutesCommand for Taylor Otwell @@ -24,6 +25,28 @@ class RouteCollector extends DataCollector implements Renderable */ protected $router; + /** + * A list of known editor strings. + * + * @var array + */ + protected $editors = [ + 'sublime' => 'subl://open?url=file://%file&line=%line', + 'textmate' => 'txmt://open?url=file://%file&line=%line', + 'emacs' => 'emacs://open?url=file://%file&line=%line', + 'macvim' => 'mvim://open/?url=file://%file&line=%line', + 'phpstorm' => 'phpstorm://open?file=%file&line=%line', + 'idea' => 'idea://open?file=%file&line=%line', + 'vscode' => 'vscode://file/%file:%line', + 'vscode-insiders' => 'vscode-insiders://file/%file:%line', + 'vscodium' => 'vscodium://file/%file:%line', + 'nova' => 'nova://core/open/file?filename=%file&line=%line', + 'xdebug' => 'xdebug://%file@%line', + 'atom' => 'atom://core/open/file?filename=%file&line=%line', + 'espresso' => 'x-espresso://open?filepath=%file&lines=%line', + 'netbeans' => 'netbeans://open/?f=%file:%line', + ]; + public function __construct(Router $router) { $this->router = $router; @@ -76,7 +99,12 @@ protected function getRouteInformation($route) if (isset($reflector)) { $filename = ltrim(str_replace(base_path(), '', $reflector->getFileName()), '/'); - $result['file'] = $filename . ':' . $reflector->getStartLine() . '-' . $reflector->getEndLine(); + + if ($href = $this->getEditorHref($reflector->getFileName(), $reflector->getStartLine())) { + $result['file'] = sprintf('%s:%s-%s', $href, $filename, $reflector->getStartLine(), $reflector->getEndLine()); + } else { + $result['file'] = sprintf('%s:%s-%s', $filename, $reflector->getStartLine(), $reflector->getEndLine()); + } } if ($middleware = $this->getMiddleware($route)) { @@ -117,7 +145,7 @@ public function getWidgets() $widgets = [ "route" => [ "icon" => "share", - "widget" => "PhpDebugBar.Widgets.VariableListWidget", + "widget" => "PhpDebugBar.Widgets.HtmlVariableListWidget", "map" => "route", "default" => "{}" ] @@ -145,4 +173,46 @@ protected function displayRoutes(array $routes) $this->table->render($this->getOutput()); } + + /** + * Get the editor href for a given file and line, if available. + * + * @param string $filePath + * @param int $line + * + * @throws InvalidArgumentException If editor resolver does not return a string + * + * @return null|string + */ + protected function getEditorHref($filePath, $line) + { + if (empty(config('debugbar.editor'))) { + return null; + } + + if (empty($this->editors[config('debugbar.editor')])) { + throw new InvalidArgumentException( + 'Unknown editor identifier: ' . config('debugbar.editor') . '. Known editors:' . + implode(', ', array_keys($this->editors)) + ); + } + + $filePath = $this->replaceSitesPath($filePath); + + $url = str_replace(['%file', '%line'], [$filePath, $line], $this->editors[config('debugbar.editor')]); + + return $url; + } + + /** + * Replace remote path + * + * @param string $filePath + * + * @return string + */ + protected function replaceSitesPath($filePath) + { + return str_replace(config('debugbar.remote_sites_path'), config('debugbar.local_sites_path'), $filePath); + } } From 8a74874093bdd98e48fe2e2d1eb4c52cab23a4ab Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 3 Dec 2021 17:13:03 +0100 Subject: [PATCH 050/404] Tweak vendor paths --- src/DataCollector/QueryCollector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 94ff9d4ff..0690ca3d6 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -23,9 +23,10 @@ class QueryCollector extends PDOCollector protected $showCopyButton = false; protected $reflection = []; protected $backtraceExcludePaths = [ - '/vendor/laravel/framework/src/Illuminate/Support/HigherOrderTapProxy', + '/vendor/laravel/framework/src/Illuminate/Support', '/vendor/laravel/framework/src/Illuminate/Database', '/vendor/laravel/framework/src/Illuminate/Events', + '/vendor/october/rain', '/vendor/barryvdh/laravel-debugbar', ]; From 14105aa63bd86165119bbfe3b6fe5372b3120f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20K=C3=B6hler?= Date: Sun, 12 Dec 2021 22:12:37 +0100 Subject: [PATCH 051/404] Update Debugbar.php (#1267) corrected the namespace for LaravelDebugbar in Barryvdh\Debugbar\Facades\Debugbar. This was causing the error "Target class [Barryvdh\Debugbar\Facades\LaravelDebugbar] does not exist" --- src/Facades/Debugbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facades/Debugbar.php b/src/Facades/Debugbar.php index 3e7929b9f..b4003579e 100644 --- a/src/Facades/Debugbar.php +++ b/src/Facades/Debugbar.php @@ -28,6 +28,6 @@ class Debugbar extends \Illuminate\Support\Facades\Facade */ protected static function getFacadeAccessor() { - return LaravelDebugbar::class; + return \Barryvdh\Debugbar\LaravelDebugbar::class; } } From 043a81b3feeb607c543a27cc5a8a24158fde6a7d Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 14 Dec 2021 15:32:48 +0100 Subject: [PATCH 052/404] Update callgraph color in darkmode --- src/Resources/laravel-debugbar-dark-mode.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resources/laravel-debugbar-dark-mode.css b/src/Resources/laravel-debugbar-dark-mode.css index 4c55466cd..69baff9b9 100644 --- a/src/Resources/laravel-debugbar-dark-mode.css +++ b/src/Resources/laravel-debugbar-dark-mode.css @@ -130,6 +130,7 @@ div.phpdebugbar div.phpdebugbar-widgets-sqlqueries li.phpdebugbar-widgets-list-i div.phpdebugbar div.phpdebugbar-widgets-sqlqueries li.phpdebugbar-widgets-list-item span.phpdebugbar-widgets-row-count, div.phpdebugbar div.phpdebugbar-widgets-sqlqueries li.phpdebugbar-widgets-list-item span.phpdebugbar-widgets-copy-clipboard, div.phpdebugbar div.phpdebugbar-widgets-sqlqueries li.phpdebugbar-widgets-list-item span.phpdebugbar-widgets-stmt-id, +div.phpdebugbar .phpdebugbar-widgets-callgraph pre, div.phpdebugbar .phpdebugbar-text-muted, div.phpdebugbar-openhandler .phpdebugbar-text-muted { From 5e97575db42dcc6322365a5d2b43a3ad3c40987e Mon Sep 17 00:00:00 2001 From: laravel-debugbar Date: Tue, 14 Dec 2021 14:33:43 +0000 Subject: [PATCH 053/404] composer fix-style --- src/Controllers/OpenHandlerController.php | 1 - src/Controllers/TelescopeController.php | 1 - src/DataFormatter/QueryFormatter.php | 1 - src/ServiceProvider.php | 1 - src/Storage/SocketStorage.php | 1 - src/Support/Clockwork/Converter.php | 1 - tests/DebugbarBrowserTest.php | 1 - tests/Models/Person.php | 1 - tests/TestCase.php | 1 - 9 files changed, 9 deletions(-) diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index 02cc3c61d..e5c059fc3 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -9,7 +9,6 @@ class OpenHandlerController extends BaseController { - public function handle(Request $request) { $openHandler = new OpenHandler($this->debugbar); diff --git a/src/Controllers/TelescopeController.php b/src/Controllers/TelescopeController.php index dcc4d2f6c..8f263b4c9 100644 --- a/src/Controllers/TelescopeController.php +++ b/src/Controllers/TelescopeController.php @@ -12,7 +12,6 @@ class TelescopeController extends BaseController { - public function show(EntriesRepository $storage, $uuid) { diff --git a/src/DataFormatter/QueryFormatter.php b/src/DataFormatter/QueryFormatter.php index 7a94e40f2..e7c1696b9 100644 --- a/src/DataFormatter/QueryFormatter.php +++ b/src/DataFormatter/QueryFormatter.php @@ -6,7 +6,6 @@ class QueryFormatter extends DataFormatter { - /** * Removes extra spaces at the beginning and end of the SQL query and its lines. * diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 08e2107c2..c7cc68b65 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -70,7 +70,6 @@ function (EngineResolver $resolver, Application $application): EngineResolver { } return new class ($resolver, $laravelDebugbar) extends EngineResolver { - private $laravelDebugbar; public function __construct(EngineResolver $resolver, LaravelDebugbar $laravelDebugbar) diff --git a/src/Storage/SocketStorage.php b/src/Storage/SocketStorage.php index 6b242b2f7..23f8b4809 100644 --- a/src/Storage/SocketStorage.php +++ b/src/Storage/SocketStorage.php @@ -6,7 +6,6 @@ class SocketStorage implements StorageInterface { - protected $hostname; protected $port; protected $socket; diff --git a/src/Support/Clockwork/Converter.php b/src/Support/Clockwork/Converter.php index 79dfb695a..dbd4c05ff 100644 --- a/src/Support/Clockwork/Converter.php +++ b/src/Support/Clockwork/Converter.php @@ -4,7 +4,6 @@ class Converter { - /** * Convert the phpdebugbar data to Clockwork format. * diff --git a/tests/DebugbarBrowserTest.php b/tests/DebugbarBrowserTest.php index b23c0423e..6619cfe32 100644 --- a/tests/DebugbarBrowserTest.php +++ b/tests/DebugbarBrowserTest.php @@ -6,7 +6,6 @@ class DebugbarBrowserTest extends BrowserTestCase { - /** * Define environment setup. * diff --git a/tests/Models/Person.php b/tests/Models/Person.php index 34a409ec3..05aa72206 100644 --- a/tests/Models/Person.php +++ b/tests/Models/Person.php @@ -4,5 +4,4 @@ class Person extends User { - } diff --git a/tests/TestCase.php b/tests/TestCase.php index c3335f35f..161e91660 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -9,7 +9,6 @@ class TestCase extends Orchestra { - /** * Get package providers. * From 80b9040c61f3772433d6e588d44325770b1bbb62 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 14 Dec 2021 15:43:41 +0100 Subject: [PATCH 054/404] The type attribute is unnecessary for JavaScript resources. (#1265) --- src/JavascriptRenderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JavascriptRenderer.php b/src/JavascriptRenderer.php index 56c3a8c02..0cf3983c4 100644 --- a/src/JavascriptRenderer.php +++ b/src/JavascriptRenderer.php @@ -64,10 +64,10 @@ public function renderHead() $jsRoute = preg_replace('/\Ahttps?:/', '', $jsRoute); $html = ""; - $html .= ""; + $html .= ""; if ($this->isJqueryNoConflictEnabled()) { - $html .= '' . "\n"; + $html .= '' . "\n"; } $html .= $this->getInlineHtml(); From 33bf3c13096da1d81810f89a7827f3a197847a39 Mon Sep 17 00:00:00 2001 From: Amir Hossein <68776630+amirHossein5@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:13:50 +0330 Subject: [PATCH 055/404] Fix direction rtl for children of debugbar div (#1263) * Fix rtl direction for children of debugbar div * fix space after * --- src/Resources/laravel-debugbar.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index 62170efa3..fd704c880 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -11,6 +11,11 @@ div.phpdebugbar { z-index: 6000000; } +div.phpdebugbar * { + direction: ltr; + text-align: left; +} + div.phpdebugbar-openhandler-overlay { z-index: 6000001; cursor: pointer; From ccf109f8755dcc7e58779d1aeb1051b04e0b4bef Mon Sep 17 00:00:00 2001 From: "Daniel S. Deboer" Date: Tue, 14 Dec 2021 09:45:18 -0500 Subject: [PATCH 056/404] [fix] Emulate quote bindings for drivers that don't support quoting (#1219) Co-authored-by: Barry vd. Heuvel --- src/DataCollector/QueryCollector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 0690ca3d6..17c3f69eb 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -162,6 +162,7 @@ public function addQuery($query, $bindings, $time, $connection) try { $binding = $pdo->quote($binding); } catch (\Exception $e) { + $binding = $this->emulateQuote($binding); } } else { $binding = $this->emulateQuote($binding); From 81b130f4fb27eae9fe450c264bdd2bdad11a775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Nikolaou?= Date: Sat, 18 Dec 2021 16:58:20 +0200 Subject: [PATCH 057/404] Add editor support for vscode remote links (#1268) --- config/debugbar.php | 3 ++- src/DataCollector/RouteCollector.php | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/debugbar.php b/config/debugbar.php index bcfc11fe0..fe3b192d7 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -49,7 +49,8 @@ | | Choose your preferred editor to use when clicking file name. | - | Supported: "phpstorm", "vscode", "vscode-insiders", "vscodium", "textmate", "emacs", + | Supported: "phpstorm", "vscode", "vscode-insiders", "vscode-remote", + | "vscode-insiders-remote", "vscodium", "textmate", "emacs", | "sublime", "atom", "nova", "macvim", "idea", "netbeans", | "xdebug", "espresso" | diff --git a/src/DataCollector/RouteCollector.php b/src/DataCollector/RouteCollector.php index 5e947e188..a255302f3 100644 --- a/src/DataCollector/RouteCollector.php +++ b/src/DataCollector/RouteCollector.php @@ -39,6 +39,8 @@ class RouteCollector extends DataCollector implements Renderable 'idea' => 'idea://open?file=%file&line=%line', 'vscode' => 'vscode://file/%file:%line', 'vscode-insiders' => 'vscode-insiders://file/%file:%line', + 'vscode-remote' => 'vscode://vscode-remote/%file:%line', + 'vscode-insiders-remote' => 'vscode-insiders://vscode-remote/%file:%line', 'vscodium' => 'vscodium://file/%file:%line', 'nova' => 'nova://core/open/file?filename=%file&line=%line', 'xdebug' => 'xdebug://%file@%line', From f92fe967b40b36ad1ee8ed2fd59c05ae67a1ebba Mon Sep 17 00:00:00 2001 From: Armin Linzbauer Date: Tue, 21 Dec 2021 19:20:10 +0100 Subject: [PATCH 058/404] Update Dependencies for Laravel 9 (#1271) --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 65bb34dc2..4eb9180e1 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ "require": { "php": ">=7.2", "maximebf/debugbar": "^1.17.2", - "illuminate/routing": "^6|^7|^8", - "illuminate/session": "^6|^7|^8", - "illuminate/support": "^6|^7|^8", - "symfony/debug": "^4.3|^5", - "symfony/finder": "^4.3|^5" + "illuminate/routing": "^6|^7|^8|^9", + "illuminate/session": "^6|^7|^8|^9", + "illuminate/support": "^6|^7|^8|^9", + "symfony/debug": "^4.3|^5|^6", + "symfony/finder": "^4.3|^5|^6" }, "require-dev": { "mockery/mockery": "^1.3.3", From 0548fa6a563e0e80f4ee8a17b93ecc8602e56cde Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 30 Jan 2022 13:42:06 +0100 Subject: [PATCH 059/404] Update readme.md --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index a87deac8f..54eaafba1 100644 --- a/readme.md +++ b/readme.md @@ -3,6 +3,7 @@ [![Packagist License](https://poser.pugx.org/barryvdh/laravel-debugbar/license.png)](http://choosealicense.com/licenses/mit/) [![Latest Stable Version](https://poser.pugx.org/barryvdh/laravel-debugbar/version.png)](https://packagist.org/packages/barryvdh/laravel-debugbar) [![Total Downloads](https://poser.pugx.org/barryvdh/laravel-debugbar/d/total.png)](https://packagist.org/packages/barryvdh/laravel-debugbar) +[![Fruitcake](https://img.shields.io/badge/Powered%20By-Fruitcake-b2bc35.svg)](https://fruitcake.nl/) This is a package to integrate [PHP Debug Bar](http://phpdebugbar.com/) with Laravel. It includes a ServiceProvider to register the debugbar and attach it to the output. You can publish assets and configure it through Laravel. From 4ad282a9af271bd0647e0353eb5aed2e8520773e Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 30 Jan 2022 18:37:50 +0100 Subject: [PATCH 060/404] Test Laravel 9 (#1282) --- .github/workflows/run-tests.yml | 8 +++++++- composer.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a18e01f92..bc6d932a8 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,11 +20,17 @@ jobs: strategy: matrix: php: [8.0, 7.4, 7.3, 7.2] - laravel: [8.*, 6.*, 7.*] + laravel: [9.*, 8.*, 6.*, 7.*] dependency-version: [prefer-lowest, prefer-stable] exclude: - laravel: 8.* php: 7.2 + - laravel: 9.* + php: 7.2 + - laravel: 9.* + php: 7.3 + - laravel: 9.* + php: 7.4 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index 4eb9180e1..c632bc244 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "mockery/mockery": "^1.3.3", - "orchestra/testbench-dusk": "^4|^5|^6", + "orchestra/testbench-dusk": "^4|^5|^6|^7", "phpunit/phpunit": "^8.5|^9.0", "squizlabs/php_codesniffer": "^3.5" }, From c90b0f7520d4d5fcc17dede1fbd5b989a5b5960c Mon Sep 17 00:00:00 2001 From: Faissal Wahabali Date: Tue, 8 Feb 2022 13:11:35 +0100 Subject: [PATCH 061/404] fix sql overflow (#1285) --- src/Resources/laravel-debugbar.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index fd704c880..424c6ad49 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -552,6 +552,7 @@ ul.phpdebugbar-widgets-timeline li:hover { ul.phpdebugbar-widgets-list li.phpdebugbar-widgets-list-item .phpdebugbar-widgets-sql { flex: 1; margin-right: 5px; + max-width: 100%; } ul.phpdebugbar-widgets-list li.phpdebugbar-widgets-list-item .phpdebugbar-widgets-duration { From bafb3903c0ab8590b192e256ca564f0846b689e0 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 8 Feb 2022 13:14:02 +0100 Subject: [PATCH 062/404] Force value as string Fixes #1284 --- src/DataCollector/QueryCollector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 17c3f69eb..fbeaf81b5 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -160,7 +160,7 @@ public function addQuery($query, $bindings, $time, $connection) if (!is_int($binding) && !is_float($binding)) { if ($pdo) { try { - $binding = $pdo->quote($binding); + $binding = $pdo->quote((string) $binding); } catch (\Exception $e) { $binding = $this->emulateQuote($binding); } @@ -211,7 +211,7 @@ protected function emulateQuote($value) $search = ["\\", "\x00", "\n", "\r", "'", '"', "\x1a"]; $replace = ["\\\\","\\0","\\n", "\\r", "\'", '\"', "\\Z"]; - return "'" . str_replace($search, $replace, $value) . "'"; + return "'" . str_replace($search, $replace, (string) $value) . "'"; } /** From b96f9820aaf1ff9afe945207883149e1c7afb298 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 9 Feb 2022 08:52:32 +0100 Subject: [PATCH 063/404] Skip Mailer in Laravel 9 Fixes #1289 --- src/LaravelDebugbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 61e168e7a..1842aa5de 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -450,7 +450,7 @@ function ($event, $params) use ($queryCollector) { } } - if ($this->shouldCollect('mail', true) && class_exists('Illuminate\Mail\MailServiceProvider')) { + if ($this->shouldCollect('mail', true) && class_exists('Illuminate\Mail\MailServiceProvider') && $this->checkVersion('9.0', '<')) { try { $mailer = $this->app['mailer']->getSwiftMailer(); $this->addCollector(new SwiftMailCollector($mailer)); From 29d7d90678f968d279eb083fccfea1824132c976 Mon Sep 17 00:00:00 2001 From: Jakub Dibala Date: Thu, 24 Feb 2022 20:28:35 +0100 Subject: [PATCH 064/404] Fix htmlentities PHP warning (#1291) * Fix htmlentities PHP warning * Update QueryFormatter.php Co-authored-by: Barry vd. Heuvel --- src/DataFormatter/QueryFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataFormatter/QueryFormatter.php b/src/DataFormatter/QueryFormatter.php index e7c1696b9..f8574f5d6 100644 --- a/src/DataFormatter/QueryFormatter.php +++ b/src/DataFormatter/QueryFormatter.php @@ -55,7 +55,7 @@ public function checkBindings($bindings) public function escapeBindings($bindings) { foreach ($bindings as &$binding) { - $binding = htmlentities($binding, ENT_QUOTES, 'UTF-8', false); + $binding = htmlentities((string) $binding, ENT_QUOTES, 'UTF-8', false); } return $bindings; From b2d39072d094ccd060e27125352985d77aa60dc0 Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Tue, 15 Mar 2022 20:31:06 +0300 Subject: [PATCH 065/404] fix style (#1266) --- src/ServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index c7cc68b65..10a5a7cfc 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -34,7 +34,7 @@ public function register() ); $this->app->singleton(LaravelDebugbar::class, function ($app) { - $debugbar = new LaravelDebugbar($app); + $debugbar = new LaravelDebugbar($app); if ($app->bound(SessionManager::class)) { $sessionManager = $app->make(SessionManager::class); @@ -42,7 +42,7 @@ public function register() $debugbar->setHttpDriver($httpDriver); } - return $debugbar; + return $debugbar; }); $this->app->alias(LaravelDebugbar::class, 'debugbar'); From e7c3f56e54258d5e2939e68d453ce9db0c086406 Mon Sep 17 00:00:00 2001 From: Alexandre D'Eschambeault Date: Wed, 4 May 2022 07:45:10 -0400 Subject: [PATCH 066/404] fix: load routes and commands in the service provider's boot method (#1197) --- src/ServiceProvider.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 10a5a7cfc..11ea596e7 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -26,8 +26,6 @@ public function register() $configPath = __DIR__ . '/../config/debugbar.php'; $this->mergeConfigFrom($configPath, 'debugbar'); - $this->loadRoutesFrom(realpath(__DIR__ . '/debugbar-routes.php')); - $this->app->alias( DataFormatter::class, DataFormatterInterface::class @@ -90,8 +88,6 @@ public function register($engine, \Closure $resolver) } ); - $this->commands(['command.debugbar.clear']); - Collection::macro('debug', function () { debug($this); return $this; @@ -108,7 +104,13 @@ public function boot() $configPath = __DIR__ . '/../config/debugbar.php'; $this->publishes([$configPath => $this->getConfigPath()], 'config'); + $this->loadRoutesFrom(realpath(__DIR__ . '/debugbar-routes.php')); + $this->registerMiddleware(InjectDebugbar::class); + + if ($this->app->runningInConsole()) { + $this->commands(['command.debugbar.clear']); + } } /** From 814b36a08a60f4159cdcbb1c466a6a0027440b6c Mon Sep 17 00:00:00 2001 From: TinaH Date: Wed, 8 Jun 2022 17:03:05 +0200 Subject: [PATCH 067/404] Turbolinks compatibility (#1320) --- src/JavascriptRenderer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/JavascriptRenderer.php b/src/JavascriptRenderer.php index 0cf3983c4..428b15a9d 100644 --- a/src/JavascriptRenderer.php +++ b/src/JavascriptRenderer.php @@ -63,11 +63,11 @@ public function renderHead() $cssRoute = preg_replace('/\Ahttps?:/', '', $cssRoute); $jsRoute = preg_replace('/\Ahttps?:/', '', $jsRoute); - $html = ""; - $html .= ""; + $html = ""; + $html .= ""; if ($this->isJqueryNoConflictEnabled()) { - $html .= '' . "\n"; + $html .= '' . "\n"; } $html .= $this->getInlineHtml(); From 3372ed65e6d2039d663ed19aa699956f9d346271 Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Mon, 11 Jul 2022 11:26:42 +0200 Subject: [PATCH 068/404] Remove symfony/debug dependency (#1321) * Migrate from symfony/debug to symfony/error-handler * Fix wrong version constraints * Remove Laravel 6 Support * Remove lumen 6 from test matrix * Remove symfony/error-handler --- .github/workflows/run-integration-tests.yml | 6 ++---- .github/workflows/run-tests.yml | 2 +- composer.json | 13 ++++++------- src/Middleware/InjectDebugbar.php | 12 ++++-------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index fb2edd370..56759976d 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -19,14 +19,12 @@ jobs: strategy: matrix: php: [8.0, 7.4, 7.3, 7.2] - lumen: [8.*, 7.*, 6.*] + lumen: [8.*, 7.*] exclude: - lumen: 8.* php: 7.2 - lumen: 7.* php: 8.0 - - lumen: 6.* - php: 8.0 name: P${{ matrix.php }} - Lumen${{ matrix.lumen }} steps: - name: Checkout code @@ -69,7 +67,7 @@ jobs: strategy: matrix: php: [8.0, 7.4, 7.3, 7.2] - laravel: [8.*, 7.*, 6.*] + laravel: [8.*, 7.*] exclude: - laravel: 8.* php: 7.2 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bc6d932a8..6f10c965b 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: php: [8.0, 7.4, 7.3, 7.2] - laravel: [9.*, 8.*, 6.*, 7.*] + laravel: [9.*, 8.*, 7.*] dependency-version: [prefer-lowest, prefer-stable] exclude: - laravel: 8.* diff --git a/composer.json b/composer.json index c632bc244..b911a5e3d 100644 --- a/composer.json +++ b/composer.json @@ -10,17 +10,16 @@ } ], "require": { - "php": ">=7.2", + "php": ">=7.2.5", "maximebf/debugbar": "^1.17.2", - "illuminate/routing": "^6|^7|^8|^9", - "illuminate/session": "^6|^7|^8|^9", - "illuminate/support": "^6|^7|^8|^9", - "symfony/debug": "^4.3|^5|^6", - "symfony/finder": "^4.3|^5|^6" + "illuminate/routing": "^7|^8|^9", + "illuminate/session": "^7|^8|^9", + "illuminate/support": "^7|^8|^9", + "symfony/finder": "^5|^6" }, "require-dev": { "mockery/mockery": "^1.3.3", - "orchestra/testbench-dusk": "^4|^5|^6|^7", + "orchestra/testbench-dusk": "^5|^6|^7", "phpunit/phpunit": "^8.5|^9.0", "squizlabs/php_codesniffer": "^3.5" }, diff --git a/src/Middleware/InjectDebugbar.php b/src/Middleware/InjectDebugbar.php index 2b4e3e158..48be02d8a 100644 --- a/src/Middleware/InjectDebugbar.php +++ b/src/Middleware/InjectDebugbar.php @@ -2,14 +2,13 @@ namespace Barryvdh\Debugbar\Middleware; -use Error; use Closure; use Exception; use Illuminate\Http\Request; use Barryvdh\Debugbar\LaravelDebugbar; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Debug\ExceptionHandler; -use Symfony\Component\Debug\Exception\FatalThrowableError; +use Throwable; class InjectDebugbar { @@ -65,10 +64,7 @@ public function handle($request, Closure $next) try { /** @var \Illuminate\Http\Response $response */ $response = $next($request); - } catch (Exception $e) { - $response = $this->handleException($request, $e); - } catch (Error $error) { - $e = new FatalThrowableError($error); + } catch (Throwable $e) { $response = $this->handleException($request, $e); } @@ -84,11 +80,11 @@ public function handle($request, Closure $next) * (Copy from Illuminate\Routing\Pipeline by Taylor Otwell) * * @param $passable - * @param Exception $e + * @param Throwable $e * @return mixed * @throws Exception */ - protected function handleException($passable, Exception $e) + protected function handleException($passable, $e) { if (! $this->container->bound(ExceptionHandler::class) || ! $passable instanceof Request) { throw $e; From 119f0bcaafaba4e00e9a3215fa57b7b36c10447b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=BCndig?= <8600029+tobias-kuendig@users.noreply.github.com> Date: Wed, 3 Aug 2022 14:39:53 +0200 Subject: [PATCH 069/404] Implemented support for Twig 3 (#1318) * Implemented support for Twig 3 * Fixed v2 namespace * Use the same notation everywhere * Removed import * Use clearer naming * Fixed another Twig_Token param * Fixed StopwatchTokenParser * Fixed namespaces * Renamed variable * Refactored Twig compatibility to common base classes * Refactor + Stopwatch fix --- src/Twig/Extension/Debug.php | 15 ++++++--- src/Twig/Extension/Dump.php | 18 +++++++---- src/Twig/Extension/Extension.php | 10 ++++++ src/Twig/Extension/Stopwatch.php | 3 +- src/Twig/Node/Node.php | 10 ++++++ src/Twig/Node/StopwatchNode.php | 29 +++++++++++++---- src/Twig/TokenParser/StopwatchTokenParser.php | 32 +++++++++++++++---- src/Twig/TokenParser/TokenParser.php | 10 ++++++ 8 files changed, 102 insertions(+), 25 deletions(-) create mode 100644 src/Twig/Extension/Extension.php create mode 100644 src/Twig/Node/Node.php create mode 100644 src/Twig/TokenParser/TokenParser.php diff --git a/src/Twig/Extension/Debug.php b/src/Twig/Extension/Debug.php index 42bc2cb32..a70b69a4f 100644 --- a/src/Twig/Extension/Debug.php +++ b/src/Twig/Extension/Debug.php @@ -10,7 +10,7 @@ /** * Access Laravels auth class in your Twig templates. */ -class Debug extends Twig_Extension +class Debug extends Extension { /** * @var \Barryvdh\Debugbar\LaravelDebugbar @@ -44,8 +44,15 @@ public function getName() */ public function getFunctions() { + // Maintain compatibility with Twig 2 and 3. + $simpleFunction = 'Twig_SimpleFunction'; + + if (!class_exists($simpleFunction)) { + $simpleFunction = '\Twig\TwigFunction'; + } + return [ - new Twig_SimpleFunction( + new $simpleFunction( 'debug', [$this, 'debug'], ['needs_context' => true, 'needs_environment' => true] @@ -57,10 +64,10 @@ public function getFunctions() * Based on Twig_Extension_Debug / twig_var_dump * (c) 2011 Fabien Potencier * - * @param Twig_Environment $env + * @param \Twig_Environment|\Twig\Environment $env * @param $context */ - public function debug(Twig_Environment $env, $context) + public function debug($env, $context) { if (!$env->isDebug() || !$this->debugbar) { return; diff --git a/src/Twig/Extension/Dump.php b/src/Twig/Extension/Dump.php index b42fafa42..edd17ba03 100644 --- a/src/Twig/Extension/Dump.php +++ b/src/Twig/Extension/Dump.php @@ -3,14 +3,11 @@ namespace Barryvdh\Debugbar\Twig\Extension; use DebugBar\DataFormatter\DataFormatterInterface; -use Twig_Environment; -use Twig_Extension; -use Twig_SimpleFunction; /** * Dump variables using the DataFormatter */ -class Dump extends Twig_Extension +class Dump extends Extension { /** * @var \DebugBar\DataFormatter\DataFormatter @@ -40,8 +37,15 @@ public function getName() */ public function getFunctions() { + // Maintain compatibility with Twig 2 and 3. + $simpleFunction = '\Twig_SimpleFunction'; + + if (!class_exists($simpleFunction)) { + $simpleFunction = '\Twig\TwigFunction'; + } + return [ - new Twig_SimpleFunction( + new $simpleFunction( 'dump', [$this, 'dump'], ['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true] @@ -53,12 +57,12 @@ public function getFunctions() * Based on Twig_Extension_Debug / twig_var_dump * (c) 2011 Fabien Potencier * - * @param Twig_Environment $env + * @param \Twig_Environment|\Twig\Environment $env * @param $context * * @return string */ - public function dump(Twig_Environment $env, $context) + public function dump($env, $context) { $output = ''; diff --git a/src/Twig/Extension/Extension.php b/src/Twig/Extension/Extension.php new file mode 100644 index 000000000..282ecf03b --- /dev/null +++ b/src/Twig/Extension/Extension.php @@ -0,0 +1,10 @@ + */ -class StopwatchNode extends \Twig_Node +class StopwatchNode extends Node { + /** + * @param \Twig_NodeInterface|\Twig\Node\Node $name + * @param $body + * @param \Twig_Node_Expression_AssignName|\Twig\Node\Expression\AssignNameExpression $var + * @param $lineno + * @param $tag + */ public function __construct( - \Twig_NodeInterface $name, + $name, $body, - \Twig_Node_Expression_AssignName $var, + $var, $lineno = 0, $tag = null ) { parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag); } - public function compile(\Twig_Compiler $compiler) + /** + * @param \Twig_Compiler|\Twig\Compiler $env + * @return void + */ + public function compile($compiler) { + // Maintain compatibility with Twig 2 and 3. + $extension = \Barryvdh\Debugbar\Twig\Extension\Stopwatch::class; + if (class_exists('\Twig_Node')) { + $extension = 'stopwatch'; + } + $compiler ->addDebugInfo($this) ->write('') @@ -28,11 +45,11 @@ public function compile(\Twig_Compiler $compiler) ->raw(' = ') ->subcompile($this->getNode('name')) ->write(";\n") - ->write("\$this->env->getExtension('stopwatch')->getDebugbar()->startMeasure(") + ->write(sprintf("\$this->env->getExtension('%s')->getDebugbar()->startMeasure(", $extension)) ->subcompile($this->getNode('var')) ->raw(");\n") ->subcompile($this->getNode('body')) - ->write("\$this->env->getExtension('stopwatch')->getDebugbar()->stopMeasure(") + ->write(sprintf("\$this->env->getExtension('%s')->getDebugbar()->stopMeasure(", $extension)) ->subcompile($this->getNode('var')) ->raw(");\n"); } diff --git a/src/Twig/TokenParser/StopwatchTokenParser.php b/src/Twig/TokenParser/StopwatchTokenParser.php index cb197a208..896af4992 100644 --- a/src/Twig/TokenParser/StopwatchTokenParser.php +++ b/src/Twig/TokenParser/StopwatchTokenParser.php @@ -9,7 +9,7 @@ * * @author Wouter J */ -class StopwatchTokenParser extends \Twig_TokenParser +class StopwatchTokenParser extends TokenParser { protected $debugbarAvailable; @@ -18,7 +18,10 @@ public function __construct($debugbarAvailable) $this->debugbarAvailable = $debugbarAvailable; } - public function parse(\Twig_Token $token) + /** + * @param \Twig_Token|\Twig\Token $token + */ + public function parse($token) { $lineno = $token->getLine(); $stream = $this->parser->getStream(); @@ -26,17 +29,31 @@ public function parse(\Twig_Token $token) // {% stopwatch 'bar' %} $name = $this->parser->getExpressionParser()->parseExpression(); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); + // Maintain compatibility with Twig 2 and 3. + if (class_exists("\Twig_Token")) { + $blockEndType = \Twig_Token::BLOCK_END_TYPE; + } else { + $blockEndType = \Twig\Token::BLOCK_END_TYPE; + } + + $stream->expect($blockEndType); // {% endstopwatch %} $body = $this->parser->subparse([$this, 'decideStopwatchEnd'], true); - $stream->expect(\Twig_Token::BLOCK_END_TYPE); + $stream->expect($blockEndType); + + // Maintain compatibility with Twig 2 and 3. + if (class_exists("\Twig_Node_Expression_AssignName")) { + $assignNameExpression = new \Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()); + } else { + $assignNameExpression = new \Twig\Node\Expression\AssignNameExpression($this->parser->getVarName(), $token->getLine()); + } if ($this->debugbarAvailable) { return new StopwatchNode( $name, $body, - new \Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), + $assignNameExpression, $lineno, $this->getTag() ); @@ -50,7 +67,10 @@ public function getTag() return 'stopwatch'; } - public function decideStopwatchEnd(\Twig_Token $token) + /** + * @param \Twig_Token|\Twig\Token $token + */ + public function decideStopwatchEnd($token) { return $token->test('endstopwatch'); } diff --git a/src/Twig/TokenParser/TokenParser.php b/src/Twig/TokenParser/TokenParser.php new file mode 100644 index 000000000..4a0b6d1cb --- /dev/null +++ b/src/Twig/TokenParser/TokenParser.php @@ -0,0 +1,10 @@ + Date: Wed, 3 Aug 2022 14:42:59 +0200 Subject: [PATCH 070/404] Fix PHP 8.2 deprecation (#1322) * Remove deprecated dynamic name property on ViewCollector * Remove unused import on ViewCollector --- src/DataCollector/ViewCollector.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index 7a1b0c577..e72097d8f 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -5,7 +5,6 @@ use Barryvdh\Debugbar\DataFormatter\SimpleFormatter; use DebugBar\Bridge\Twig\TwigCollector; use Illuminate\View\View; -use Symfony\Component\VarDumper\Cloner\VarCloner; class ViewCollector extends TwigCollector { @@ -21,7 +20,6 @@ public function __construct($collectData = true) { $this->setDataFormatter(new SimpleFormatter()); $this->collect_data = $collectData; - $this->name = 'views'; $this->templates = []; } From ef8f2fa23f20c0d1899a7a03b6ce7034ad708a5e Mon Sep 17 00:00:00 2001 From: pataar Date: Sat, 15 Oct 2022 00:05:55 +0200 Subject: [PATCH 071/404] style: fix the code style, and update the workflow (#1352) * style: fix the code style * add style permission * fix the workflow --- .github/workflows/fix-cs.yml | 9 ++++++--- src/Twig/Extension/Extension.php | 8 ++++++-- src/Twig/Node/Node.php | 8 ++++++-- src/Twig/TokenParser/TokenParser.php | 8 ++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/fix-cs.yml b/.github/workflows/fix-cs.yml index c92491dd9..3b6b49063 100644 --- a/.github/workflows/fix-cs.yml +++ b/.github/workflows/fix-cs.yml @@ -1,10 +1,13 @@ -name: Fix Codestyle +name: Fix Code Style on: push: branches: - master +permissions: + contents: write + jobs: fix-style: name: Fix Code Style @@ -20,7 +23,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 7.4 + php-version: 8.1 coverage: none tools: composer:v2 @@ -31,7 +34,7 @@ jobs: - run: composer fix-style continue-on-error: true - # Revert modifications so they don't get commited đŸ’¥ + # Revert modifications so they don't get committed đŸ’¥ - run: git checkout -- composer.json - uses: stefanzweifel/git-auto-commit-action@v4 diff --git a/src/Twig/Extension/Extension.php b/src/Twig/Extension/Extension.php index 282ecf03b..dda2a6171 100644 --- a/src/Twig/Extension/Extension.php +++ b/src/Twig/Extension/Extension.php @@ -4,7 +4,11 @@ // Maintain compatibility with Twig 2 and 3. if (class_exists('\Twig_Extension')) { - abstract class Extension extends \Twig_Extension {} + abstract class Extension extends \Twig_Extension + { + } } else { - abstract class Extension extends \Twig\Extension\AbstractExtension {} + abstract class Extension extends \Twig\Extension\AbstractExtension + { + } } diff --git a/src/Twig/Node/Node.php b/src/Twig/Node/Node.php index bf81c1b9e..f35ea7b7a 100644 --- a/src/Twig/Node/Node.php +++ b/src/Twig/Node/Node.php @@ -4,7 +4,11 @@ // Maintain compatibility with Twig 2 and 3. if (class_exists('\Twig_Node')) { - abstract class Node extends \Twig_Node {} + abstract class Node extends \Twig_Node + { + } } else { - abstract class Node extends \Twig\Node\Node {} + abstract class Node extends \Twig\Node\Node + { + } } diff --git a/src/Twig/TokenParser/TokenParser.php b/src/Twig/TokenParser/TokenParser.php index 4a0b6d1cb..2ff179628 100644 --- a/src/Twig/TokenParser/TokenParser.php +++ b/src/Twig/TokenParser/TokenParser.php @@ -4,7 +4,11 @@ // Maintain compatibility with Twig 2 and 3. if (class_exists('\Twig_TokenParser')) { - abstract class TokenParser extends \Twig_TokenParser {} + abstract class TokenParser extends \Twig_TokenParser + { + } } else { - abstract class TokenParser extends \Twig\TokenParser\AbstractTokenParser {} + abstract class TokenParser extends \Twig\TokenParser\AbstractTokenParser + { + } } From 430c52b3fe73d9aa3a6736eab57dfdb45d6d9648 Mon Sep 17 00:00:00 2001 From: pataar Date: Sat, 15 Oct 2022 00:06:45 +0200 Subject: [PATCH 072/404] fix(exception): use the correct typing for the 'addThrowable' method (#1351) --- src/LaravelDebugbar.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 1842aa5de..b3fedc39f 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -34,6 +34,7 @@ use DebugBar\Storage\PdoStorage; use DebugBar\Storage\RedisStorage; use Exception; +use Throwable; use Illuminate\Contracts\Foundation\Application; use Illuminate\Session\SessionManager; use Illuminate\Support\Str; @@ -635,7 +636,7 @@ public function addException(Exception $e) /** * Adds an exception to be profiled in the debug bar * - * @param Exception $e + * @param Throwable $e */ public function addThrowable($e) { From 74d71878f7dd79fa0b9a744f293201cfcea34851 Mon Sep 17 00:00:00 2001 From: Sergiy Petrov Date: Mon, 31 Oct 2022 15:06:00 +0200 Subject: [PATCH 073/404] Update run-tests.yml (#3) (#1357) test against php 8.1 --- .github/workflows/run-integration-tests.yml | 24 +++++++++++++++++---- .github/workflows/run-tests.yml | 4 +++- composer.json | 8 +++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 56759976d..81ad84f4e 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -18,13 +18,21 @@ jobs: COMPOSER_NO_INTERACTION: 1 strategy: matrix: - php: [8.0, 7.4, 7.3, 7.2] - lumen: [8.*, 7.*] + php: [8.1, 8.0, 7.4, 7.3, 7.2] + lumen: [9.*, 8.*, 7.*] exclude: - lumen: 8.* php: 7.2 + - lumen: 9.* + php: 7.2 + - lumen: 9.* + php: 7.3 + - lumen: 9.* + php: 7.4 - lumen: 7.* php: 8.0 + - lumen: 7.* + php: 8.1 name: P${{ matrix.php }} - Lumen${{ matrix.lumen }} steps: - name: Checkout code @@ -66,11 +74,19 @@ jobs: COMPOSER_NO_INTERACTION: 1 strategy: matrix: - php: [8.0, 7.4, 7.3, 7.2] - laravel: [8.*, 7.*] + php: [8.1, 8.0, 7.4, 7.3, 7.2] + laravel: [9.*, 8.*, 7.*] exclude: - laravel: 8.* php: 7.2 + - laravel: 9.* + php: 7.2 + - laravel: 9.* + php: 7.3 + - laravel: 9.* + php: 7.4 + - laravel: 7.* + php: 8.1 name: P${{ matrix.php }} - Laravel${{ matrix.laravel }} steps: - name: Checkout code diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6f10c965b..fea6a5a0d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - php: [8.0, 7.4, 7.3, 7.2] + php: [8.1, 8.0, 7.4, 7.3, 7.2] laravel: [9.*, 8.*, 7.*] dependency-version: [prefer-lowest, prefer-stable] exclude: @@ -31,6 +31,8 @@ jobs: php: 7.3 - laravel: 9.* php: 7.4 + - laravel: 7.* + php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index b911a5e3d..c5030ae3d 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ "require": { "php": ">=7.2.5", "maximebf/debugbar": "^1.17.2", - "illuminate/routing": "^7|^8|^9", - "illuminate/session": "^7|^8|^9", - "illuminate/support": "^7|^8|^9", + "illuminate/routing": "^7|^8.67|^9", + "illuminate/session": "^7|^8.67|^9", + "illuminate/support": "^7|^8.67|^9", "symfony/finder": "^5|^6" }, "require-dev": { "mockery/mockery": "^1.3.3", "orchestra/testbench-dusk": "^5|^6|^7", - "phpunit/phpunit": "^8.5|^9.0", + "phpunit/phpunit": "^8.5.30|^9.0", "squizlabs/php_codesniffer": "^3.5" }, "autoload": { From 44f66c9266c9fe89a0ffe3c95537f27548bff856 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Mon, 31 Oct 2022 08:57:06 -0500 Subject: [PATCH 074/404] PHP 8.2 Build (#1353) * PHP 8.2 Build * Update run-tests.yml * Update run-tests.yml Co-authored-by: Barry vd. Heuvel --- .github/workflows/run-tests.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index fea6a5a0d..12a8f811e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,19 +19,23 @@ jobs: strategy: matrix: - php: [8.1, 8.0, 7.4, 7.3, 7.2] - laravel: [9.*, 8.*, 7.*] + php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2] + laravel: [^9, ^8, ^7] dependency-version: [prefer-lowest, prefer-stable] exclude: - - laravel: 8.* + - laravel: ^7* + php: 8.1 + - laravel: ^7 + php: 8.2 + - laravel: ^8 php: 7.2 - - laravel: 9.* + - laravel: ^9 php: 7.2 - - laravel: 9.* + - laravel: ^9 php: 7.3 - - laravel: 9.* + - laravel: ^9 php: 7.4 - - laravel: 7.* + - laravel: ^7 php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} @@ -50,7 +54,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:>=2.62.1" --no-interaction --no-update composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress - name: Update Dusk Chromedriver From 9bb3381172922b2fb8eaf3170079a440415d313c Mon Sep 17 00:00:00 2001 From: pafernandez-oesia <96843912+pafernandez-oesia@users.noreply.github.com> Date: Mon, 31 Oct 2022 15:50:44 +0100 Subject: [PATCH 075/404] Fix dark mode styles #1123 (#1334) * Fix #1123 Add selector for ListWidget styles in dark mode. * Fix label style for ListWidget --- src/Resources/laravel-debugbar-dark-mode.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Resources/laravel-debugbar-dark-mode.css b/src/Resources/laravel-debugbar-dark-mode.css index 69baff9b9..50f7832d2 100644 --- a/src/Resources/laravel-debugbar-dark-mode.css +++ b/src/Resources/laravel-debugbar-dark-mode.css @@ -24,6 +24,8 @@ div.phpdebugbar-openhandler, div.phpdebugbar div.phpdebugbar-header > div > *, div.phpdebugbar ul.phpdebugbar-widgets-timeline li span.phpdebugbar-widgets-label, div.phpdebugbar ul.phpdebugbar-widgets-timeline li span.phpdebugbar-widgets-collector, +div.phpdebugbar ul.phpdebugbar-widgets-list li.phpdebugbar-widgets-list-item, +div.phpdebugbar ul.phpdebugbar-widgets-list li span.phpdebugbar-widgets-label, div.phpdebugbar code.phpdebugbar-widgets-sql span.hljs-keyword, div.phpdebugbar-openhandler .phpdebugbar-openhandler-header, div.phpdebugbar-openhandler .phpdebugbar-openhandler-header a { From 615ce4732d0d5c828bd060d1e2dc9b65f7369509 Mon Sep 17 00:00:00 2001 From: Mike Wink <85063626+mikewink@users.noreply.github.com> Date: Mon, 31 Oct 2022 15:51:34 +0100 Subject: [PATCH 076/404] Update Querycollector with SQLite Explain support (#1315) This adds support for SQLite EXPLAIN statement. There is no support for EXPLAIN QUERY PLAN yet, as this would require more changes to the package config. --- src/DataCollector/QueryCollector.php | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index fbeaf81b5..f11695c65 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -511,6 +511,41 @@ public function collect() 'type' => 'explain', ]; } + } elseif ($query['driver'] === 'sqlite') { + $vmi = ''; + $vmi .= " + + + + + + + + + "; + + foreach ($query['explain'] as $explain) { + $vmi .= " + + + + + + + + + "; + } + + $vmi .= '
AddressOpcodeP1P2P3P4P5Comment
{$explain->addr}{$explain->opcode}{$explain->p1}{$explain->p2}{$explain->p3}{$explain->p4}{$explain->p5}{$explain->comment}
'; + + $statements[] = [ + 'sql' => " - EXPLAIN:", + 'type' => 'explain', + 'params' => [ + 'Virtual Machine Instructions' => $vmi, + ] + ]; } else { foreach ($query['explain'] as $explain) { $statements[] = [ From bfdfbafb87fb4aae273a95a67c905aed29ca8c50 Mon Sep 17 00:00:00 2001 From: Lee Taylor <48020564+leettaylor@users.noreply.github.com> Date: Mon, 31 Oct 2022 14:52:28 +0000 Subject: [PATCH 077/404] Add config option to exclude paths from ViewCollector (#1327) * Add views.exclude_paths config option * Pass through excludePaths to the ViewCollector * Exclude files matching paths from view collector * Use strpos for check --- config/debugbar.php | 1 + src/DataCollector/ViewCollector.php | 11 ++++++++++- src/LaravelDebugbar.php | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/debugbar.php b/config/debugbar.php index fe3b192d7..137b2b080 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -206,6 +206,7 @@ 'views' => [ 'timeline' => false, // Add the views to the timeline (Experimental) 'data' => false, //Note: Can slow down the application, because the data can be quite large.. + 'exclude_paths' => [], // Add the paths which you don't want to appear in the views ], 'route' => [ 'label' => true, // show complete route on bar diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index e72097d8f..e21b90a45 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -10,17 +10,20 @@ class ViewCollector extends TwigCollector { protected $templates = []; protected $collect_data; + protected $exclude_paths; /** * Create a ViewCollector * * @param bool $collectData Collects view data when tru + * @param string[] $excludePaths Paths to exclude from collection */ - public function __construct($collectData = true) + public function __construct($collectData = true, $excludePaths = []) { $this->setDataFormatter(new SimpleFormatter()); $this->collect_data = $collectData; $this->templates = []; + $this->exclude_paths = $excludePaths; } public function getName() @@ -69,6 +72,12 @@ public function addView(View $view) $path = ''; } + foreach ($this->exclude_paths as $excludePath) { + if (strpos($path, $excludePath) !== false) { + return; + } + } + if (!$this->collect_data) { $params = array_keys($view->getData()); } else { diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index b3fedc39f..f44040769 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -205,7 +205,8 @@ function () use ($debugbar, $startTime) { if ($this->shouldCollect('views', true) && isset($this->app['events'])) { try { $collectData = $this->app['config']->get('debugbar.options.views.data', true); - $this->addCollector(new ViewCollector($collectData)); + $excludePaths = $this->app['config']->get('debugbar.options.views.exclude_paths', []); + $this->addCollector(new ViewCollector($collectData, $excludePaths)); $this->app['events']->listen( 'composing:*', function ($view, $data = []) use ($debugbar) { From 06782a09cb288dd6cf306f70c237e804c0962a16 Mon Sep 17 00:00:00 2001 From: Dave James Miller Date: Mon, 31 Oct 2022 14:55:20 +0000 Subject: [PATCH 078/404] Delete changelog.md (#1302) --- changelog.md | 86 ---------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 changelog.md diff --git a/changelog.md b/changelog.md deleted file mode 100644 index 072b56141..000000000 --- a/changelog.md +++ /dev/null @@ -1,86 +0,0 @@ -# Changelog for Laravel Debugbar - -## 1.8.4 (2014-10-31) - -- Add Redis/PDO storage options - -## 1.8.3 (2014-11-23) - -- Base EventCollector on TimeData Collector - -## 1.8.2 (2014-11-18) - -- Use XHR handler instead of jQuery handler - -## 1.8.1 (2014-11-14) - -- Fix compatability with Symfony 2.3 (Laravel 4.) - -## 1.8.0 (2014-10-31) - -- Fix L5 compatability -- add hints + explain options to QueryLogger -- update to Debugbar 1.10.x -- new ViewCollector layout with more information - -## 1.7.7 (2014-09-15) - -- Make it compatible with Laravel 5.0-dev -- Allow anonymous function as `enabled` setting (for IP checks etc) -- Escape query bindings, to prevent executing of scripts/html - -## 1.7.6 (2014-09-12) - -- Fix reflash bug -- Fix caching of debugbar assets - -## 1.7.5 (2014-09-12) - -- Reflash data for all debugbar requests - -## 1.7.4 (2014-09-08) - -- Rename assets routes to prevent Nginx conflicts - -## 1.7.3 (2014-09-05) - -- Add helper functions (debug(), add/start/stop_measure() and measure() -- Collect data on responses that are not redirect/ajax/html also. - -## 1.7.2 (2014-09-04) - -- Fix 4.0 compatibility (problem with Controller namespace) -- Give deprecation notice instead of publishing assets. - -## 1.7.1 (2014-09-03) - -- Deprecated `debugbar:publish` command in favor of AssetController -- Fixed issue with detecting absolute paths in Windows - -## 1.7.0 (2014-09-03) - -- Use AssetController instead of publishing assets to the public folder. -- Inline fonts + images to base64 Data-URI -- Use PSR-4 file structure - -## 1.6.8 (2014-08-27) - -- Change OpenHandler layout -- Add backtrace option for query origin - -## 1.6.7 (2014-08-09) - -- Add Twig extensions for better integration with rcrowe/TwigBridge - -## 1.6.6 (2014-07-08) - -- Check if Requests wantsJSON instead of only isXmlHttpRequest -- Make sure closure for timing is run, even when disabled - -## 1.6.5 (2014-06-24) - -- Add Laravel style - -## 1.6.4 (2014-06-15) - -- Work on non-UTF-8 handling \ No newline at end of file From ea7695f3949aba7e731b0f982ad6ac42d65c5377 Mon Sep 17 00:00:00 2001 From: Faraz Samapoor Date: Mon, 31 Oct 2022 18:29:31 +0330 Subject: [PATCH 079/404] Removes repeated "and" from config file. (#1358) --- config/debugbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/debugbar.php b/config/debugbar.php index 137b2b080..4581a9dce 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -92,7 +92,7 @@ | Vendor files are included by default, but can be set to false. | This can also be set to 'js' or 'css', to only include javascript or css vendor files. | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files) - | and for js: jquery and and highlight.js + | and for js: jquery and highlight.js | So if you want syntax highlighting, set it to true. | jQuery is set to not conflict with existing jQuery scripts. | From 7a7315f99c69181d9db4030117850e9aa655ebd4 Mon Sep 17 00:00:00 2001 From: Ferdous Anam <40851904+ferdousanam@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:00:07 +0600 Subject: [PATCH 080/404] View Editor Link (#1359) --- src/DataCollector/ViewCollector.php | 70 ++++++++++++++++++++- src/JavascriptRenderer.php | 1 + src/Resources/templates/widget.js | 98 +++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/Resources/templates/widget.js diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index e21b90a45..ef9ac3d8f 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -5,6 +5,7 @@ use Barryvdh\Debugbar\DataFormatter\SimpleFormatter; use DebugBar\Bridge\Twig\TwigCollector; use Illuminate\View\View; +use InvalidArgumentException; class ViewCollector extends TwigCollector { @@ -12,6 +13,30 @@ class ViewCollector extends TwigCollector protected $collect_data; protected $exclude_paths; + /** + * A list of known editor strings. + * + * @var array + */ + protected $editors = [ + 'sublime' => 'subl://open?url=file://%file&line=%line', + 'textmate' => 'txmt://open?url=file://%file&line=%line', + 'emacs' => 'emacs://open?url=file://%file&line=%line', + 'macvim' => 'mvim://open/?url=file://%file&line=%line', + 'phpstorm' => 'phpstorm://open?file=%file&line=%line', + 'idea' => 'idea://open?file=%file&line=%line', + 'vscode' => 'vscode://file/%file:%line', + 'vscode-insiders' => 'vscode-insiders://file/%file:%line', + 'vscode-remote' => 'vscode://vscode-remote/%file:%line', + 'vscode-insiders-remote' => 'vscode-insiders://vscode-remote/%file:%line', + 'vscodium' => 'vscodium://file/%file:%line', + 'nova' => 'nova://core/open/file?filename=%file&line=%line', + 'xdebug' => 'xdebug://%file@%line', + 'atom' => 'atom://core/open/file?filename=%file&line=%line', + 'espresso' => 'x-espresso://open?filepath=%file&lines=%line', + 'netbeans' => 'netbeans://open/?f=%file:%line', + ]; + /** * Create a ViewCollector * @@ -36,7 +61,7 @@ public function getWidgets() return [ 'views' => [ 'icon' => 'leaf', - 'widget' => 'PhpDebugBar.Widgets.TemplatesWidget', + 'widget' => 'PhpDebugBar.Widgets.LaravelViewTemplatesWidget', 'map' => 'views', 'default' => '[]' ], @@ -47,6 +72,36 @@ public function getWidgets() ]; } + /** + * Get the editor href for a given file and line, if available. + * + * @param string $filePath + * @param int $line + * + * @throws InvalidArgumentException If editor resolver does not return a string + * + * @return null|string + */ + protected function getEditorHref($filePath, $line) + { + if (empty(config('debugbar.editor'))) { + return null; + } + + if (empty($this->editors[config('debugbar.editor')])) { + throw new InvalidArgumentException( + 'Unknown editor identifier: ' . config('debugbar.editor') . '. Known editors:' . + implode(', ', array_keys($this->editors)) + ); + } + + $filePath = $this->replaceSitesPath($filePath); + + $url = str_replace(['%file', '%line'], [$filePath, $line], $this->editors[config('debugbar.editor')]); + + return $url; + } + /** * Add a View instance to the Collector * @@ -93,6 +148,7 @@ public function addView(View $view) 'param_count' => count($params), 'params' => $params, 'type' => $type, + 'editorLink' => $this->getEditorHref($view->getPath(), 0), ]; if ($this->getXdebugLink($path)) { @@ -111,4 +167,16 @@ public function collect() 'templates' => $templates, ]; } + + /** + * Replace remote path + * + * @param string $filePath + * + * @return string + */ + protected function replaceSitesPath($filePath) + { + return str_replace(config('debugbar.remote_sites_path'), config('debugbar.local_sites_path'), $filePath); + } } diff --git a/src/JavascriptRenderer.php b/src/JavascriptRenderer.php index 428b15a9d..9c967909e 100644 --- a/src/JavascriptRenderer.php +++ b/src/JavascriptRenderer.php @@ -23,6 +23,7 @@ public function __construct(DebugBar $debugBar, $baseUrl = null, $basePath = nul $this->cssVendors['fontawesome'] = __DIR__ . '/Resources/vendor/font-awesome/style.css'; $this->jsFiles['laravel-sql'] = __DIR__ . '/Resources/sqlqueries/widget.js'; $this->jsFiles['laravel-cache'] = __DIR__ . '/Resources/cache/widget.js'; + $this->jsFiles['laravel-view'] = __DIR__ . '/Resources/templates/widget.js'; $theme = config('debugbar.theme', 'auto'); switch ($theme) { diff --git a/src/Resources/templates/widget.js b/src/Resources/templates/widget.js new file mode 100644 index 000000000..bb39188b5 --- /dev/null +++ b/src/Resources/templates/widget.js @@ -0,0 +1,98 @@ +(function($) { + + var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-'); + + /** + * Widget for the displaying templates data + * + * Options: + * - data + */ + var TemplatesWidget = PhpDebugBar.Widgets.LaravelViewTemplatesWidget = PhpDebugBar.Widget.extend({ + + className: csscls('templates'), + + render: function() { + this.$status = $('
').addClass(csscls('status')).appendTo(this.$el); + + this.$list = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, tpl) { + $('').addClass(csscls('name')).text(tpl.name).appendTo(li); + + if (typeof tpl.editorLink !== 'undefined' && tpl.editorLink !== null) { + $('') + .addClass(csscls('editor-link')) + .on('click', function (event) { + event.stopPropagation(); + }) + .appendTo(li); + } + if (typeof tpl.xdebug_link !== 'undefined' && tpl.xdebug_link !== null) { + if (tpl.xdebug_link.ajax) { + $('').on('click', function () { + $.ajax(tpl.xdebug_link.url); + }).addClass(csscls('editor-link')).appendTo(li); + } else { + $('').addClass(csscls('editor-link')).appendTo(li); + } + } + if (tpl.render_time_str) { + $('').addClass(csscls('render-time')).text(tpl.render_time_str).appendTo(li); + } + if (tpl.memory_str) { + $('').addClass(csscls('memory')).text(tpl.memory_str).appendTo(li); + } + if (typeof(tpl.param_count) != 'undefined') { + $('').addClass(csscls('param-count')).text(tpl.param_count).appendTo(li); + } + if (typeof(tpl.type) != 'undefined' && tpl.type) { + $('').addClass(csscls('type')).text(tpl.type).appendTo(li); + } + if (tpl.params && !$.isEmptyObject(tpl.params)) { + var table = $('
Params
').addClass(csscls('params')).appendTo(li); + for (var key in tpl.params) { + if (typeof tpl.params[key] !== 'function') { + table.append('' + key + '
' + tpl.params[key] + '
'); + } + } + li.css('cursor', 'pointer').click(function() { + if (table.is(':visible')) { + table.hide(); + } else { + table.show(); + } + }); + } + }}); + this.$list.$el.appendTo(this.$el); + this.$callgraph = $('
').addClass(csscls('callgraph')).appendTo(this.$el); + + this.bindAttr('data', function(data) { + this.$list.set('data', data.templates); + this.$status.empty(); + this.$callgraph.empty(); + + var sentence = data.sentence || "templates were rendered"; + $('').text(data.nb_templates + " " + sentence).appendTo(this.$status); + + if (data.accumulated_render_time_str) { + this.$status.append($('').addClass(csscls('render-time')).text(data.accumulated_render_time_str)); + } + if (data.memory_usage_str) { + this.$status.append($('').addClass(csscls('memory')).text(data.memory_usage_str)); + } + if (data.nb_blocks > 0) { + $('
').text(data.nb_blocks + " blocks were rendered").appendTo(this.$status); + } + if (data.nb_macros > 0) { + $('
').text(data.nb_macros + " macros were rendered").appendTo(this.$status); + } + if (typeof data.callgraph !== 'undefined') { + this.$callgraph.html(data.callgraph); + } + }); + } + + }); + +})(PhpDebugBar.$); From 7590abc024d9b6108ba9e69e29b94f4679b5f283 Mon Sep 17 00:00:00 2001 From: Aldo Karendra Date: Tue, 10 Jan 2023 18:09:53 +0700 Subject: [PATCH 081/404] fix: deprecated dynamic property on PHP 8.2 (#1370) * fix: deprecated dynamic property on PHP 8.2 Fixing deprecated on PHP 8.2 : - Creation of dynamic property Barryvdh\Debugbar\DataFormatter\QueryFormatter::$cloner is deprecated Reference : https://php.watch/versions/8.2/dynamic-properties-deprecated * fix: deprecated dynamic property on PHP 8.2 Fixing deprecated on PHP 8.2 : - Creation of dynamic property Barryvdh\Debugbar\DataFormatter\SimpleFormatter::$cloner is deprecated Reference : https://php.watch/versions/8.2/dynamic-properties-deprecated * fix: deprecated dynamic property on PHP 8.2 --- src/DataFormatter/QueryFormatter.php | 1 + src/DataFormatter/SimpleFormatter.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/DataFormatter/QueryFormatter.php b/src/DataFormatter/QueryFormatter.php index f8574f5d6..dc49853e6 100644 --- a/src/DataFormatter/QueryFormatter.php +++ b/src/DataFormatter/QueryFormatter.php @@ -4,6 +4,7 @@ use DebugBar\DataFormatter\DataFormatter; +#[\AllowDynamicProperties] class QueryFormatter extends DataFormatter { /** diff --git a/src/DataFormatter/SimpleFormatter.php b/src/DataFormatter/SimpleFormatter.php index 9825e9133..369e1be3f 100644 --- a/src/DataFormatter/SimpleFormatter.php +++ b/src/DataFormatter/SimpleFormatter.php @@ -9,6 +9,7 @@ * * @see https://github.com/symfony/symfony/blob/v3.4.4/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php */ +#[\AllowDynamicProperties] class SimpleFormatter extends DataFormatter { /** From 47f5852dba2ae586509ea305acec935d9001a971 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Thu, 12 Jan 2023 10:13:32 -0500 Subject: [PATCH 082/404] Laravel 10.x Support (#1380) --- .github/workflows/run-tests.yml | 14 ++++++++++---- composer.json | 8 ++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 12a8f811e..48111fe4f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,10 +20,10 @@ jobs: strategy: matrix: php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2] - laravel: [^9, ^8, ^7] + laravel: [^10, ^9, ^8, ^7] dependency-version: [prefer-lowest, prefer-stable] exclude: - - laravel: ^7* + - laravel: ^7 php: 8.1 - laravel: ^7 php: 8.2 @@ -35,8 +35,14 @@ jobs: php: 7.3 - laravel: ^9 php: 7.4 - - laravel: ^7 - php: 8.1 + - laravel: ^10 + php: 7.2 + - laravel: ^10 + php: 7.3 + - laravel: ^10 + php: 7.4 + - laravel: ^10 + php: 8.0 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index c5030ae3d..5e626ee15 100644 --- a/composer.json +++ b/composer.json @@ -12,14 +12,14 @@ "require": { "php": ">=7.2.5", "maximebf/debugbar": "^1.17.2", - "illuminate/routing": "^7|^8.67|^9", - "illuminate/session": "^7|^8.67|^9", - "illuminate/support": "^7|^8.67|^9", + "illuminate/routing": "^7|^8.67|^9|^10", + "illuminate/session": "^7|^8.67|^9|^10", + "illuminate/support": "^7|^8.67|^9|^10", "symfony/finder": "^5|^6" }, "require-dev": { "mockery/mockery": "^1.3.3", - "orchestra/testbench-dusk": "^5|^6|^7", + "orchestra/testbench-dusk": "^5|^6|^7|^8", "phpunit/phpunit": "^8.5.30|^9.0", "squizlabs/php_codesniffer": "^3.5" }, From 6e922688caabc831be67b0b237fd3b1f3928d5dd Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 1 Feb 2023 17:22:49 +0100 Subject: [PATCH 083/404] Debugbar for Laravel --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 54eaafba1..5bac5ccd9 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -## Laravel Debugbar +## Debugbar for Laravel ![Unit Tests](https://github.com/barryvdh/laravel-debugbar/workflows/Unit%20Tests/badge.svg) [![Packagist License](https://poser.pugx.org/barryvdh/laravel-debugbar/license.png)](http://choosealicense.com/licenses/mit/) [![Latest Stable Version](https://poser.pugx.org/barryvdh/laravel-debugbar/version.png)](https://packagist.org/packages/barryvdh/laravel-debugbar) From a67e03c63dce7d512ccd98a4e6031c7af47e88d3 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sat, 4 Feb 2023 16:30:33 +0100 Subject: [PATCH 084/404] Add editorconfig, fix style, skip resources (#1385) * Add editorconfig, fix style, skip resources * Minimum dev --- .editorconfig | 12 ++++++++++++ .github/workflows/run-integration-tests.yml | 2 ++ composer.json | 4 ++-- src/DataCollector/QueryCollector.php | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..2e7acaf5d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 81ad84f4e..b881bef14 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -51,6 +51,7 @@ jobs: run: | composer create-project --prefer-dist laravel/lumen:${{ matrix.lumen }} --no-progress sample cd sample + composer config minimum-stability dev composer update --prefer-stable --prefer-dist --no-progress - name: Add package from source run: | @@ -105,6 +106,7 @@ jobs: run: | composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} --no-progress sample cd sample + composer config minimum-stability dev composer update --prefer-stable --prefer-dist --no-progress - name: Add package from source run: | diff --git a/composer.json b/composer.json index 5e626ee15..5313e1db4 100644 --- a/composer.json +++ b/composer.json @@ -52,8 +52,8 @@ } }, "scripts": { - "check-style": "phpcs -p --standard=PSR12 config/ src/ tests/", - "fix-style": "phpcbf -p --standard=PSR12 config/ src/ tests/", + "check-style": "phpcs -p --standard=PSR12 config/ src/ tests/ --ignore=src/Resources/* ", + "fix-style": "phpcbf -p --standard=PSR12 config/ src/ tests/ --ignore=src/Resources*", "test": "phpunit" } } diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index f11695c65..153834b8a 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -545,7 +545,7 @@ public function collect() 'params' => [ 'Virtual Machine Instructions' => $vmi, ] - ]; + ]; } else { foreach ($query['explain'] as $explain) { $statements[] = [ From 06b16eece7194e8a5addd628942552e7c6d03d68 Mon Sep 17 00:00:00 2001 From: Geoffrey Rose Date: Sat, 4 Feb 2023 07:33:08 -0800 Subject: [PATCH 085/404] font-size: initial; (#1381) --- src/Resources/laravel-debugbar.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index 424c6ad49..346e55cc0 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -13,6 +13,7 @@ div.phpdebugbar { div.phpdebugbar * { direction: ltr; + font-size: initial; text-align: left; } From 3dea98905873eb1dc93753f55494afaa1e3c432e Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 4 Feb 2023 18:33:21 +0300 Subject: [PATCH 086/404] Add db.slow_threshold to default config (#1375) --- config/debugbar.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/debugbar.php b/config/debugbar.php index 4581a9dce..5c4643cf7 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -198,7 +198,8 @@ 'types' => ['SELECT'], // Deprecated setting, is always only SELECT ], 'hints' => false, // Show hints for common mistakes - 'show_copy' => false, // Show copy button next to the query + 'show_copy' => false, // Show copy button next to the query, + 'slow_threshold' => false, // Only track queries that last longer than this time in ms ], 'mail' => [ 'full_log' => false, From 3001b7d43a46f75bd5d58d556da90de7b94f6b88 Mon Sep 17 00:00:00 2001 From: Huzaifa Saif Ur Rehman Date: Sat, 4 Feb 2023 20:34:08 +0500 Subject: [PATCH 087/404] feat: json_encode context with JSON_PRETTY_PRINT flag (#1374) --- src/LaravelDebugbar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index f44040769..5cf221095 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -260,7 +260,7 @@ function ($level, $message = null, $context = null) use ($logger) { try { $logMessage = (string) $message; if (mb_check_encoding($logMessage, 'UTF-8')) { - $logMessage .= (!empty($context) ? ' ' . json_encode($context) : ''); + $logMessage .= (!empty($context) ? ' ' . json_encode($context, JSON_PRETTY_PRINT) : ''); } else { $logMessage = "[INVALID UTF-8 DATA]"; } From c9fb100934bc51485df770d9a3f9ecce12b2ce6f Mon Sep 17 00:00:00 2001 From: Tom <26380378+azgooon@users.noreply.github.com> Date: Sat, 4 Feb 2023 15:34:21 +0000 Subject: [PATCH 088/404] Update ViewCollector.php (#1378) Fixes error: "Creation of dynamic property Barryvdh\Debugbar\DataCollector\ViewCollector::$name is deprecated" --- src/DataCollector/ViewCollector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index ef9ac3d8f..b0ae1baa4 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -9,6 +9,7 @@ class ViewCollector extends TwigCollector { + protected $name; protected $templates = []; protected $collect_data; protected $exclude_paths; From 8aeccb1909a6c0ad8cbf935e751f927fa5e56fca Mon Sep 17 00:00:00 2001 From: Samuel Date: Sat, 4 Feb 2023 15:35:10 +0000 Subject: [PATCH 089/404] QueryCollector: Exception -> Throwable (#1366) --- src/DataCollector/QueryCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 153834b8a..f07aa3bf7 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -134,7 +134,7 @@ public function addQuery($query, $bindings, $time, $connection) $pdo = null; try { $pdo = $connection->getPdo(); - } catch (\Exception $e) { + } catch (\Throwable $e) { // ignore error for non-pdo laravel drivers } $bindings = $connection->prepareBindings($bindings); From eb01216141e62433178c52b0cbdb785b45bae871 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sat, 4 Feb 2023 16:47:28 +0100 Subject: [PATCH 090/404] Drop lower PHP/Laravel versions (#1386) * Drop lower PHP versions * Dev stability * Fix versions --- .github/workflows/run-integration-tests.yml | 36 ++++++--------------- .github/workflows/run-tests.yml | 22 ++----------- composer.json | 10 +++--- 3 files changed, 16 insertions(+), 52 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index b881bef14..49877b8fe 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -18,21 +18,11 @@ jobs: COMPOSER_NO_INTERACTION: 1 strategy: matrix: - php: [8.1, 8.0, 7.4, 7.3, 7.2] - lumen: [9.*, 8.*, 7.*] + php: [8.2, 8.1, 8.0] + lumen: [9.*] exclude: - - lumen: 8.* - php: 7.2 - - lumen: 9.* - php: 7.2 - - lumen: 9.* - php: 7.3 - - lumen: 9.* - php: 7.4 - - lumen: 7.* + - lumen: 10.* php: 8.0 - - lumen: 7.* - php: 8.1 name: P${{ matrix.php }} - Lumen${{ matrix.lumen }} steps: - name: Checkout code @@ -49,7 +39,7 @@ jobs: - name: Install dependencies run: | - composer create-project --prefer-dist laravel/lumen:${{ matrix.lumen }} --no-progress sample + composer create-project --prefer-dist laravel/lumen:${{ matrix.lumen }} --stability=dev --no-progress sample cd sample composer config minimum-stability dev composer update --prefer-stable --prefer-dist --no-progress @@ -75,19 +65,11 @@ jobs: COMPOSER_NO_INTERACTION: 1 strategy: matrix: - php: [8.1, 8.0, 7.4, 7.3, 7.2] - laravel: [9.*, 8.*, 7.*] + php: [8.2, 8.1, 8.0] + laravel: [10.*, 9.*] exclude: - - laravel: 8.* - php: 7.2 - - laravel: 9.* - php: 7.2 - - laravel: 9.* - php: 7.3 - - laravel: 9.* - php: 7.4 - - laravel: 7.* - php: 8.1 + - laravel: 10.* + php: 8.0 name: P${{ matrix.php }} - Laravel${{ matrix.laravel }} steps: - name: Checkout code @@ -104,7 +86,7 @@ jobs: - name: Install dependencies run: | - composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} --no-progress sample + composer create-project --prefer-dist laravel/laravel:${{ matrix.laravel }} --stability=dev --no-progress sample cd sample composer config minimum-stability dev composer update --prefer-stable --prefer-dist --no-progress diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 48111fe4f..f42ee34bf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -19,28 +19,10 @@ jobs: strategy: matrix: - php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2] - laravel: [^10, ^9, ^8, ^7] + php: [8.2, 8.1, 8.0] + laravel: [^10, ^9] dependency-version: [prefer-lowest, prefer-stable] exclude: - - laravel: ^7 - php: 8.1 - - laravel: ^7 - php: 8.2 - - laravel: ^8 - php: 7.2 - - laravel: ^9 - php: 7.2 - - laravel: ^9 - php: 7.3 - - laravel: ^9 - php: 7.4 - - laravel: ^10 - php: 7.2 - - laravel: ^10 - php: 7.3 - - laravel: ^10 - php: 7.4 - laravel: ^10 php: 8.0 diff --git a/composer.json b/composer.json index 5313e1db4..4312ed4ab 100644 --- a/composer.json +++ b/composer.json @@ -10,12 +10,12 @@ } ], "require": { - "php": ">=7.2.5", + "php": "^8.0", "maximebf/debugbar": "^1.17.2", - "illuminate/routing": "^7|^8.67|^9|^10", - "illuminate/session": "^7|^8.67|^9|^10", - "illuminate/support": "^7|^8.67|^9|^10", - "symfony/finder": "^5|^6" + "illuminate/routing": "^9|^10", + "illuminate/session": "^9|^10", + "illuminate/support": "^9|^10", + "symfony/finder": "^6" }, "require-dev": { "mockery/mockery": "^1.3.3", From 5d4ee5c21ede2a3f7ae092937aa2cff828fc1daf Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 20 Feb 2023 11:41:14 +0300 Subject: [PATCH 091/404] Show only duplicated queries (#1394) --- src/Resources/sqlqueries/widget.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Resources/sqlqueries/widget.js b/src/Resources/sqlqueries/widget.js index 988dc2da9..ebed4f08d 100644 --- a/src/Resources/sqlqueries/widget.js +++ b/src/Resources/sqlqueries/widget.js @@ -259,6 +259,24 @@ if (duplicate) { t.append(", " + duplicate + " of which were duplicated"); t.append(", " + (data.nb_statements - duplicate) + " unique"); + + // add toggler for displaying only duplicated queries + var duplicatedText = "Show only duplicated"; + var allText = "Show All"; + var id = "phpdebugbar-show-duplicates"; + t.append(". " + duplicatedText + ""); + + $(".phpdebugbar #" + id).click(function () { + var $this = $(this); + $this.toggleClass("shown_duplicated"); + $this.text($this.hasClass("shown_duplicated") ? allText : duplicatedText); + $(".phpdebugbar-widgets-sqlqueries .phpdebugbar-widgets-list-item") + .not(".phpdebugbar-widgets-sql-duplicate") + .toggle(); + + return false; + }); + } if (data.accumulated_duration_str) { this.$status.append($('').addClass(csscls('duration')).text(data.accumulated_duration_str)); From a84a666a6e9251d97e587105331ddee3857bd98b Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 21 Feb 2023 14:31:53 +0100 Subject: [PATCH 092/404] Revert "font-size: initial; (#1381)" (#1395) This reverts commit 06b16eece7194e8a5addd628942552e7c6d03d68. --- src/Resources/laravel-debugbar.css | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index 346e55cc0..424c6ad49 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -13,7 +13,6 @@ div.phpdebugbar { div.phpdebugbar * { direction: ltr; - font-size: initial; text-align: left; } From e3c7995370e417509c4a261439ffb64396107a32 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 21 Feb 2023 15:15:44 +0100 Subject: [PATCH 093/404] Fix restore btn styling (#1396) --- src/Resources/laravel-debugbar.css | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index 424c6ad49..3d595265d 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -13,6 +13,7 @@ div.phpdebugbar { div.phpdebugbar * { direction: ltr; + text-align: left; } @@ -154,7 +155,7 @@ div.phpdebugbar-openhandler table td a { div.phpdebugbar-resize-handle { display: block!important; height: 3px; - margin-top: -4px; + margin-top: -3px; width: 100%; background: none; cursor: ns-resize; @@ -218,11 +219,9 @@ div.phpdebugbar-body { div.phpdebugbar-header { min-height: 30px; line-height: 20px; - padding-left: 39px; text-shadow: 1px 1px #FFF; } -div.phpdebugbar-header, a.phpdebugbar-restore-btn, div.phpdebugbar-openhandler .phpdebugbar-openhandler-header { background: #f5f5f5 url(data:image/png;base64,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) no-repeat 5px 3px; @@ -258,10 +257,15 @@ div.phpdebugbar-openhandler-header { a.phpdebugbar-restore-btn { border-right-color: #ddd!important; - height: 20px; + height: 22px; width: 23px; background-position: center; background-size: 21px; + background-color: white; +} + +.phpdebugbar:not(.phpdebugbar-closed) a.phpdebugbar-restore-btn { + border-right: none; } div.phpdebugbar-header > div > * { @@ -424,6 +428,7 @@ a.phpdebugbar-tab:hover, span.phpdebugbar-indicator:hover, a.phpdebugbar-indicator:hover, a.phpdebugbar-close-btn:hover, +a.phpdebugbar-restore-btn:hover, a.phpdebugbar-minimize-btn:hover, a.phpdebugbar-maximize-btn:hover, a.phpdebugbar-open-btn:hover { From 5db4f7d9524ea4cca009bc44aab89a9bb443bc20 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 21 Feb 2023 14:16:55 +0000 Subject: [PATCH 094/404] Update LaravelDebugbar.php (#1391) Fix Lumen / Illuminate 9 version detection --- src/LaravelDebugbar.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 5cf221095..54e827641 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -103,6 +103,9 @@ public function __construct($app = null) $this->app = $app; $this->version = $app->version(); $this->is_lumen = Str::contains($this->version, 'Lumen'); + if ($this->is_lumen) { + $this->version = Str::betweenFirst($app->version(), '(', ')'); + } } /** From f217b9022a0270bdd59061fd0b3990ee2d007559 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 21 Feb 2023 15:20:06 +0100 Subject: [PATCH 095/404] Update branch alias --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4312ed4ab..10b871c66 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "prefer-stable": true, "extra": { "branch-alias": { - "dev-master": "3.6-dev" + "dev-master": "3.8-dev" }, "laravel": { "providers": [ From 8548ee32a3325f2b3e71b105065a4394f9604f86 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 21 Feb 2023 15:20:45 +0100 Subject: [PATCH 096/404] Bump required version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 10b871c66..f1dc1ee46 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": "^8.0", - "maximebf/debugbar": "^1.17.2", + "maximebf/debugbar": "^1.18.2", "illuminate/routing": "^9|^10", "illuminate/session": "^9|^10", "illuminate/support": "^9|^10", From aff3235fecb4104203b1e62c32239c56530eee32 Mon Sep 17 00:00:00 2001 From: G4Zz0L1 Date: Tue, 21 Feb 2023 15:21:02 +0100 Subject: [PATCH 097/404] Update Debugbar to include autoshow setting (#1393) I think that's a valid point to include, due to the fact that in a lot of software with the autoshow set to true it's impossible to use the debugbar. I'm in Laravel Nova right now, every time a notification ajax gets sent, the request I'm debugging gets removed by that setting. I've tried to add a middleware to enable that setting, but it breaks other things in beetween. Right now this it's the most polished solution. Let me know if it's ok! Thanks! --- src/LaravelDebugbar.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 54e827641..cfc6db4ad 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -897,9 +897,12 @@ function (&$item) { */ public function injectDebugbar(Response $response) { + $config = $this->app['config']; $content = $response->getContent(); $renderer = $this->getJavascriptRenderer(); + $autoShow = $config->get('debugbar.ajax_handler_auto_show', true); + $renderer->setAjaxHandlerAutoShow($autoShow); if ($this->getStorage()) { $openHandlerUrl = route('debugbar.openhandler'); $renderer->setOpenHandlerUrl($openHandlerUrl); From 92e31a5593b144328c5f7ab0f4390db5c8f82204 Mon Sep 17 00:00:00 2001 From: Faissal Wahabali Date: Wed, 22 Feb 2023 20:02:18 +0100 Subject: [PATCH 098/404] fix openhandler close icon position (#1398) --- src/Resources/laravel-debugbar.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index 3d595265d..20aa438c8 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -235,6 +235,7 @@ div.phpdebugbar-openhandler .phpdebugbar-openhandler-header { } div.phpdebugbar-openhandler .phpdebugbar-openhandler-header a { + display: flex; cursor: pointer; } From bdfe99cbbfaa880a5126732a2806a82380be0a89 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Wed, 10 May 2023 02:57:13 -0500 Subject: [PATCH 099/404] (fix) upgrade find view from hash (#1415) --- src/DataCollector/QueryCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index f07aa3bf7..8765a2539 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -393,7 +393,7 @@ protected function findViewFromHash($hash) } foreach ($property->getValue($finder) as $name => $path) { - if (sha1($path) == $hash || md5($path) == $hash) { + if (hash('xxh128', 'v2' . $path) == $hash || sha1('v2' . $path) == $hash) { return $name; } } From 8ac7c19d1af8ec4d0717279978fe3d477ac1a48d Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Mon, 3 Jul 2023 12:08:21 +0200 Subject: [PATCH 100/404] Check path in ViewCollector (#1424) --- src/DataCollector/ViewCollector.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index b0ae1baa4..2e898e15d 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -112,18 +112,17 @@ public function addView(View $view) { $name = $view->getName(); $path = $view->getPath(); + $type = ''; - if (!is_object($path)) { - if ($path) { - $path = ltrim(str_replace(base_path(), '', realpath($path)), '/'); - } + if ($path && is_string($path)) { + $path = ltrim(str_replace(base_path(), '', realpath($path)), '/'); if (substr($path, -10) == '.blade.php') { $type = 'blade'; } else { $type = pathinfo($path, PATHINFO_EXTENSION); } - } else { + } elseif (is_object($path)) { $type = get_class($view); $path = ''; } From 23f6174bff720bc4ecce767c07fe0a79a175eca8 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Thu, 6 Jul 2023 09:39:12 -0500 Subject: [PATCH 101/404] Fix php 8.0 - must be a valid hashing algorithm (#1419) --- src/DataCollector/QueryCollector.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 8765a2539..8824067c0 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -392,8 +392,10 @@ protected function findViewFromHash($hash) $this->reflection['viewfinderViews'] = $property; } + $xxh128Exists = in_array('xxh128', hash_algos()); + foreach ($property->getValue($finder) as $name => $path) { - if (hash('xxh128', 'v2' . $path) == $hash || sha1('v2' . $path) == $hash) { + if (($xxh128Exists && hash('xxh128', 'v2' . $path) == $hash) || sha1('v2' . $path) == $hash) { return $name; } } From cf4554d1dd7805a6a737dcb0f620c80d36850108 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Mon, 17 Jul 2023 10:04:38 -0500 Subject: [PATCH 102/404] Reverting #1359 unnecessary file (#1427) --- src/DataCollector/ViewCollector.php | 2 +- src/JavascriptRenderer.php | 1 - src/Resources/templates/widget.js | 98 ----------------------------- 3 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 src/Resources/templates/widget.js diff --git a/src/DataCollector/ViewCollector.php b/src/DataCollector/ViewCollector.php index 2e898e15d..1cefe5c7a 100644 --- a/src/DataCollector/ViewCollector.php +++ b/src/DataCollector/ViewCollector.php @@ -62,7 +62,7 @@ public function getWidgets() return [ 'views' => [ 'icon' => 'leaf', - 'widget' => 'PhpDebugBar.Widgets.LaravelViewTemplatesWidget', + 'widget' => 'PhpDebugBar.Widgets.TemplatesWidget', 'map' => 'views', 'default' => '[]' ], diff --git a/src/JavascriptRenderer.php b/src/JavascriptRenderer.php index 9c967909e..428b15a9d 100644 --- a/src/JavascriptRenderer.php +++ b/src/JavascriptRenderer.php @@ -23,7 +23,6 @@ public function __construct(DebugBar $debugBar, $baseUrl = null, $basePath = nul $this->cssVendors['fontawesome'] = __DIR__ . '/Resources/vendor/font-awesome/style.css'; $this->jsFiles['laravel-sql'] = __DIR__ . '/Resources/sqlqueries/widget.js'; $this->jsFiles['laravel-cache'] = __DIR__ . '/Resources/cache/widget.js'; - $this->jsFiles['laravel-view'] = __DIR__ . '/Resources/templates/widget.js'; $theme = config('debugbar.theme', 'auto'); switch ($theme) { diff --git a/src/Resources/templates/widget.js b/src/Resources/templates/widget.js deleted file mode 100644 index bb39188b5..000000000 --- a/src/Resources/templates/widget.js +++ /dev/null @@ -1,98 +0,0 @@ -(function($) { - - var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-'); - - /** - * Widget for the displaying templates data - * - * Options: - * - data - */ - var TemplatesWidget = PhpDebugBar.Widgets.LaravelViewTemplatesWidget = PhpDebugBar.Widget.extend({ - - className: csscls('templates'), - - render: function() { - this.$status = $('
').addClass(csscls('status')).appendTo(this.$el); - - this.$list = new PhpDebugBar.Widgets.ListWidget({ itemRenderer: function(li, tpl) { - $('').addClass(csscls('name')).text(tpl.name).appendTo(li); - - if (typeof tpl.editorLink !== 'undefined' && tpl.editorLink !== null) { - $('') - .addClass(csscls('editor-link')) - .on('click', function (event) { - event.stopPropagation(); - }) - .appendTo(li); - } - if (typeof tpl.xdebug_link !== 'undefined' && tpl.xdebug_link !== null) { - if (tpl.xdebug_link.ajax) { - $('').on('click', function () { - $.ajax(tpl.xdebug_link.url); - }).addClass(csscls('editor-link')).appendTo(li); - } else { - $('').addClass(csscls('editor-link')).appendTo(li); - } - } - if (tpl.render_time_str) { - $('').addClass(csscls('render-time')).text(tpl.render_time_str).appendTo(li); - } - if (tpl.memory_str) { - $('').addClass(csscls('memory')).text(tpl.memory_str).appendTo(li); - } - if (typeof(tpl.param_count) != 'undefined') { - $('').addClass(csscls('param-count')).text(tpl.param_count).appendTo(li); - } - if (typeof(tpl.type) != 'undefined' && tpl.type) { - $('').addClass(csscls('type')).text(tpl.type).appendTo(li); - } - if (tpl.params && !$.isEmptyObject(tpl.params)) { - var table = $('
Params
').addClass(csscls('params')).appendTo(li); - for (var key in tpl.params) { - if (typeof tpl.params[key] !== 'function') { - table.append('' + key + '
' + tpl.params[key] + '
'); - } - } - li.css('cursor', 'pointer').click(function() { - if (table.is(':visible')) { - table.hide(); - } else { - table.show(); - } - }); - } - }}); - this.$list.$el.appendTo(this.$el); - this.$callgraph = $('
').addClass(csscls('callgraph')).appendTo(this.$el); - - this.bindAttr('data', function(data) { - this.$list.set('data', data.templates); - this.$status.empty(); - this.$callgraph.empty(); - - var sentence = data.sentence || "templates were rendered"; - $('').text(data.nb_templates + " " + sentence).appendTo(this.$status); - - if (data.accumulated_render_time_str) { - this.$status.append($('').addClass(csscls('render-time')).text(data.accumulated_render_time_str)); - } - if (data.memory_usage_str) { - this.$status.append($('').addClass(csscls('memory')).text(data.memory_usage_str)); - } - if (data.nb_blocks > 0) { - $('
').text(data.nb_blocks + " blocks were rendered").appendTo(this.$status); - } - if (data.nb_macros > 0) { - $('
').text(data.nb_macros + " macros were rendered").appendTo(this.$status); - } - if (typeof data.callgraph !== 'undefined') { - this.$callgraph.html(data.callgraph); - } - }); - } - - }); - -})(PhpDebugBar.$); From 56a2dc1da9d3219164074713983eef68996386cf Mon Sep 17 00:00:00 2001 From: Benny Rahmat <46495960+akunbeben@users.noreply.github.com> Date: Wed, 26 Jul 2023 12:57:49 +0800 Subject: [PATCH 103/404] feat: update LivewireCollector to supports Livewire v3 (#1436) --- src/DataCollector/LivewireCollector.php | 21 +++++++++++++++++++++ src/LaravelDebugbar.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/LivewireCollector.php b/src/DataCollector/LivewireCollector.php index fe8d29d86..7aed46f51 100644 --- a/src/DataCollector/LivewireCollector.php +++ b/src/DataCollector/LivewireCollector.php @@ -12,6 +12,7 @@ use Illuminate\Support\Fluent; use Illuminate\Support\Str; use Livewire\Livewire; +use Livewire\Component; /** * Collector for Models. @@ -46,6 +47,26 @@ public function __construct(Request $request) $this->data[$key] = $this->formatVar($data); }); + + Livewire::listen('render', function (Component $component) use ($request) { + // Create an unique name for each compoent + $key = $component->getName() . ' #' . $component->getId(); + + $data = [ + 'data' => $component->all(), + ]; + + if ($request->request->get('id') == $component->getId()) { + $data['oldData'] = $request->request->get('data'); + $data['actionQueue'] = $request->request->get('actionQueue'); + } + + $data['name'] = $component->getName(); + $data['component'] = get_class($component); + $data['id'] = $component->getId(); + + $this->data[$key] = $this->formatVar($data); + }); } public function collect() diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index cfc6db4ad..9fa8476e1 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -838,7 +838,7 @@ protected function isDebugbarRequest() protected function isJsonRequest(Request $request) { // If XmlHttpRequest or Live, return true - if ($request->isXmlHttpRequest() || $request->headers->get('X-Livewire')) { + if ($request->isXmlHttpRequest() || $request->headers->has('X-Livewire')) { return true; } From 7d906ef86a810c3204cc887d585ac2011063ca1a Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 23 Aug 2023 13:58:37 +0200 Subject: [PATCH 104/404] Clarify development usage --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 5bac5ccd9..ea4731ffc 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,7 @@ Read [the documentation](http://phpdebugbar.com/docs/) for more configuration op ![Debugbar 3.3 Screenshot](https://user-images.githubusercontent.com/973269/79428890-196cc680-7fc7-11ea-8229-189f5eac9009.png) -Note: Use the DebugBar only in development. It can slow the application down (because it has to gather data). So when experiencing slowness, try disabling some of the collectors. +> Note: Use the DebugBar only in development. Do not use Debugbar on public websites, as it will leak information from stored requests (by design). It can also slow the application down (because it has to gather data). So when experiencing slowness, try disabling some of the collectors. This package includes some custom collectors: - QueryCollector: Show all queries, including binding + timing From 4635ad96904ca6168068f08e32247b853674dc22 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 24 Aug 2023 12:37:14 +0200 Subject: [PATCH 105/404] Improve masking of request collector (#1442) --- src/DataCollector/RequestCollector.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/DataCollector/RequestCollector.php b/src/DataCollector/RequestCollector.php index cc3fe866f..16d180cf3 100644 --- a/src/DataCollector/RequestCollector.php +++ b/src/DataCollector/RequestCollector.php @@ -125,8 +125,16 @@ public function collect() } } - if (isset($data['request_headers']['php-auth-pw'])) { - $data['request_headers']['php-auth-pw'] = '******'; + if (isset($data['request_request']['password'])) { + $data['request_request']['password'] = '******'; + } + + if (isset($data['request_headers']['authorization'][0])) { + $data['request_headers']['authorization'][0] = substr($data['request_headers']['authorization'][0], 0, 12) . '******'; + } + + if (isset($data['request_headers']['php-auth-pw'][0])) { + $data['request_headers']['php-auth-pw'][0] = '******'; } if (isset($data['request_server']['PHP_AUTH_PW'])) { From 9aeb524444042926657990a33ef8365e6b3020fa Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 24 Aug 2023 13:48:43 +0200 Subject: [PATCH 106/404] Drop lowest versions (#1441) Drop lowest to fix Chromedriver --- .github/workflows/run-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f42ee34bf..d9d050333 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -21,7 +21,7 @@ jobs: matrix: php: [8.2, 8.1, 8.0] laravel: [^10, ^9] - dependency-version: [prefer-lowest, prefer-stable] + dependency-version: [prefer-stable] exclude: - laravel: ^10 php: 8.0 From cde481e21461be9986dca00c8e314559b55bba41 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 24 Aug 2023 14:10:48 +0200 Subject: [PATCH 107/404] Secure storage by default (#1443) Disable the OpenHandler for storage by default, need to explicitly enable to browse previous requests. --- config/debugbar.php | 4 +++ readme.md | 8 ++++- src/Controllers/OpenHandlerController.php | 41 +++++++++++++++++++++-- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/config/debugbar.php b/config/debugbar.php index 5c4643cf7..e68132016 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -31,9 +31,13 @@ | By default, file storage (in the storage folder) is used. Redis and PDO | can also be used. For PDO, run the package migrations first. | + | Warning: Enabling storage.open will allow everyone to access previous request, + | do not enable open storage in publicly available environments! + | Specify a callback if you want to limit based on IP or authentication. */ 'storage' => [ 'enabled' => true, + 'open' => env('DEBUGBAR_OPEN_STORAGE', false), // Can be bool or callback. 'driver' => 'file', // redis, file, pdo, socket, custom 'path' => storage_path('debugbar'), // For file driver 'connection' => null, // Leave null for default connection (Redis/PDO) diff --git a/readme.md b/readme.md index ea4731ffc..a747891ae 100644 --- a/readme.md +++ b/readme.md @@ -14,7 +14,7 @@ Read [the documentation](http://phpdebugbar.com/docs/) for more configuration op ![Debugbar 3.3 Screenshot](https://user-images.githubusercontent.com/973269/79428890-196cc680-7fc7-11ea-8229-189f5eac9009.png) -> Note: Use the DebugBar only in development. Do not use Debugbar on public websites, as it will leak information from stored requests (by design). It can also slow the application down (because it has to gather data). So when experiencing slowness, try disabling some of the collectors. +### Note: Use the DebugBar only in development. Do not use Debugbar on publicly accessible websites, as it will leak information from stored requests (by design). It can also slow the application down (because it has to gather data). So when experiencing slowness, try disabling some of the collectors. This package includes some custom collectors: - QueryCollector: Show all queries, including binding + timing @@ -183,6 +183,12 @@ You can enable or disable the debugbar during run time. NB. Once enabled, the collectors are added (and could produce extra overhead), so if you want to use the debugbar in production, disable in the config and only enable when needed. +## Storage + +Debugbar remembers previous requests, which you can view using the Browse button on the right. This will only work if you enable `debugbar.storage.open` in the config. +Make sure you only do this on local development, because otherwise other people will be able to view previous requests. +In general, Debugbar should only be used locally or at least restricted by IP. +It's possible to pass a callback, which will receive the Request object, so you can determine access to the OpenHandler storage. ## Twig Integration diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index e5c059fc3..0d8acb07b 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -3,16 +3,47 @@ namespace Barryvdh\Debugbar\Controllers; use Barryvdh\Debugbar\Support\Clockwork\Converter; +use DebugBar\DebugBarException; use DebugBar\OpenHandler; use Illuminate\Http\Request; use Illuminate\Http\Response; class OpenHandlerController extends BaseController { + /** + * Check if the storage is open for inspecting. + * + * @param Request $request + * @return bool + */ + protected function isStorageOpen(Request $request) + { + $open = config('debugbar.storage.open'); + + if (is_callable($open)) { + return call_user_func($open, [$request]); + } + + return $open; + } + public function handle(Request $request) { - $openHandler = new OpenHandler($this->debugbar); - $data = $openHandler->handle($request->input(), false, false); + if ($this->isStorageOpen($request)) { + $openHandler = new OpenHandler($this->debugbar); + $data = $openHandler->handle($request->input(), false, false); + } else { + $data = [ + [ + 'datetime' => date("Y-m-d H:i:s"), + 'id' => null, + 'ip' => $request->getClientIp(), + 'method' => 'ERROR', + 'uri' => '!! To enable public access to previous requests, set debugbar.storage.open, or DEBUGBAR_OPEN_STORAGE to true in you config !!', + 'utime' => microtime(true), + ] + ]; + } return new Response( $data, @@ -30,8 +61,12 @@ public function handle(Request $request) * @return mixed * @throws \DebugBar\DebugBarException */ - public function clockwork($id) + public function clockwork(Request $request, $id) { + if (!$this->isStorageOpen($request)) { + throw new DebugBarException(" o enable public access to previous requests, set debugbar.storage.open, or DEBUGBAR_OPEN_STORAGE to true in you config"); + } + $request = [ 'op' => 'get', 'id' => $id, From a9daaa22157acf25d1bbac184d1673bb9d868e3d Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 24 Aug 2023 14:18:28 +0200 Subject: [PATCH 108/404] Clarify text (#1444) --- src/Controllers/OpenHandlerController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index 0d8acb07b..0057adf92 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -39,7 +39,7 @@ public function handle(Request $request) 'id' => null, 'ip' => $request->getClientIp(), 'method' => 'ERROR', - 'uri' => '!! To enable public access to previous requests, set debugbar.storage.open, or DEBUGBAR_OPEN_STORAGE to true in you config !!', + 'uri' => '!! To enable public access to previous requests, set debugbar.storage.open to true in your config, or enable DEBUGBAR_OPEN_STORAGE if you did not publish the config. !!', 'utime' => microtime(true), ] ]; @@ -64,7 +64,7 @@ public function handle(Request $request) public function clockwork(Request $request, $id) { if (!$this->isStorageOpen($request)) { - throw new DebugBarException(" o enable public access to previous requests, set debugbar.storage.open, or DEBUGBAR_OPEN_STORAGE to true in you config"); + throw new DebugBarException("To enable public access to previous requests, set debugbar.storage.open to true in your config, or enable DEBUGBAR_OPEN_STORAGE if you did not publish the config."); } $request = [ From af7739f6c3329a73f6fb2fae2d96e71d1d28d570 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Thu, 24 Aug 2023 07:18:47 -0500 Subject: [PATCH 109/404] Bump dracula theme (#1439) --- src/Resources/laravel-debugbar-dark-mode.css | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Resources/laravel-debugbar-dark-mode.css b/src/Resources/laravel-debugbar-dark-mode.css index 50f7832d2..f616dba66 100644 --- a/src/Resources/laravel-debugbar-dark-mode.css +++ b/src/Resources/laravel-debugbar-dark-mode.css @@ -195,7 +195,7 @@ div.phpdebugbar div.phpdebugbar-widgets-sqlqueries table.phpdebugbar-widgets-par div.phpdebugbar code, div.phpdebugbar pre { - color: #FFF; + color: #f1fa8c; } div.phpdebugbar-openhandler .phpdebugbar-openhandler-actions > a, @@ -262,7 +262,8 @@ div.phpdebugbar .hljs-subst { color: #f8f8f2; } -div.phpdebugbar .hljs-title { +div.phpdebugbar .hljs-title, +div.phpdebugbar .hljs-meta-keyword { color: #50fa7b; } @@ -286,6 +287,10 @@ div.phpdebugbar .hljs-deletion { color: #6272a4; } +div.phpdebugbar .hljs-strong { + font-weight: bold; +} + div.phpdebugbar .hljs-literal, div.phpdebugbar .hljs-number { color: #bd93f9; From 51d4a3033f5e5372e6679892e63516e224486cfd Mon Sep 17 00:00:00 2001 From: aivanov07 <42939853+aivanov07@users.noreply.github.com> Date: Thu, 24 Aug 2023 15:20:58 +0300 Subject: [PATCH 110/404] fix when forget button is unclickable if the cache name is too long (#1440) --- src/Resources/laravel-debugbar.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Resources/laravel-debugbar.css b/src/Resources/laravel-debugbar.css index 20aa438c8..c2163c7ea 100644 --- a/src/Resources/laravel-debugbar.css +++ b/src/Resources/laravel-debugbar.css @@ -334,6 +334,9 @@ ul.phpdebugbar-widgets-timeline li span.phpdebugbar-widgets-collector { top: 0px; color: #000; font-size: 11px; + overflow: hidden; + text-overflow: ellipsis; + width: 90%; } ul.phpdebugbar-widgets-timeline li .phpdebugbar-widgets-value span.phpdebugbar-widgets-label { From 8b7b8940ab2692fb526e1a0cb5d561fd51a0ae3b Mon Sep 17 00:00:00 2001 From: erikn69 Date: Thu, 24 Aug 2023 07:21:30 -0500 Subject: [PATCH 111/404] Fix normalizeFilename when multiple matches (#1430) --- src/DataCollector/QueryCollector.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 8824067c0..2ca8cfcc2 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -433,7 +433,14 @@ protected function normalizeFilename($path) if (file_exists($path)) { $path = realpath($path); } - return str_replace(base_path(), '', $path); + + $basepath = base_path(); + + if (! str_starts_with($path, $basepath)) { + return $path; + } + + return substr($path, strlen($basepath)); } /** From 5e8e4a3ac7b66b9219daee9202d7dd92276f0da6 Mon Sep 17 00:00:00 2001 From: Sachin Bahukhandi Date: Thu, 24 Aug 2023 17:51:53 +0530 Subject: [PATCH 112/404] Fixed the command debugbar:clear not being triggered via the Artisan::call(Browser) (#1411) --- src/ServiceProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 11ea596e7..4ba25e814 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -108,9 +108,7 @@ public function boot() $this->registerMiddleware(InjectDebugbar::class); - if ($this->app->runningInConsole()) { - $this->commands(['command.debugbar.clear']); - } + $this->commands(['command.debugbar.clear']); } /** From b4997907a2cd987e2601ee90ad406abe14eae2a8 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 24 Aug 2023 14:24:50 +0200 Subject: [PATCH 113/404] Config CS --- config/debugbar.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/debugbar.php b/config/debugbar.php index e68132016..41b69f53f 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -31,13 +31,13 @@ | By default, file storage (in the storage folder) is used. Redis and PDO | can also be used. For PDO, run the package migrations first. | - | Warning: Enabling storage.open will allow everyone to access previous request, - | do not enable open storage in publicly available environments! + | Warning: Enabling storage.open will allow everyone to access previous + | request, do not enable open storage in publicly available environments! | Specify a callback if you want to limit based on IP or authentication. */ 'storage' => [ 'enabled' => true, - 'open' => env('DEBUGBAR_OPEN_STORAGE', false), // Can be bool or callback. + 'open' => env('DEBUGBAR_OPEN_STORAGE', false), // bool/callback. 'driver' => 'file', // redis, file, pdo, socket, custom 'path' => storage_path('debugbar'), // For file driver 'connection' => null, // Leave null for default connection (Redis/PDO) From 070a313fd744f67348906bc879e544c4dda36be9 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 24 Aug 2023 14:28:59 +0200 Subject: [PATCH 114/404] Update debugbar.php (#1445) --- config/debugbar.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/debugbar.php b/config/debugbar.php index 41b69f53f..6b688786a 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -31,13 +31,13 @@ | By default, file storage (in the storage folder) is used. Redis and PDO | can also be used. For PDO, run the package migrations first. | - | Warning: Enabling storage.open will allow everyone to access previous - | request, do not enable open storage in publicly available environments! + | Warning: Enabling storage.open will allow everyone to access previous + | request, do not enable open storage in publicly available environments! | Specify a callback if you want to limit based on IP or authentication. */ 'storage' => [ 'enabled' => true, - 'open' => env('DEBUGBAR_OPEN_STORAGE', false), // bool/callback. + 'open' => env('DEBUGBAR_OPEN_STORAGE', false), // bool/callback. 'driver' => 'file', // redis, file, pdo, socket, custom 'path' => storage_path('debugbar'), // For file driver 'connection' => null, // Leave null for default connection (Redis/PDO) From bfd0131c146973cab164e50f5cdd8a67cc60cab1 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 25 Aug 2023 20:43:57 +0200 Subject: [PATCH 115/404] Limit OpenStorage check to 'find' (#1447) Allow get for direct access, eg. for ajax calls. --- src/Controllers/OpenHandlerController.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Controllers/OpenHandlerController.php b/src/Controllers/OpenHandlerController.php index 0057adf92..363e7ac9a 100644 --- a/src/Controllers/OpenHandlerController.php +++ b/src/Controllers/OpenHandlerController.php @@ -29,7 +29,7 @@ protected function isStorageOpen(Request $request) public function handle(Request $request) { - if ($this->isStorageOpen($request)) { + if ($request->input('op') === 'get' || $this->isStorageOpen($request)) { $openHandler = new OpenHandler($this->debugbar); $data = $openHandler->handle($request->input(), false, false); } else { @@ -63,10 +63,6 @@ public function handle(Request $request) */ public function clockwork(Request $request, $id) { - if (!$this->isStorageOpen($request)) { - throw new DebugBarException("To enable public access to previous requests, set debugbar.storage.open to true in your config, or enable DEBUGBAR_OPEN_STORAGE if you did not publish the config."); - } - $request = [ 'op' => 'get', 'id' => $id, From 27b088aaad2adba74a7a73a47cb8d11277b551e3 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Sun, 27 Aug 2023 08:34:05 -0500 Subject: [PATCH 116/404] ci: Use GitHub Actions V3 (#1448) --- .github/workflows/fix-cs.yml | 2 +- .github/workflows/run-integration-tests.yml | 4 ++-- .github/workflows/run-tests.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/fix-cs.yml b/.github/workflows/fix-cs.yml index 3b6b49063..127ae952d 100644 --- a/.github/workflows/fix-cs.yml +++ b/.github/workflows/fix-cs.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 49877b8fe..7e9dc0dc3 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -26,7 +26,7 @@ jobs: name: P${{ matrix.php }} - Lumen${{ matrix.lumen }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: src @@ -73,7 +73,7 @@ jobs: name: P${{ matrix.php }} - Laravel${{ matrix.laravel }} steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: src diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d9d050333..3138180eb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 From 88aef02d095141be312f4f5f77e4199e3347e6cd Mon Sep 17 00:00:00 2001 From: erikn69 Date: Fri, 15 Sep 2023 11:27:25 -0500 Subject: [PATCH 117/404] Remove Laravel <5.2 code (#1461) --- src/LaravelDebugbar.php | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/LaravelDebugbar.php b/src/LaravelDebugbar.php index 9fa8476e1..a0642eace 100644 --- a/src/LaravelDebugbar.php +++ b/src/LaravelDebugbar.php @@ -340,30 +340,15 @@ function ($level, $message = null, $context = null) use ($logger) { try { $db->listen( - function ( - $query, - $bindings = null, - $time = null, - $connectionName = null - ) use ( - $db, - $queryCollector - ) { + function (\Illuminate\Database\Events\QueryExecuted $query) use ($db, $queryCollector) { if (!app(static::class)->shouldCollect('db', true)) { return; // Issue 776 : We've turned off collecting after the listener was attached } - // Laravel 5.2 changed the way some core events worked. We must account for - // the first argument being an "event object", where arguments are passed - // via object properties, instead of individual arguments. - if ($query instanceof \Illuminate\Database\Events\QueryExecuted) { - $bindings = $query->bindings; - $time = $query->time; - $connection = $query->connection; - - $query = $query->sql; - } else { - $connection = $db->connection($connectionName); - } + + $bindings = $query->bindings; + $time = $query->time; + $connection = $query->connection; + $query = $query->sql; //allow collecting only queries slower than a specified amount of milliseconds $threshold = app('config')->get('debugbar.options.db.slow_threshold', false); From 8a3bab78027f29c1e37d26b83413c93fe82a1310 Mon Sep 17 00:00:00 2001 From: Yannik Sembritzki Date: Tue, 19 Sep 2023 16:17:37 +0200 Subject: [PATCH 118/404] Add nonce to "; + $html .= ""; if ($this->isJqueryNoConflictEnabled()) { - $html .= '' . "\n"; + $html .= "jQuery.noConflict(true);" . "\n"; } - $html .= $this->getInlineHtml(); + $inlineHtml = $this->getInlineHtml(); + if ($nonce != '') { + $inlineHtml = preg_replace("/ + From aa600c97fab378443dbf324eaffc0bbae4529896 Mon Sep 17 00:00:00 2001 From: Tobias Petry Date: Mon, 16 Sep 2024 13:51:02 +0200 Subject: [PATCH 284/404] Explain Improvements (#1670) * support mariadb explain * fix for really old mysql versions (not support by laravel anymore) * disable visual explain for mariadb * disable visual explain for mariadb * indentation whitespace was lost for pgsql explain * make visual explain check only when running an explain (its not needed before) --- src/Controllers/QueriesController.php | 17 +++++++---- src/DataCollector/QueryCollector.php | 3 +- src/Resources/queries/widget.js | 21 ++++++++------ src/Support/Explain.php | 41 ++++++++++++++++++++++----- 4 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/Controllers/QueriesController.php b/src/Controllers/QueriesController.php index a98201b3f..314a9b1c2 100644 --- a/src/Controllers/QueriesController.php +++ b/src/Controllers/QueriesController.php @@ -21,14 +21,21 @@ public function explain(Request $request) } try { - $data = match ($request->json('mode')) { - 'visual' => (new Explain())->generateVisualExplain($request->json('connection'), $request->json('query'), $request->json('bindings'), $request->json('hash')), - default => (new Explain())->generateRawExplain($request->json('connection'), $request->json('query'), $request->json('bindings'), $request->json('hash')), - }; + $explain = new Explain(); + + if ($request->json('mode') === 'visual') { + return response()->json([ + 'success' => true, + 'data' => $explain->generateVisualExplain($request->json('connection'), $request->json('query'), $request->json('bindings'), $request->json('hash')), + ]); + } return response()->json([ 'success' => true, - 'data' => $data, + 'data' => $explain->generateRawExplain($request->json('connection'), $request->json('query'), $request->json('bindings'), $request->json('hash')), + 'visual' => $explain->isVisualExplainSupported($request->json('connection')) ? [ + 'confirm' => $explain->confirmVisualExplain($request->json('connection')), + ] : null, ]); } catch (Exception $e) { return response()->json([ diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index a1d80ed26..19fec2a64 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -500,7 +500,7 @@ public function collect() } $canExplainQuery = match (true) { - in_array($query['driver'], ['mysql', 'pgsql']) => $query['bindings'] !== null && preg_match('/^\s*(' . implode('|', $this->explainTypes) . ') /i', $query['query']), + in_array($query['driver'], ['mariadb', 'mysql', 'pgsql']) => $query['bindings'] !== null && preg_match('/^\s*(' . implode('|', $this->explainTypes) . ') /i', $query['query']), default => false, }; @@ -523,7 +523,6 @@ public function collect() 'connection' => $connectionName, 'explain' => $this->explainQuery && $canExplainQuery ? [ 'url' => route('debugbar.queries.explain'), - 'visual-confirm' => (new Explain())->confirm($query['connection']), 'driver' => $query['driver'], 'connection' => $query['connection'], 'query' => $query['query'], diff --git a/src/Resources/queries/widget.js b/src/Resources/queries/widget.js index 9b9f5cd5c..42c33d0b0 100644 --- a/src/Resources/queries/widget.js +++ b/src/Resources/queries/widget.js @@ -41,7 +41,7 @@ return isCopied; }, - explainMysql: function ($element, statement, rows) { + explainMysql: function ($element, statement, rows, visual) { const headings = []; for (const key in rows[0]) { headings.push($('').text(key)); @@ -60,27 +60,30 @@ $table.find('thead').append($('').append(headings)); $table.find('tbody').append(values); - $element.append([$table, this.explainVisual(statement)]); + $element.append($table); + if (visual) { + $element.append(this.explainVisual(statement, visual.confirm)); + } }, - explainPgsql: function ($element, statement, rows) { + explainPgsql: function ($element, statement, rows, visual) { const $ul = $('