Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions resources/templates/users/_preferences.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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')
},
],
}) }}
</div>
{% endif %}

Expand Down
2 changes: 0 additions & 2 deletions src/Http/Controllers/Users/PreferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
105 changes: 1 addition & 104 deletions yii2-adapter/legacy/web/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,23 @@

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;
use craft\queue\QueueLogBehavior;
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;
Expand All @@ -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;
Expand Down Expand Up @@ -116,8 +100,6 @@ public function init(): void

// Process resource requests before we do anything to establish the user session
$this->_processResourceRequest();

$this->debugBootstrap();
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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);
}
Expand Down