PluginProbe
ActivityPub / 9.2.1
ActivityPub v9.2.1
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | integration/class-litespeed-cache.php +11 -8 8.2.1 → 9.2.1 View file →
@@ -22,9 +22,9 @@
22 22 * @var string
23 23 */
24 24 public static $rules = '<IfModule LiteSpeed>
25 25 RewriteEngine On
26 -RewriteCond %{HTTP:Accept} application
26 +RewriteCond %{HTTP:Accept} ^[\s,]*(application/activity\+json|application/ld\+json[^,]*activitystreams) [NC]
27 27 RewriteRule ^ - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+isjson]
28 28 </IfModule>';
29 29
30 30 /**
@@ -53,9 +53,11 @@
53 53 */
54 54 public static function init() {
55 55 // Add rules if LiteSpeed Cache is active and rules aren't set.
56 56 if ( is_plugin_active( self::$plugin_slug ) ) {
57 - if ( ! \get_option( self::$option_name ) ) {
57 + // (Re)write when the installed rules differ from the current ones: first setup, or a rules
58 + // update that must replace a previously written (looser) block on existing installs.
59 + if ( \get_option( self::$option_name ) !== \md5( self::$rules ) ) {
58 60 self::add_htaccess_rules();
59 61 }
60 62
61 63 \add_filter( 'site_status_tests', array( self::class, 'add_site_health_test' ) );
@@ -85,10 +87,11 @@
85 87 */
86 88 public static function add_htaccess_rules() {
87 89 $added_rules = self::append_with_markers( self::$marker, self::$rules );
88 90
91 + // Store a fingerprint of the written rules so a later change re-applies them (see init()).
89 92 if ( $added_rules ) {
90 - \update_option( self::$option_name, '1' );
93 + \update_option( self::$option_name, \md5( self::$rules ) );
91 94 } else {
92 95 \update_option( self::$option_name, '0' );
93 96 }
94 97 }
@@ -180,13 +183,13 @@
180 183
181 184 $htaccess = $wp_filesystem->get_contents( $htaccess_file );
182 185
183 186 // If marker exists, remove the old block first.
184 - if ( strpos( $htaccess, $marker ) !== false ) {
187 + if ( \strpos( $htaccess, $marker ) !== false ) {
185 188 // Remove existing marker block.
186 - $pattern = '/# BEGIN ' . preg_quote( $marker, '/' ) . '.*?# END ' . preg_quote( $marker, '/' ) . '\r?\n?/s';
187 - $htaccess = preg_replace( $pattern, '', $htaccess );
188 - $htaccess = trim( $htaccess );
189 + $pattern = '/# BEGIN ' . \preg_quote( $marker, '/' ) . '.*?# END ' . \preg_quote( $marker, '/' ) . '\r?\n?/s';
190 + $htaccess = \preg_replace( $pattern, '', $htaccess );
191 + $htaccess = \trim( $htaccess );
189 192 }
190 193
191 194 // If rules are empty, just return (for removal case).
192 195 if ( empty( $rules ) ) {
@@ -214,9 +217,9 @@
214 217 // Ensure get_home_path() is declared.
215 218 require_once ABSPATH . 'wp-admin/includes/file.php';
216 219
217 220 // phpcs:ignore WordPress.PHP.NoSilencedErrors
218 - if ( @file_exists( \get_home_path() . '.htaccess' ) ) {
221 + if ( @\file_exists( \get_home_path() . '.htaccess' ) ) {
219 222 /** The htaccess file resides in ABSPATH */
220 223 $htaccess_file = \get_home_path() . '.htaccess';
221 224 }
222 225