OllieJones / index-wp-mysql-for-speed

A plugin to add useful indexes to your WordPress installation's MySQL database.
GNU General Public License v2.0
125 stars 10 forks source link

Warning message since new version #47

Closed patrick-leb closed 2 years ago

patrick-leb commented 2 years ago

FastCGI sent in stderr: "PHP message: PHP Warning: copy(/var/www/html/wordpress/web/app/mu-plugins/index-wp-mysql-for-speed-update-filter.php): failed to open stream: Permission denied in /var/www/html/wordpress/web/app/plugins/index-wp-mysql-for-speed/index-wp-mysql-for-speed.php on line 193PHP message: index-wp-mysql-for-speed: Unable to set up the mu-plugin to filter data definition language when preparing for a WordPress upgrade" while reading response header from upstream

Hey @OllieJones , as you know, big fan here!

I'm seeing this error pop up in my logs on the newest version of the plugin. This is because on my sites, wordpress is on read-only except for the upload folder. I manage all plugins via composer.

Is there a way to handle this setup?

Thanks!

OllieJones commented 2 years ago

My plugin places a file in mu-plugins . If your mu-plugins directory is locked down then it can't place the file.

The consequence of having the file missing during a version upgrade is some warnings from MySQL about indexes.

I'll be glad to make a change so this works via composer. Can you point me to some instructions about how to do that?

patrick-leb commented 2 years ago

I'm using Bedrock (like I feel everyone using WP with composer) https://docs.roots.io/bedrock/master/composer/#updating-wp-and-plugin-versions

Since your plugin is already published on wp.org, i think you only need a composer json file. However I'm not certain how to move just a file into mu-plugin.

You can specify your plugin to be a regular plugin or a mu-plugin in the composer.json file of your plugin, e.g like so: https://github.com/ymirapp/wordpress-plugin/blob/main/composer.json#L5

I wouldn't mind requiring your plugin as MU, if it allows you to skip the copy part. With Bedrock, we force a plugin into MU like so in the composer file: https://docs.roots.io/bedrock/master/mu-plugin-autoloader/

gregdev commented 2 years ago

Worth noting is the approach of copying a file into the mu-plugins directory won't work on sites running on multiple application servers - the copied file will only exist on whichever server handled the plugin install/upgrade request.

One approach could be for the plugin to check if it's in plugins or mu-plugins directory and then either copy or include the file as appropriate. If that approach was taken then a composer.json file could be added to this repo with a type of wordpress-muplugin so those who install it via composer get it as a must-use plugin.

OllieJones commented 2 years ago

Thanks for this. I confess the composer train left the station without me and I still have to figure out to climb on board. I will do that. My mu-plugin component fits in a single file, so it shouldn't be too hard.

I cribbed my current mu stuff from the Health Check and Troubleshooting plugin. And, Till's Redis Object Cache plugin appears to use a similar approach. I'll dig into those more carefully.

Again, thanks for your help.

OllieJones commented 2 years ago

Version 1.4.11 supports composer installation. You'll need to incorporate the following scripts in your top-level composer.json file if you want composer to handle the copying of the mu-plugin file from this plugin to the wp-content/mu-plugins directory.

"scripts": { "install-wp-mysql-mu-module": [ "@composer --working-dir=wordpress/wp-content/plugins/index-wp-mysql-for-speed install-mu-module" ], "post-install-cmd": [ "@install-wp-mysql-mu-module" ], "post-update-cmd": [ "@install-wp-mysql-mu-module" ] },