diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md index 1e5c4c91054..2435ca51a63 100644 --- a/CHANGELOG-WIP.md +++ b/CHANGELOG-WIP.md @@ -3,6 +3,7 @@ ### Development - Reference tags now support fallback values when no attribute is specified. ([#17688](https://github.com/craftcms/cms/pull/17688)) - Deprecated support for categories, global sets, and tags. ([#18009](https://github.com/craftcms/cms/pull/18009)) +- Removed support for the Debug Toolbar. [Laravel Debugbar](https://laraveldebugbar.com) can be used instead. ([#18812](https://github.com/craftcms/cms/pull/18812)) ### Extensibility - Added `CraftCms\Cms\Support\Arr`. diff --git a/CHANGELOG.md b/CHANGELOG.md index def51cae64b..6d8c47d2b03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Added support for Symfony-style array config files in `config/craft/sanitizers/`. ([#18808](https://github.com/craftcms/cms/pull/18808)) - The `craftAsset()` Twig function now resolves to Vite versioned assets. ([#18801](https://github.com/craftcms/cms/pull/18801)) - Deprecated the `csrfTokenName`, `enableCsrfCookie`, and `enableCsrfProtection` general config settings. ([#18806](https://github.com/craftcms/cms/pull/18806)) +- Removed support for the Debug Toolbar. [Laravel Debugbar](https://laraveldebugbar.com) can be used instead. ([#18812](https://github.com/craftcms/cms/pull/18812)) - Fixed a PHP error that occurred when saving a Structure section with a Max Levels value. ([#18809](https://github.com/craftcms/cms/issues/18809)) ## 6.0.0-alpha.1 - 2026-05-06 diff --git a/resources/templates/users/_preferences.twig b/resources/templates/users/_preferences.twig index 132ca4b781b..87e91c9f85e 100644 --- a/resources/templates/users/_preferences.twig +++ b/resources/templates/users/_preferences.twig @@ -194,24 +194,6 @@ }, ], }) }} - - {{ forms.checkboxGroupField({ - label: 'Debug Toolbar'|t('app'), - options: [ - { - label: 'Show the debug toolbar on the front end'|t('app'), - name: 'enableDebugToolbarForSite', - id: 'enableDebugToolbarForSite', - checked: Auth.user.getPreference('enableDebugToolbarForSite') - }, - { - label: 'Show the debug toolbar in the control panel'|t('app'), - name: 'enableDebugToolbarForCp', - id: 'enableDebugToolbarForCp', - checked: Auth.user.getPreference('enableDebugToolbarForCp') - }, - ], - }) }} {% endif %} diff --git a/src/Http/Controllers/Users/PreferencesController.php b/src/Http/Controllers/Users/PreferencesController.php index ab02e677ff1..7046b2136c2 100644 --- a/src/Http/Controllers/Users/PreferencesController.php +++ b/src/Http/Controllers/Users/PreferencesController.php @@ -81,8 +81,6 @@ public function store(Request $request, Users $users): Response if ($user->admin) { $preferences = array_merge($preferences, [ 'showFieldHandles' => (bool) $request->input('showFieldHandles', $user->getPreference('showFieldHandles')), - 'enableDebugToolbarForSite' => (bool) $request->input('enableDebugToolbarForSite', $user->getPreference('enableDebugToolbarForSite')), - 'enableDebugToolbarForCp' => (bool) $request->input('enableDebugToolbarForCp', $user->getPreference('enableDebugToolbarForCp')), 'showExceptionView' => (bool) $request->input('showExceptionView', $user->getPreference('showExceptionView')), 'profileTemplates' => (bool) $request->input('profileTemplates', $user->getPreference('profileTemplates')), ]); diff --git a/tests/Feature/Http/Controllers/User/PreferencesControllerTest.php b/tests/Feature/Http/Controllers/User/PreferencesControllerTest.php index 31c42a57e4a..6fd7327b510 100644 --- a/tests/Feature/Http/Controllers/User/PreferencesControllerTest.php +++ b/tests/Feature/Http/Controllers/User/PreferencesControllerTest.php @@ -95,24 +95,17 @@ /** @var User $user */ $user = auth()->user(); - // Admin users can set these preferences - // The user in tests should already be an admin if (! $user->admin) { $this->markTestSkipped('User must be admin for this test'); } postJson(action([PreferencesController::class, 'store'], [ 'showFieldHandles' => true, - 'enableDebugToolbarForSite' => true, - 'enableDebugToolbarForCp' => true, 'showExceptionView' => true, 'profileTemplates' => true, ]))->assertOk(); - // Verify preferences were saved (admin-only preferences) expect($user->getPreference('showFieldHandles'))->toBeTrue(); - expect($user->getPreference('enableDebugToolbarForSite'))->toBeTrue(); - expect($user->getPreference('enableDebugToolbarForCp'))->toBeTrue(); expect($user->getPreference('showExceptionView'))->toBeTrue(); expect($user->getPreference('profileTemplates'))->toBeTrue(); }); diff --git a/yii2-adapter/legacy/web/Application.php b/yii2-adapter/legacy/web/Application.php index ce5a72b48cf..3468b6da546 100644 --- a/yii2-adapter/legacy/web/Application.php +++ b/yii2-adapter/legacy/web/Application.php @@ -7,13 +7,7 @@ namespace craft\web; -use Craft; use craft\base\ApplicationTrait; -use craft\debug\DeprecatedPanel; -use craft\debug\DumpPanel; -use craft\debug\Module as DebugModule; -use craft\debug\RequestPanel; -use craft\debug\UserPanel; use craft\errors\ExitException; use craft\helpers\App; use craft\helpers\FileHelper; @@ -21,18 +15,15 @@ use CraftCms\Aliases\Aliases; use CraftCms\Cms\Cms; use CraftCms\Cms\Plugin\Plugins; -use CraftCms\Cms\Support\Typecast; use CraftCms\Cms\Support\Url; use CraftCms\Yii2Adapter\Web\Response as IlluminateBridgeResponse; use Illuminate\Contracts\Http\Kernel; use Illuminate\Http\Request as IlluminateRequest; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Log; use IntlDateFormatter; use IntlException; -use ReflectionClass; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; use Throwable; use yii\base\Component; @@ -42,13 +33,6 @@ use yii\base\InvalidArgumentException; use yii\base\InvalidConfigException; use yii\base\InvalidRouteException; -use yii\debug\Module as YiiDebugModule; -use yii\debug\panels\AssetPanel; -use yii\debug\panels\DbPanel; -use yii\debug\panels\LogPanel; -use yii\debug\panels\MailPanel; -use yii\debug\panels\ProfilingPanel; -use yii\debug\panels\RouterPanel; use yii\web\BadRequestHttpException; use yii\web\NotFoundHttpException; use yii\web\Response as BaseResponse; @@ -116,8 +100,6 @@ public function init(): void // Process resource requests before we do anything to establish the user session $this->_processResourceRequest(); - - $this->debugBootstrap(); } /** @@ -225,12 +207,7 @@ public function handleRequest($request, bool $skipSpecialHandling = false): Base } // If we’re still here, finally let Yii do its thing. - try { - return parent::handleRequest($request); - } catch (Throwable $e) { - $this->_unregisterDebugModule(); - throw $e; - } + return parent::handleRequest($request); } /** @@ -363,81 +340,6 @@ protected function ensureResourcePathExists(): void } } - /** - * Bootstraps the Debug Toolbar if necessary. - */ - protected function debugBootstrap(): void - { - $request = $this->getRequest(); - - if ($request->getIsLivePreview() || $request->getIsPreview()) { - return; - } - - // Only load the debug toolbar if it's enabled for the user, or Dev Mode is enabled and the request wants it - $user = Auth::user(); - $pref = $request->getIsCpRequest() ? 'enableDebugToolbarForCp' : 'enableDebugToolbarForSite'; - if (!( - ($user && $user->admin && $user->getPreference($pref)) || - (app()->hasDebugModeEnabled() && $request->getHeaders()->get('X-Debug') === 'enable') - )) { - return; - } - - $svg = rawurlencode(file_get_contents(dirname(__DIR__) . '/icons/custom-icons/c-debug.svg')); - DebugModule::setYiiLogo("data:image/svg+xml;charset=utf-8,$svg"); - - // Determine the base path using reflection in case it wasn't loaded from @vendor - $ref = new ReflectionClass(YiiDebugModule::class); - $basePath = dirname($ref->getFileName()); - - $this->setModule('debug', [ - 'class' => DebugModule::class, - 'basePath' => $basePath, - 'allowedIPs' => ['*'], - 'panels' => [ - 'config' => false, - 'user' => UserPanel::class, - 'router' => [ - 'class' => RouterPanel::class, - 'categories' => [ - UrlManager::class . '::_getMatchedElementRoute', - UrlManager::class . '::_getMatchedUrlRoute', - UrlManager::class . '::_getTemplateRoute', - UrlManager::class . '::_getTokenRoute', - ], - ], - 'request' => RequestPanel::class, - 'log' => LogPanel::class, - 'dump' => DumpPanel::class, - 'deprecated' => DeprecatedPanel::class, - 'profiling' => ProfilingPanel::class, - 'db' => DbPanel::class, - 'asset' => AssetPanel::class, - 'mail' => MailPanel::class, - ], - ]); - /** @var DebugModule $module */ - $module = $this->getModule('debug'); - $module->bootstrap($this); - - if ($config = Config::get('craft.debug', [])) { - Typecast::configure($module, $config); - } - } - - /** - * Unregisters the Debug module's end body event. - */ - private function _unregisterDebugModule(): void - { - $debug = $this->getModule('debug', false); - - if ($debug !== null) { - $this->getView()->off(View::EVENT_END_BODY, [$debug, 'renderToolbar']); - } - } - /** * Processes resource requests. * @@ -492,10 +394,6 @@ private function _processInstallRequest(Request $request): ?BaseResponse $isCpRequest = $request->getIsCpRequest(); $isInstalled = Cms::isInstalled(); - if (!$isInstalled) { - $this->_unregisterDebugModule(); - } - // Are they requesting the installer? if ($isCpRequest && $request->getSegment(1) === 'install') { // Is Craft already installed? @@ -560,7 +458,6 @@ private function _processActionRequest(Request $request): ?BaseResponse ? ($response ?? $this->getResponse()) : $response; } catch (Throwable $e) { - $this->_unregisterDebugModule(); if ($e instanceof InvalidRouteException) { throw new NotFoundHttpException(t('Page not found.'), $e->getCode(), $e); }