johnbillion / query-monitor

The developer tools panel for WordPress
https://querymonitor.com
GNU General Public License v2.0
1.59k stars 208 forks source link

Disabling QM on sub-site removes `db.php` for network #820

Closed crstauf closed 11 months ago

crstauf commented 11 months ago

Crazy timing! I came to look up a different issue and was curious about this one. I've been trying to understand why my db.php symlink kept going away, and it is exactly the case that deactivating it on a single site in multisite removes the symlink (and yes we have DISALLOW_FILE_MODS in place).

For reference, I've been manually creating the symlink per the instructions here: https://github.com/johnbillion/query-monitor/wiki/db.php-Symlink

Originally posted by @MadtownLems in https://github.com/johnbillion/query-monitor/issues/817#issuecomment-1749593575

johnbillion commented 11 months ago

This is an interesting use case. If QM is active on one site on the network and I deactivate it on that site, I would expect the db.php file to be deleted too as it's no longer needed, but it might be active on another site on the network.

I don't want to introduce code to check the active status on all sites on the network because that's a mess. I think QM should not delete the db.php file when it's deactivated on a single site on the network. The file is harmless when QM isn't active anyway.

crstauf commented 11 months ago

It's surprising that there aren't separate functions for network de/activations.

MadtownLems commented 11 months ago

It's surprising that there aren't separate functions for network de/activations.

I believe that whether it's network or not is passed in action calls: https://developer.wordpress.org/reference/hooks/activate_plugin/

However, I don't think that helps a ton, because of the following situation:

Subsite A has Query Monitor locally activated. Then QM is network activated. Then QM is network deactivated. Subsite A still has QM locally activated, and thus, should still be using db.php

crstauf commented 11 months ago

Oh, interesting. I was expecting there'd be register_network_activation_hook() function (and similar deactivation function), but that could work.