Skip to content

Commit 6255b33

Browse files
committed
General: Use clean WordPress version in is_wp_version_compatible().
Update `is_wp_version_compatible()` to use `wp_get_wp_version()` introduced in [58813] to ensure the value of `$wp_version` has not been modified by a theme or plugin. Props costdev, mukesh27, Cybr, sergeybiryukov. Fixes #61781. Built from https://develop.svn.wordpress.org/trunk@58843 git-svn-id: https://core.svn.wordpress.org/trunk@58239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent fc3c4ef commit 6255b33

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

wp-includes/functions.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8833,13 +8833,21 @@ function wp_get_wp_version() {
88338833
*
88348834
* @since 5.2.0
88358835
*
8836-
* @global string $wp_version The WordPress version string.
8836+
* @global string $_wp_tests_wp_version The WordPress version string. Used only in Core tests.
88378837
*
88388838
* @param string $required Minimum required WordPress version.
88398839
* @return bool True if required version is compatible or empty, false if not.
88408840
*/
88418841
function is_wp_version_compatible( $required ) {
8842-
global $wp_version;
8842+
if (
8843+
defined( 'WP_RUN_CORE_TESTS' )
8844+
&& WP_RUN_CORE_TESTS
8845+
&& isset( $GLOBALS['_wp_tests_wp_version'] )
8846+
) {
8847+
$wp_version = $GLOBALS['_wp_tests_wp_version'];
8848+
} else {
8849+
$wp_version = wp_get_wp_version();
8850+
}
88438851

88448852
// Strip off any -alpha, -RC, -beta, -src suffixes.
88458853
list( $version ) = explode( '-', $wp_version );

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.7-alpha-58842';
19+
$wp_version = '6.7-alpha-58843';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)