Skip to content

Add WP_DEBUG_LOG and WP_DEBUG_DISPLAY toggles - #2553

Merged
bcotrim merged 14 commits into
trunkfrom
add/enable-debug-log
Feb 23, 2026
Merged

Add WP_DEBUG_LOG and WP_DEBUG_DISPLAY toggles#2553
bcotrim merged 14 commits into
trunkfrom
add/enable-debug-log

Conversation

@bcotrim

@bcotrim bcotrim commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Related issues

Fixes STU-4 #23

Proposed Changes

  • Add WP_DEBUG_LOG and WP_DEBUG_DISPLAY toggles in a new "Developer" tab within the Edit Site modal
  • Xdebug control moved to Developer tab alongside new debug toggles
  • WP_DEBUG automatically enabled when either WP_DEBUG_LOG or WP_DEBUG_DISPLAY is toggled on
  • Developer settings grouped in read-only Settings view
  • Full CLI support: studio site set --debug-log --debug-display with --no- variants
  • Server restart triggered when debug settings change
image

Testing Instructions

  1. Open WordPress Studio and select a site
  2. Click "Edit site" → Developer tab
  3. Toggle "Enable debug log" and "Show errors in browser"
  4. Save and verify the site restarts
  5. Check that wp-content/debug.log is created
  6. Via CLI: studio site set --path /path/to/site --debug-log --debug-display

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
Add toggles for enabling WP_DEBUG_LOG and WP_DEBUG_DISPLAY in Site Settings.
- New Developer tab in Edit Site modal with Xdebug, debug log, and debug display toggles
- Grouped controls update appdata, trigger server restart, and inject Blueprint constants
- WP_DEBUG auto-enabled when either debug setting is on
- Full CLI support via 'studio site set --debug-log --debug-display'
@bcotrim bcotrim self-assigned this Feb 8, 2026
@bcotrim
bcotrim marked this pull request as draft February 8, 2026 12:14
@wpmobilebot

wpmobilebot commented Feb 8, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 3ae0fcc vs trunk

site-editor

Metric trunk 3ae0fcc Diff Change
load 1458.00 ms 1403.00 ms -55.00 ms 🟢 -3.8%

site-startup

Metric trunk 3ae0fcc Diff Change
siteCreation 7069.00 ms 7075.00 ms +6.00 ms ⚪ 0.0%
siteStartup 3943.00 ms 3939.00 ms -4.00 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim
bcotrim requested a review from a team February 18, 2026 16:10
@bcotrim
bcotrim marked this pull request as ready for review February 18, 2026 16:10

@ivan-ottinger ivan-ottinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a nice improvement! Great work!

Despite disabling the logging settings, the debug.log file is still being created on a fresh site.

From what I have seen so far, this is likely related to Playground's default PHP error logging that is overriding our settings.


Another, but minor design thing I noticed is that the tabs line does not stretch to the sides in a way we have on other existing modal in the app:

Settings:
Image

Edit site:
Image


Apart from the above, the UI looks clean to me and CLI commands run well too. 🙂

Image Image Image
@wojtekn

wojtekn commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

From what I have seen so far, this is likely related to Playground's default PHP error logging that is overriding our settings.

There was a discussion with the Playground team on reverting those to the default state. I removed those under WordPress/wordpress-playground#3131, which was closed, but @adamziel mentioned it was solved in another way.

@katinthehatsite

Copy link
Copy Markdown
Contributor

Despite disabling the logging settings, the debug.log file is still being created on a fresh site.

I am not sure why but I did not see this issue when testing: I tried with the new site and enabled and disabled it multiple times and the setting was reflected correctly 🤔

@@ -138,9 +138,20 @@ export function ContentTabSettings( { selectedSite }: ContentTabSettingsProps )
<span className="line-clamp-1 break-all">{ selectedSite.phpVersion }</span>
</div>
</SettingsRow>
<tr>
<th colSpan={ 2 } className="pb-4 ltr:text-left rtl:text-right">
<h3 className="text-black text-sm font-semibold mt-4">{ __( 'Developer' ) }</h3>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might want to remove the padding of 1rem for the General tab to make sure that the tab looks more aligned.

@bcotrim

bcotrim commented Feb 19, 2026

Copy link
Copy Markdown
Contributor Author

@ivan-ottinger nice catch!

The debug.log being created with settings off was caused by Playground’s 0-playground.php which unconditionally sets error_log to wp-content/debug.log and has log_errors=1 in its default php.ini. Any PHP warning would create the file.

Fixed by adding a Studio mu-plugin (0-configure-error-logging.php) that sets ini_set('log_errors', '0') when WP_DEBUG_LOG is disabled. This runs after Playground’s setup but before any warnings get triggered.

The site behavior should now match the selected options. Let me know what you think.

@wojtekn

wojtekn commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

@bcotrim, can we check this with the Playground team? It seems like something that should be fixed on the Playground side.

@ivan-ottinger ivan-ottinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug.log being created with settings off was caused by Playground’s 0-playground.php which unconditionally sets error_log to wp-content/debug.log and has log_errors=1 in its default php.ini. Any PHP warning would create the file.

Fixed by adding a Studio mu-plugin (0-configure-error-logging.php) that sets ini_set('log_errors', '0') when WP_DEBUG_LOG is disabled. This runs after Playground’s setup but before any warnings get triggered.

The site behavior should now match the selected options. Let me know what you think.

Thank you for the updates, Bernardo! The changes look good to me and work well. I did not observe any further major issues, just a tiny naming thing (please see the inline comment below) and a different styling for disabled elements when when saving:

CleanShot.2026-02-20.at.12.33.47.mp4

(xdebug checkbox is disabled differently)


I am aware of Wojtek's comment on fixing the override on the Playground side. I am approving this PR in case we decide to move forward with the current approach.

className="w-full [&>[role=tabpanel]]:h-64 [&>[role=tabpanel]]:overflow-auto"
tabs={ [
{ name: 'general', title: __( 'General' ) },
{ name: 'developer', title: __( 'Debugging' ) },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could change the name here (and in related references) as well (to debugging).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xdebug checkbox is disabled differently

I noted this as well while reviewing this PR, I think it looks better now with recent changes

@bcotrim

bcotrim commented Feb 20, 2026

Copy link
Copy Markdown
Contributor Author

@bcotrim, can we check this with the Playground team? It seems like something that should be fixed on the Playground side.

Shared: p1771600191281759-slack-C09GMMV3T6J

Meanwhile should we merge this PR or hold on to Playground and design feedback?

@katinthehatsite katinthehatsite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good, I tested this on my end once again and checked the code and did not see any regressions. 👍

@wojtekn

wojtekn commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Meanwhile should we merge this PR or hold on to Playground and design feedback?

UI looks solid, so I think we should be good to merge.

We could consider changing the MU plugin to an NPM patch for the Playground package, so it will be easier to notice when the fix arrives in the Playground core and to clean up our hotfix.

@wojtekn

wojtekn commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

@bcotrim one more thing - looking at labels, it may be unclear for some users what happens behind those new controls. Would it make sense to update descriptions and say "[...] by setting WP_DEBUG constant"?

# Conflicts:
#	apps/studio/src/ipc-types.d.ts
#	apps/studio/src/storage/user-data.ts
@bcotrim

bcotrim commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

@wojtekn done in 0ddde2a

@bcotrim
bcotrim merged commit 658e68e into trunk Feb 23, 2026
9 checks passed
@bcotrim
bcotrim deleted the add/enable-debug-log branch February 23, 2026 16:08
@wojtekn

wojtekn commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

We've added settings that allow enabling the logs:

CleanShot 2026-02-24 at 09 31 24@2x

The feature will be included in the incoming 1.7.5 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants