Skip to content

Commit 142adbf

Browse files
fix: delete redundant datamachine_check_requirements() (#1919) (#1924)
The plugin header already declares every requirement the custom function checked: Requires at least: 7.0 Requires PHP: 8.2 Requires Plugins: agents-api WordPress core (6.5+ for `Requires at least`/`Requires PHP`, 6.6+ for `Requires Plugins`) reads these headers and: * Refuses to activate the plugin if WP or PHP is below the minimum. * Refuses to activate if `agents-api` is missing. * Surfaces user-friendly admin notices on the plugins screen. * Compares versions via `is_wp_version_compatible()` / `is_php_version_compatible()`, the canonical contract for "does this version satisfy the requirement." `datamachine_check_requirements()` reimplemented a strict subset of this with worse behavior: * Naive `version_compare( $wp, '7.0', '<' )` rejected WP 7.0 RC nightlies because PHP treats `7.0-RC3` as < `7.0` (RC sorts before final). This was the bug that motivated #1919 — DM 0.107.0 silently no-op'd on every WP 7.0 RC site, no fatal, no frontend-visible signal, and no CLI commands registered. * The vendor/autoload.php existence check was redundant — if the file is missing, the next `require_once` at line 26 fatals immediately, which is a louder, better signal to the developer than a buried admin notice. * The admin_notices callbacks only fired in `wp-admin`, so frontend operators never saw the failure mode. Delete the function and the early-return guard. Trust the plugin header. Removed: * Lines 21-23: `if ( ! datamachine_check_requirements() ) { return; }` * Lines 829-861: the `datamachine_check_requirements()` function Net: -39 lines, no functional regressions on any supported WP/PHP version. Closes #1919 Co-authored-by: homeboy-ci[bot] <266378653+homeboy-ci[bot]@users.noreply.github.com>
1 parent 54224db commit 142adbf

1 file changed

Lines changed: 0 additions & 39 deletions

File tree

data-machine.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
die;
1919
}
2020

21-
if ( ! datamachine_check_requirements() ) {
22-
return;
23-
}
24-
2521
define( 'DATAMACHINE_VERSION', '0.107.0' );
2622

2723
define( 'DATAMACHINE_PATH', plugin_dir_path( __FILE__ ) );
@@ -824,38 +820,3 @@ function datamachine_on_new_site( \WP_Site $new_site ) {
824820

825821
// Migrations, scaffolding, and activation helpers.
826822
require_once __DIR__ . '/inc/migrations/load.php';
827-
828-
829-
function datamachine_check_requirements() {
830-
global $wp_version;
831-
$current_wp_version = $wp_version ?? '';
832-
if ( '' !== $current_wp_version && ! wp_installing() && version_compare( $current_wp_version, '7.0', '<' ) ) {
833-
add_action(
834-
'admin_notices',
835-
function () use ( $current_wp_version ) {
836-
echo '<div class="notice notice-error"><p>';
837-
printf(
838-
esc_html( 'Data Machine requires WordPress %2$s or higher. You are running WordPress %1$s.' ),
839-
esc_html( $current_wp_version ),
840-
'7.0'
841-
);
842-
echo '</p></div>';
843-
}
844-
);
845-
return false;
846-
}
847-
848-
if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
849-
add_action(
850-
'admin_notices',
851-
function () {
852-
echo '<div class="notice notice-error"><p>';
853-
echo esc_html( 'Data Machine: Composer dependencies are missing. Please run "composer install" or contact Chubes to report a bug.' );
854-
echo '</p></div>';
855-
}
856-
);
857-
return false;
858-
}
859-
860-
return true;
861-
}

0 commit comments

Comments
 (0)