Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update minimum required version in PHP. #65301

Merged
merged 6 commits into from
Sep 13, 2024
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
6 changes: 4 additions & 2 deletions gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
### BEGIN AUTO-GENERATED DEFINES
defined( 'GUTENBERG_DEVELOPMENT_MODE' ) or define( 'GUTENBERG_DEVELOPMENT_MODE', true );
### END AUTO-GENERATED DEFINES
defined( 'GUTENBERG_MINIMUM_WP_VERSION' ) or define( 'GUTENBERG_MINIMUM_WP_VERSION', '6.5' );


gutenberg_pre_init();

Expand All @@ -26,7 +28,7 @@
function gutenberg_wordpress_version_notice() {
echo '<div class="error"><p>';
/* translators: %s: Minimum required version */
printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), '5.9' );
printf( __( 'Gutenberg requires WordPress %s or later to function properly. Please upgrade WordPress before activating Gutenberg.', 'gutenberg' ), GUTENBERG_MINIMUM_WP_VERSION );
echo '</p></div>';

deactivate_plugins( array( 'gutenberg/gutenberg.php' ) );
Expand Down Expand Up @@ -67,7 +69,7 @@ function gutenberg_pre_init() {
// Compare against major release versions (X.Y) rather than minor (X.Y.Z)
// unless a minor release is the actual minimum requirement. WordPress reports
// X.Y for its major releases.
if ( version_compare( $version, '5.9', '<' ) ) {
if ( version_compare( $version, GUTENBERG_MINIMUM_WP_VERSION, '<' ) ) {
add_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
return;
}
Expand Down
26 changes: 26 additions & 0 deletions phpunit/class-test-plugin-version-meta-test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Unit tests covering the version checks in the plugin file.
*
* @package Gutenberg
*/
class Test_PluginMetaData_Test extends WP_UnitTestCase {
/**
* Test the minimum WordPress version check.
*
* Ensures the constant defined as the minimum required version of WordPress
* matches the minimum version defined in the plugin header.
*/
public function test_minimum_required_wordpress_version() {
$file_meta = get_file_data( __DIR__ . '/../gutenberg.php', array( 'RequiresWP' => 'Requires at least' ) );
/*
* Gutenberg.php isn't loaded in the test environment.
*
* Read the file directly and use regex to extract the constant.
*/
preg_match( '/GUTENBERG_MINIMUM_WP_VERSION\', \'(.*?)\'/', file_get_contents( __DIR__ . '/../gutenberg.php' ), $matches );
$version_in_file = $matches[1];

$this->assertSame( $file_meta['RequiresWP'], $version_in_file, 'The minimum required WordPress version does not match the plugin header.' );
}
}
Loading