Skip to content

Commit 429fc4e

Browse files
committed
fix; use version_compare to simplify incompatible dependent check
1 parent 616760d commit 429fc4e

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

src/Admin/Updates/UpdateChecker.php

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,6 @@ private function get_all_plugins(): array {
450450
* @param string $version The current version to check against.
451451
*/
452452
private function is_incompatible_dependent( string $plugin_path, string $version = WPGRAPHQL_VERSION ): bool {
453-
$current_version = SemVer::parse( $version );
454-
455-
if ( null === $current_version ) {
456-
return false;
457-
}
458-
459453
$all_plugins = $this->get_all_plugins();
460454
$plugin_data = $all_plugins[ $plugin_path ] ?? null;
461455

@@ -464,28 +458,8 @@ private function is_incompatible_dependent( string $plugin_path, string $version
464458
return false;
465459
}
466460

467-
// Parse the version.
468-
$minimum_version = SemVer::parse( $plugin_data[ self::VERSION_HEADER ] );
469-
470-
if ( null === $minimum_version ) {
471-
return false;
472-
}
473-
474-
// Check if the plugin is incompatible.
475-
if ( $minimum_version['major'] > $current_version['major'] ) {
476-
return true;
477-
}
478-
479-
if ( $minimum_version['minor'] > $current_version['minor'] ) {
480-
return true;
481-
}
482-
483-
if ( $minimum_version['patch'] > $current_version['patch'] ) {
484-
return true;
485-
}
486-
487-
// The plugin is compatible.
488-
return false;
461+
// The version is incompatible if the current version is less than the required version.
462+
return version_compare( $version, $plugin_data[ self::VERSION_HEADER ], '<' );
489463
}
490464

491465
/**

0 commit comments

Comments
 (0)