Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 799 forks source link

WP Super Cache: iThemes Security overwrites the WP_CACHE define in wp-config.php #32462

Open donnchawp opened 1 year ago

donnchawp commented 1 year ago

Impacted plugin

Super Cache

Quick summary

The iThemes Security plugin sometimes writes to the file wp-config.php and deletes the WP_CACHE define added by WP Super Cache.

The code that WP Super Cache uses to update the config files searches for a string to add a new settings above it. In the case of the wp-config.php, it matches on "define", but it appears likely that iThemes Security adds a define(), which gets matched. That causes the configuration of both plugins to be mixed up.

We will have to update the code that modifies wp-config.php to avoid this problem, probably by checking for the opening PHP tag instead.

It looks like it only happens if WP Super Cache is enabled after the other plugin.

Steps to reproduce

I gather from the forum post that iThemes Security occasionally updates their configuration data, and WP Super Cache will add the WP_CACHE define in there if it is enabled afterwards.

A clear and concise description of what you expected to happen.

The configuration data for both plugins to be separated

What actually happened

The WP_CACHE define for WP Super Cache is inserted into the iThemes Security plugin configuration data in wp-config.php and is deleted if that plugin updates the configuration data.

Impact

Some (< 50%)

Available workarounds?

Yes, easy to implement

Platform (Simple and/or Atomic)

Self-hosted

Logs or notes

No response

donnchawp commented 1 year ago

A simple way to fix this is by modifying the "replace_line" function in the plugin so it looks for the first opening PHP tag, rather than the "if ( define" string it currently uses. It can add the new line after that tag. Another way would be to add the new line right at the top of the file, enclosed by open and closing PHP tags.

donnchawp commented 12 months ago

Another ticket: https://wordpress.org/support/topic/conflict-with-ithemes-security-7/

JayHoltslander commented 11 months ago

It looks like it only happens if WP Super Cache is enabled after the other plugin.

Good to know.