<!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>[58813] trunk: General: Introduce `wp_get_wp_version()` to get unmodified version.</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/58813">58813</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/58813","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>peterwilsoncc</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2024-07-27 00:25:44 +0000 (Sat, 27 Jul 2024)</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_get_wp_version()` to get unmodified version.
Introduces `wp_get_wp_version()` to get an unmodified value of `$wp_version` from `wp-includes/version.php`. Some plugins modify the global in an attempt to improve security through obscurity. This practice can cause errors in WordPress so the ability to get an unmodified version is needed.
Replaces instances within the code base in which `version.php` was required in order to get an unmodified value. `script-loader.php` is intentionally excluded from the replacements as the function is not always available to the file.
Props debarghyabanerjee, afragen, costdev.
See <a href="https://core.trac.wordpress.org/ticket/61627">#61627</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludescreditsphp">trunk/src/wp-admin/includes/credits.php</a></li>
<li><a href="#trunksrcwpadminincludesdashboardphp">trunk/src/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunksrcwpadminincludesimportphp">trunk/src/wp-admin/includes/import.php</a></li>
<li><a href="#trunksrcwpadminincludesplugininstallphp">trunk/src/wp-admin/includes/plugin-install.php</a></li>
<li><a href="#trunksrcwpadminincludesthemephp">trunk/src/wp-admin/includes/theme.php</a></li>
<li><a href="#trunksrcwpadminincludestranslationinstallphp">trunk/src/wp-admin/includes/translation-install.php</a></li>
<li><a href="#trunksrcwpadminincludesupdatephp">trunk/src/wp-admin/includes/update.php</a></li>
<li><a href="#trunksrcwpincludesfunctionsphp">trunk/src/wp-includes/functions.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpatterndirectorycontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
<li><a href="#trunksrcwpincludesupdatephp">trunk/src/wp-includes/update.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsfunctionswpGetWpVersionphp">trunk/tests/phpunit/tests/functions/wpGetWpVersion.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludescreditsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/credits.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/credits.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-admin/includes/credits.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -19,10 +19,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_credits( $version = '', $locale = '' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $version ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
- $version = $wp_version;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $version = wp_get_wp_version();
</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"> if ( ! $locale ) {
</span></span></pre></div>
<a id="trunksrcwpadminincludesdashboardphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/dashboard.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/dashboard.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-admin/includes/dashboard.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1819,13 +1819,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = get_site_transient( 'browser_' . $key );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false === $response ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $url = 'http://api.wordpress.org/core/browse-happy/1.1/';
</span><span class="cx" style="display: block; padding: 0 10px"> $options = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
</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"> if ( wp_http_supports( array( 'ssl' ) ) ) {
</span></span></pre></div>
<a id="trunksrcwpadminincludesimportphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/import.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/import.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-admin/includes/import.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,11 +136,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Importers with metadata for each.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_get_popular_importers() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $locale = get_user_locale();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cache_key = 'popular_importers_' . md5( $locale . $wp_version );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cache_key = 'popular_importers_' . md5( $locale . wp_get_wp_version() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $popular_importers = get_site_transient( $cache_key );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $popular_importers ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,11 +144,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $url = add_query_arg(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'locale' => $locale,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'version' => $wp_version,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'version' => wp_get_wp_version(),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'http://api.wordpress.org/core/importers/1.1/'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $options = array( 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( wp_http_supports( array( 'ssl' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $url = set_url_scheme( $url, 'https' );
</span></span></pre></div>
<a id="trunksrcwpadminincludesplugininstallphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/plugin-install.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/plugin-install.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-admin/includes/plugin-install.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,9 +100,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * for more information on the make-up of possible return values depending on the value of `$action`.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function plugins_api( $action, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $args ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $args = (object) $args;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,7 +115,7 @@
</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"> if ( ! isset( $args->wp_version ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args->wp_version = substr( $wp_version, 0, 3 ); // x.y
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args->wp_version = substr( wp_get_wp_version(), 0, 3 ); // x.y
</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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,7 +165,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $http_args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'timeout' => 15,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = wp_remote_get( $url, $http_args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminincludesthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/theme.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-admin/includes/theme.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -493,9 +493,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * for more information on the make-up of possible return objects depending on the value of `$action`.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function themes_api( $action, $args = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $args ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $args = (object) $args;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -511,7 +508,7 @@
</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"> if ( ! isset( $args->wp_version ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $args->wp_version = substr( $wp_version, 0, 3 ); // x.y
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $args->wp_version = substr( wp_get_wp_version(), 0, 3 ); // x.y
</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"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -562,7 +559,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $http_args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'timeout' => 15,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $request = wp_remote_get( $url, $http_args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpadminincludestranslationinstallphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/translation-install.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/translation-install.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-admin/includes/translation-install.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,9 +17,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array|WP_Error On success an associative array of translations, WP_Error on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function translations_api( $type, $args = null ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,7 +43,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $options = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'timeout' => 3,
</span><span class="cx" style="display: block; padding: 0 10px"> 'body' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'wp_version' => $wp_version,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wp_version' => wp_get_wp_version(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'locale' => get_locale(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'version' => $args['version'], // Version of plugin, theme or core.
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -128,11 +125,8 @@
</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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $api = translations_api( 'core', array( 'version' => wp_get_wp_version() ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $api = translations_api( 'core', array( 'version' => $wp_version ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpadminincludesupdatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/update.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-admin/includes/update.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -264,11 +264,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $cur->response = '';
</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">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $is_development_version = preg_match( '/alpha|beta|RC/', wp_get_wp_version() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $is_development_version = preg_match( '/alpha|beta|RC/', $wp_version );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( $is_development_version ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return sprintf(
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: 1: WordPress version number, 2: URL to WordPress Updates screen. */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -854,8 +851,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return void|false
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function maintenance_nag() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
</del><span class="cx" style="display: block; padding: 0 10px"> global $upgrading;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $nag = isset( $upgrading );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -873,7 +868,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * This flag is cleared whenever a successful update occurs using Core_Upgrader.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $comparison = ! empty( $failed['critical'] ) ? '>=' : '>';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], $wp_version, $comparison ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $failed['attempted'] ) && version_compare( $failed['attempted'], wp_get_wp_version(), $comparison ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $nag = true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesfunctionsphp"></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/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/functions.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-includes/functions.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -9006,3 +9006,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo wp_kses_post( wp_get_admin_notice( $message, $args ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Returns the current WordPress Version.
+ *
+ * Returns an unmodified version of `$wp_version`. Some plugins modify the
+ * global in an attempt to improve security through obscurity. This
+ * practice can cause errors in WordPress so the ability to get an
+ * unmodified version is needed.
+ *
+ * @since 6.7.0
+ *
+ * @return string The current WordPress Version.
+ */
+function wp_get_wp_version() {
+ require ABSPATH . WPINC . '/version.php';
+
+ return $wp_version;
+}
</ins></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpatterndirectorycontrollerphp"></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/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -87,13 +87,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_items( $request ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * Include an unmodified `$wp_version`, so the API can craft a response that's tailored to
- * it. Some plugins modify the version in a misguided attempt to improve security by
- * obscuring the version, which can cause invalid requests.
- */
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $valid_query_args = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'offset' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'order' => true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,7 +99,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $query_args = array_intersect_key( $request->get_params(), $valid_query_args );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $query_args['locale'] = get_user_locale();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $query_args['wp-version'] = $wp_version;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $query_args['wp-version'] = wp_get_wp_version();
</ins><span class="cx" style="display: block; padding: 0 10px"> $query_args['pattern-categories'] = isset( $request['category'] ) ? $request['category'] : false;
</span><span class="cx" style="display: block; padding: 0 10px"> $query_args['pattern-keywords'] = isset( $request['keyword'] ) ? $request['keyword'] : false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></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/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-includes/script-loader.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -684,7 +684,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> static $suffixes;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( null === $suffixes ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Include an unmodified $wp_version.
+ *
+ * Note: wp_get_wp_version() is not used here, as this file can be included
+ * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case
+ * wp-includes/functions.php is not loaded.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/version.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1522,7 +1528,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_default_styles( $styles ) {
</span><span class="cx" style="display: block; padding: 0 10px"> global $editor_styles;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * Include an unmodified $wp_version.
+ *
+ * Note: wp_get_wp_version() is not used here, as this file can be included
+ * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case
+ * wp-includes/functions.php is not loaded.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/version.php';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! defined( 'SCRIPT_DEBUG' ) ) {
</span></span></pre></div>
<a id="trunksrcwpincludesupdatephp"></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/update.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/update.php 2024-07-26 07:54:26 UTC (rev 58812)
+++ trunk/src/wp-includes/update.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,8 +31,6 @@
</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">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
</del><span class="cx" style="display: block; padding: 0 10px"> $php_version = PHP_VERSION;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $current = get_site_transient( 'update_core' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,7 +37,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $translations = wp_get_installed_translations( 'core' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Invalidate the transient when $wp_version changes.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_object( $current ) && $wp_version !== $current->version_checked ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_object( $current ) && wp_get_wp_version() !== $current->version_checked ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $current = false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,7 +44,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_object( $current ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $current = new stdClass();
</span><span class="cx" style="display: block; padding: 0 10px"> $current->updates = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $current->version_checked = $wp_version;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $current->version_checked = wp_get_wp_version();
</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"> if ( ! empty( $extra_stats ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -95,7 +93,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $extensions = get_loaded_extensions();
</span><span class="cx" style="display: block; padding: 0 10px"> sort( $extensions, SORT_STRING | SORT_FLAG_CASE );
</span><span class="cx" style="display: block; padding: 0 10px"> $query = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'version' => $wp_version,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'version' => wp_get_wp_version(),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'php' => $php_version,
</span><span class="cx" style="display: block; padding: 0 10px"> 'locale' => $locale,
</span><span class="cx" style="display: block; padding: 0 10px"> 'mysql' => $mysql_version,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -191,7 +189,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $options = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'timeout' => $doing_cron ? 30 : 3,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'headers' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp_install' => $wp_install,
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp_blog' => home_url( '/' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -266,7 +264,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $updates = new stdClass();
</span><span class="cx" style="display: block; padding: 0 10px"> $updates->updates = $offers;
</span><span class="cx" style="display: block; padding: 0 10px"> $updates->last_checked = time();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $updates->version_checked = $wp_version;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $updates->version_checked = wp_get_wp_version();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $body['translations'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $updates->translations = $body['translations'];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -315,9 +313,6 @@
</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">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> // If running blog-side, bail unless we've not checked in the last 12 hours.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! function_exists( 'get_plugins' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . 'wp-admin/includes/plugin.php';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -423,7 +418,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'locale' => wp_json_encode( $locales ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'all' => wp_json_encode( true ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
</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"> if ( $extra_stats ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -590,9 +585,6 @@
</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">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $installed_themes = wp_get_themes();
</span><span class="cx" style="display: block; padding: 0 10px"> $translations = wp_get_installed_translations( 'themes' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -705,7 +697,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'translations' => wp_json_encode( $translations ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'locale' => wp_json_encode( $locales ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ),
</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"> if ( $extra_stats ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -989,14 +981,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @global string $wp_version The WordPress version string.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function _maybe_update_core() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Include an unmodified $wp_version.
- require ABSPATH . WPINC . '/version.php';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $current = get_site_transient( 'update_core' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $current->last_checked, $current->version_checked )
</span><span class="cx" style="display: block; padding: 0 10px"> && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked )
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- && $current->version_checked === $wp_version
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ && wp_get_wp_version() === $current->version_checked
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsfunctionswpGetWpVersionphp"></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/functions/wpGetWpVersion.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/functions/wpGetWpVersion.php (rev 0)
+++ trunk/tests/phpunit/tests/functions/wpGetWpVersion.php 2024-07-27 00:25:44 UTC (rev 58813)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,34 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+
+/**
+ * Tests for wp_get_wp_version().
+ *
+ * @group functions
+ *
+ * @covers ::wp_get_wp_version
+ */
+class Tests_Functions_WpGetWpVersion extends WP_UnitTestCase {
+
+ /**
+ * Tests that the WordPress version is returned.
+ *
+ * @ticket 61627
+ */
+ public function test_should_return_wp_version() {
+ $this->assertSame( $GLOBALS['wp_version'], wp_get_wp_version() );
+ }
+
+ /**
+ * Tests that changes to the `$wp_version` global are ignored.
+ *
+ * @ticket 61627
+ */
+ public function test_should_ignore_changes_to_wp_version_global() {
+ $original_wp_version = $GLOBALS['wp_version'];
+ $GLOBALS['wp_version'] = 'modified_wp_version';
+ $actual = wp_get_wp_version();
+ $GLOBALS['wp_version'] = $original_wp_version;
+
+ $this->assertSame( $original_wp_version, $actual );
+ }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/functions/wpGetWpVersion.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></div>
</body>
</html>