<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56042] trunk: General: Introduce `WP_DEVELOPMENT_MODE` constant to signify context-specific development mode.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/56042">56042</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/56042","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>flixos90</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-06-26 19:55:28 +0000 (Mon, 26 Jun 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>General: Introduce `WP_DEVELOPMENT_MODE` constant to signify context-specific development mode.
In recent releases, WordPress core added several instances of cache usage around specific files. While those caches are safe to use in a production context, in development certain nuances apply for whether or not those caches make sense to use. Initially, `WP_DEBUG` was used as a temporary workaround, but it was clear that a more granular method to signify a specific development mode was required: For example, caches around `theme.json` should be disabled when working on a theme as otherwise it would disrupt the theme developer's workflow, but when working on a plugin or WordPress core, this consideration does not apply.
This changeset introduces a `WP_DEVELOPMENT_MODE` constant which, for now, can be set to either "core", "plugin", "theme", or an empty string, the latter of which means no development mode, which is also the default. A new function `wp_get_development_mode()` is the recommended way to retrieve that configuration value.
With the new function available, this changeset replaces all existing instances of the aforementioned `WP_DEBUG` workaround to use `wp_get_development_mode()` with a more specific check.
Props azaozz, sergeybiryukov, peterwilsoncc, spacedmonkey.
Fixes <a href="https://core.trac.wordpress.org/ticket/57487">#57487</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkenv">trunk/.env</a></li>
<li><a href="#trunksrcwpincludesdefaultconstantsphp">trunk/src/wp-includes/default-constants.php</a></li>
<li><a href="#trunksrcwpincludesglobalstylesandsettingsphp">trunk/src/wp-includes/global-styles-and-settings.php</a></li>
<li><a href="#trunksrcwpincludesloadphp">trunk/src/wp-includes/load.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpGetGlobalStylesSvgFiltersphp">trunk/tests/phpunit/tests/theme/wpGetGlobalStylesSvgFilters.php</a></li>
<li><a href="#trunktestsphpunitteststhemewpGetGlobalStylesheetphp">trunk/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php</a></li>
<li><a href="#trunktoolslocalenvscriptsinstalljs">trunk/tools/local-env/scripts/install.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsloadwpGetDevelopmentModephp">trunk/tests/phpunit/tests/load/wpGetDevelopmentMode.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkenv"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/.env</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/.env 2023-06-26 18:13:04 UTC (rev 56041)
+++ trunk/.env 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,6 +59,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> LOCAL_WP_DEBUG_DISPLAY=true
</span><span class="cx" style="display: block; padding: 0 10px"> LOCAL_SCRIPT_DEBUG=true
</span><span class="cx" style="display: block; padding: 0 10px"> LOCAL_WP_ENVIRONMENT_TYPE=local
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+LOCAL_WP_DEVELOPMENT_MODE=core
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> # The URL to use when running e2e tests.
</span><span class="cx" style="display: block; padding: 0 10px"> WP_BASE_URL=http://localhost:${LOCAL_PORT}
</span></span></pre></div>
<a id="trunksrcwpincludesdefaultconstantsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/default-constants.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-constants.php 2023-06-26 18:13:04 UTC (rev 56041)
+++ trunk/src/wp-includes/default-constants.php 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,9 +77,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // No trailing slash, full paths only - WP_CONTENT_URL is defined further down.
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Add define( 'WP_DEVELOPMENT_MODE', 'core' ) or define( 'WP_DEVELOPMENT_MODE', 'plugin' ) or
+ * define( 'WP_DEVELOPMENT_MODE', 'theme' ) to wp-config.php to signify development mode for WordPress core, a
+ * plugin, or a theme respectively.
+ */
+ if ( ! defined( 'WP_DEVELOPMENT_MODE' ) ) {
+ define( 'WP_DEVELOPMENT_MODE', '' );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Add define( 'WP_DEBUG', true ); to wp-config.php to enable display of notices during development.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! defined( 'WP_DEBUG' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( 'development' === wp_get_environment_type() ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_get_development_mode() || 'development' === wp_get_environment_type() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> define( 'WP_DEBUG', true );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'WP_DEBUG', false );
</span></span></pre></div>
<a id="trunksrcwpincludesglobalstylesandsettingsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/global-styles-and-settings.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/global-styles-and-settings.php 2023-06-26 18:13:04 UTC (rev 56041)
+++ trunk/src/wp-includes/global-styles-and-settings.php 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -66,12 +66,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $cache_key = 'wp_get_global_settings_' . $origin;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
</ins><span class="cx" style="display: block; padding: 0 10px"> * developer's workflow.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $can_use_cached = ! WP_DEBUG;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $can_use_cached = wp_get_development_mode() !== 'theme';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $settings = false;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $can_use_cached ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -151,12 +149,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_get_global_stylesheet( $types = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
</ins><span class="cx" style="display: block; padding: 0 10px"> * developer's workflow.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $can_use_cached = empty( $types ) && ! WP_DEBUG;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $can_use_cached = empty( $types ) && wp_get_development_mode() !== 'theme';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * By using the 'theme_json' group, this data is marked to be non-persistent across requests.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -252,12 +248,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
</ins><span class="cx" style="display: block; padding: 0 10px"> * developer's workflow.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $can_use_cached = ! WP_DEBUG;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $can_use_cached = wp_get_development_mode() !== 'theme';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * By using the 'theme_json' group, this data is marked to be non-persistent across requests.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -303,12 +297,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_get_global_styles_svg_filters() {
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Ignore cache when the development mode is set to 'theme', so it doesn't interfere with the theme
</ins><span class="cx" style="display: block; padding: 0 10px"> * developer's workflow.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $can_use_cached = ! WP_DEBUG;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $can_use_cached = wp_get_development_mode() !== 'theme';
</ins><span class="cx" style="display: block; padding: 0 10px"> $cache_group = 'theme_json';
</span><span class="cx" style="display: block; padding: 0 10px"> $cache_key = 'wp_get_global_styles_svg_filters';
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $can_use_cached ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -402,12 +394,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> null !== $theme_has_support &&
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Ignore static cache when `WP_DEBUG` is enabled. Why? To avoid interfering with
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Ignore static cache when the development mode is set to 'theme', to avoid interfering with
</ins><span class="cx" style="display: block; padding: 0 10px"> * the theme developer's workflow.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core.
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ! WP_DEBUG &&
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_get_development_mode() !== 'theme' &&
</ins><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * Ignore cache when automated test suites are running. Why? To ensure
</span><span class="cx" style="display: block; padding: 0 10px"> * the static cache is reset between each test.
</span></span></pre></div>
<a id="trunksrcwpincludesloadphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/load.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/load.php 2023-06-26 18:13:04 UTC (rev 56041)
+++ trunk/src/wp-includes/load.php 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -262,6 +262,50 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Retrieves the current development mode.
+ *
+ * The development mode affects how certain parts of the WordPress application behave, which is relevant when
+ * developing for WordPress.
+ *
+ * Valid developer modes are 'core', 'plugin', 'theme', or an empty string to disable developer mode.
+ *
+ * Developer mode is considered separately from `WP_DEBUG` and {@see wp_get_environment_type()}. It does not affect
+ * debugging output, but rather functional nuances in WordPress.
+ *
+ * @since 6.3.0
+ *
+ * @return string The current development mode.
+ */
+function wp_get_development_mode() {
+ static $current_mode = null;
+
+ if ( ! defined( 'WP_RUN_CORE_TESTS' ) && null !== $current_mode ) {
+ return $current_mode;
+ }
+
+ $development_mode = WP_DEVELOPMENT_MODE;
+
+ // Exclusively for core tests, rely on a global `$_wp_tests_development_mode`.
+ if ( defined( 'WP_RUN_CORE_TESTS' ) && isset( $GLOBALS['_wp_tests_development_mode'] ) ) {
+ $development_mode = $GLOBALS['_wp_tests_development_mode'];
+ }
+
+ $valid_modes = array(
+ 'core',
+ 'plugin',
+ 'theme',
+ '',
+ );
+ if ( ! in_array( $development_mode, $valid_modes, true ) ) {
+ $development_mode = '';
+ }
+
+ $current_mode = $development_mode;
+
+ return $current_mode;
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Don't load all of WordPress when handling a favicon.ico request.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Instead, send the headers for a zero-length favicon and bail.
</span></span></pre></div>
<a id="trunktestsphpunittestsloadwpGetDevelopmentModephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/load/wpGetDevelopmentMode.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/load/wpGetDevelopmentMode.php (rev 0)
+++ trunk/tests/phpunit/tests/load/wpGetDevelopmentMode.php 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,46 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Unit tests for `wp_get_development_mode()`.
+ *
+ * @package WordPress
+ * @subpackage UnitTests
+ * @since 6.3.0
+ *
+ * @group load.php
+ * @covers ::wp_get_development_mode
+ */
+class Test_WP_Get_Development_Mode extends WP_UnitTestCase {
+
+ /**
+ * Tests that `wp_get_development_mode()` returns the value of the `WP_DEVELOPMENT_MODE` constant.
+ *
+ * @ticket 57487
+ */
+ public function test_wp_get_development_mode_constant() {
+ $this->assertSame( WP_DEVELOPMENT_MODE, wp_get_development_mode() );
+ }
+
+ /**
+ * Tests that `wp_get_development_mode()` allows test overrides.
+ *
+ * @ticket 57487
+ */
+ public function test_wp_get_development_mode_test_overrides() {
+ global $_wp_tests_development_mode;
+
+ $_wp_tests_development_mode = 'plugin';
+ $this->assertSame( 'plugin', wp_get_development_mode() );
+ }
+
+ /**
+ * Tests that `wp_get_development_mode()` ignores invalid filter values.
+ *
+ * @ticket 57487
+ */
+ public function test_wp_get_development_mode_filter_invalid_value() {
+ global $_wp_tests_development_mode;
+
+ $_wp_tests_development_mode = 'invalid';
+ $this->assertSame( '', wp_get_development_mode() );
+ }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/load/wpGetDevelopmentMode.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunitteststhemewpGetGlobalStylesSvgFiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpGetGlobalStylesSvgFilters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpGetGlobalStylesSvgFilters.php 2023-06-26 18:13:04 UTC (rev 56041)
+++ trunk/tests/phpunit/tests/theme/wpGetGlobalStylesSvgFilters.php 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -34,4 +34,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString( '<svg', $svg_for_default_theme, 'Block theme should contain SVG' );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotSame( $svg_for_default_theme, $svg_for_block_theme, 'Cache value should have changed' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Tests that the function relies on the development mode for whether to use caching.
+ *
+ * @ticket 57487
+ *
+ * @covers ::wp_get_global_styles_svg_filters
+ */
+ public function test_caching_is_used_when_developing_theme() {
+ global $_wp_tests_development_mode;
+
+ switch_theme( 'block-theme' );
+
+ // Store SVG in cache.
+ $svg = '<svg></svg>';
+ wp_cache_set( 'wp_get_global_styles_svg_filters', $svg, 'theme_json' );
+
+ // By default, caching should be used, so the above value will be returned.
+ $_wp_tests_development_mode = '';
+ $this->assertSame( $svg, wp_get_global_styles_svg_filters(), 'Caching was not used despite development mode disabled' );
+
+ // When the development mode is set to 'theme', caching should not be used.
+ $_wp_tests_development_mode = 'theme';
+ $this->assertNotSame( $svg, wp_get_global_styles_svg_filters(), 'Caching was used despite theme development mode' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunitteststhemewpGetGlobalStylesheetphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php 2023-06-26 18:13:04 UTC (rev 56041)
+++ trunk/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -221,6 +221,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Tests that the function relies on the development mode for whether to use caching.
+ *
+ * @ticket 57487
+ */
+ public function test_caching_is_used_when_developing_theme() {
+ global $_wp_tests_development_mode;
+
+ $this->maybe_switch_theme( 'block-theme' );
+
+ // Store CSS in cache.
+ $css = '.my-class { display: block; }';
+ wp_cache_set( 'wp_get_global_stylesheet', $css, 'theme_json' );
+
+ // By default, caching should be used, so the above value will be returned.
+ $_wp_tests_development_mode = '';
+ $this->assertSame( $css, wp_get_global_stylesheet(), 'Caching was not used despite development mode disabled' );
+
+ // When the development mode is set to 'theme', caching should not be used.
+ $_wp_tests_development_mode = 'theme';
+ $this->assertNotSame( $css, wp_get_global_stylesheet(), 'Caching was used despite theme development mode' );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Adds the 'editor-font-sizes' theme support with custom font sizes.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $add_theme_support Whether to add the theme support.
</span></span></pre></div>
<a id="trunktoolslocalenvscriptsinstalljs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tools/local-env/scripts/install.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tools/local-env/scripts/install.js 2023-06-26 18:13:04 UTC (rev 56041)
+++ trunk/tools/local-env/scripts/install.js 2023-06-26 19:55:28 UTC (rev 56042)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,6 +16,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cli( `config set WP_DEBUG_DISPLAY ${process.env.LOCAL_WP_DEBUG_DISPLAY} --raw --type=constant` );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cli( `config set SCRIPT_DEBUG ${process.env.LOCAL_SCRIPT_DEBUG} --raw --type=constant` );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cli( `config set WP_ENVIRONMENT_TYPE ${process.env.LOCAL_WP_ENVIRONMENT_TYPE} --type=constant` );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+wp_cli( `config set WP_DEVELOPMENT_MODE ${process.env.LOCAL_WP_DEVELOPMENT_MODE} --type=constant` );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Move wp-config.php to the base directory, so it doesn't get mixed up in the src or build directories.
</span><span class="cx" style="display: block; padding: 0 10px"> renameSync( 'src/wp-config.php', 'wp-config.php' );
</span></span></pre>
</div>
</div>
</body>
</html>