PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-waf/src/class-waf-initializer.php +9 -4 13.7.2 → 16.3-beta View file →
@@ -16,9 +16,9 @@
16 16 */
17 17 class Waf_Initializer {
18 18
19 19 /**
20 - * Option for storing whether or not the WAF files are potentially out of date.
20 + * Option for storing whether the WAF files are potentially out of date.
21 21 *
22 22 * @var string NEEDS_UPDATE_OPTION_NAME
23 23 */
24 24 const NEEDS_UPDATE_OPTION_NAME = 'jetpack_waf_needs_update';
@@ -35,10 +35,11 @@
35 35
36 36 // Ensure backwards compatibility
37 37 Waf_Compatibility::add_compatibility_hooks();
38 38
39 - // Register REST routes
40 - add_action( 'rest_api_init', array( new REST_Controller(), 'register_rest_routes' ) );
39 + // Register REST routes. Use a static callable so the controller class is not
40 + // loaded into memory/opcache on requests that never reach `rest_api_init`.
41 + add_action( 'rest_api_init', array( REST_Controller::class, 'register_rest_routes' ) );
41 42
42 43 // Update the WAF after installing or upgrading a relevant Jetpack plugin
43 44 add_action( 'upgrader_process_complete', __CLASS__ . '::update_waf_after_plugin_upgrade', 10, 2 );
44 45
@@ -131,8 +132,12 @@
131 132 public static function update_waf_after_plugin_upgrade( $upgrader, $hook_extra ) {
132 133 $jetpack_text_domains_with_waf = array( 'jetpack', 'jetpack-protect' );
133 134 $jetpack_plugins_with_waf = array( 'jetpack/jetpack.php', 'jetpack-protect/jetpack-protect.php' );
134 135
136 + $hook_extra['type'] ??= null;
137 + $hook_extra['action'] ??= null;
138 + $hook_extra['plugins'] ??= array();
139 +
135 140 // Only run on upgrades affecting plugins
136 141 if ( 'plugin' !== $hook_extra['type'] ) {
137 142 return;
138 143 }
@@ -150,9 +155,9 @@
150 155 return;
151 156 }
152 157 if ( 'install' === $hook_extra['action'] &&
153 158 ! empty( $upgrader->new_plugin_data['TextDomain'] ) &&
154 - empty( in_array( $upgrader->new_plugin_data['TextDomain'], $jetpack_text_domains_with_waf, true ) )
159 + empty( in_array( $upgrader->new_plugin_data['TextDomain'] ?? null, $jetpack_text_domains_with_waf, true ) )
155 160 ) {
156 161 return;
157 162 }
158 163