Commit 01abbee6 authored by Erick Hitter's avatar Erick Hitter
Browse files

Stop loading so much of the plugin before we know we're ready

Plugin could be half-activated, due to secret's absence, but Events Store would still capture data. As the rest of the plugin, notably its CLI commands, aren't loaded, this could store data into an unreachable hole. Also, with the introduction of a custom table, the table shouldn't be created when the environment isn't ready.
parent 4933d175
......@@ -11,13 +11,7 @@
namespace Automattic\WP\Cron_Control;
// Load basics needed to instantiate plugin
require __DIR__ . '/includes/constants.php';
require __DIR__ . '/includes/utils.php';
require __DIR__ . '/includes/abstract-class-singleton.php';
require __DIR__ . '/includes/class-lock.php';
// For data consistency, ensure alternate data store is always loaded
require __DIR__ . '/includes/class-events-store.php';
// Instantiate main plugin class, which checks environment and loads remaining classes when appropriate
require __DIR__ . '/includes/class-main.php';
......
......@@ -17,12 +17,8 @@ class Main extends Singleton {
return;
}
// Load dependencies
require __DIR__ . '/class-events.php';
require __DIR__ . '/class-internal-events.php';
require __DIR__ . '/class-rest-api.php';
require __DIR__ . '/functions.php';
require __DIR__ . '/wp-cli.php';
// Load balance of plugin
$this->load_plugin_classes();
// Block normal cron execution
$this->set_constants();
......@@ -34,6 +30,29 @@ class Main extends Singleton {
add_filter( 'cron_request', array( $this, 'block_spawn_cron' ) );
}
/**
* Load remaining classes
*
* Order here is somewhat important, as most classes depend on the Event Store,
* but we don't want to load it prematurely.
*/
private function load_plugin_classes() {
// Load event store and its dependencies
require __DIR__ . '/constants.php';
require __DIR__ . '/utils.php';
require __DIR__ . '/class-events-store.php';
// Load dependencies for remaining classes
require __DIR__ . '/class-lock.php';
// Load remaining functionality
require __DIR__ . '/class-events.php';
require __DIR__ . '/class-internal-events.php';
require __DIR__ . '/class-rest-api.php';
require __DIR__ . '/functions.php';
require __DIR__ . '/wp-cli.php';
}
/**
* Define constants that block Core's cron
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment