-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes Satispress creates an archive of the folder, not the content of the folder #142
Comments
It sounds like the vendor for that plugin is right clicking the folder on a Mac machine to create the zip file, which is why it has that SatisPress downloads updates as soon as they become available and caches them. When you delete that zip file, then uncheck/check the plugin, SatisPress will create a zip from the plugin source as it's installed in your WordPress instance instead. So the WordPress installer essentially normalizes the folder structure during installation. The next release has a basic validator for zip files, but ideally it would check for this scenario and either skip caching it or fix the structure. I think is pretty much the same as #127. |
It doesn't use the WordPress updater to do so?
Stupid suggestion but instead of having this validation/normalization on Satispress side, would it make sense to schedule a wp-cron to create the cache from WP instance on its next run? This way we let WP do all the heavy lifting of validation/normalization and then get the end result. The downside is that it would delay updates via Composer update by the next wp-cron. Personally, it would be no issues whatsoever but I don't know about the rest of the community. |
No, it uses the URL supplied to the WordPress updater, which should be a publicly accessible URL to a zip file. Some vendors don't package things correctly or implement non-standard update processes, though.
Packages are already cached from source on upgrade if the release doesn't exist, so wp-cron probably wouldn't do much here. Not downloading updates directly from the remote source means they can't be exposed to Composer unless the theme or plugin is updated in WordPress first. It also means some versions may not be cached if they haven't been in installed in WordPress, so a complete history wouldn't be available. Personally, I use SatisPress on a production website and don't want to update plugins before testing them in development, so there are some downsides to relying on the installed source only. I really think the package delivered directly from the vendor should be considered canonical in most situations. |
That's super interesting! I thought it did, so my "wp repo" has every single plugin activated and is slow as hell. So I can deactivate all of them?!
I totally get it now that I understand the underlying philosophy better - thanks for expanding on that. I update my production servers automatically for minor releases, but bigger ones I do check locally first indeed. For what it's worth, I host maybe 30 odd 3rd party plugins, and every single time I had that issue, it's been that problem of "Pluginname.zip/Pluginname" which, as you said, seems to be the same issue as #127 |
Unfortunately, no. The code has to run for the custom updaters to run, so the plugins need to be active. I guess if there were significant performance benefits, it would be possible to write adapters for each vendor and the plugin might not even have to be installed in the first place, but that sounds like it'd be a maintenance nightmare.
At the very least, it should be possible to check if the top level only contains directories and skip updates from the remote URL in that case. Normalization could be implemented in a future release. |
@patrick-leb I'm pretty sure the HiddenDirectoryValidator in the latest release should prevent this from happening in the future. Updates for plugins that do contain the |
@bradyvercher I thought we were out of the woods with that one but it's still happening :(
It happened with another plugin as well (woocommerce-product-search, AGAIN). Seems like it's always the same vendors not packaging their thing properly. |
@patrick-leb Dang! I thought that validator would handle that scenario. Do you have any idea why it's making it past that? |
I have no idea - I'm not even sure how to reproduce it... 😞 I was wondering since, by nomenclature (I believe...), WP is requiring the plugin entry file to be the same name as the folder. e.g: Maybe we can do a validator that checks that before building the archive? |
The validator is standalone, so you just need to feed it the path to a zip file and a release instance and it should let you know whether it's valid. There's a test for it here. Maybe the validator logic needs to be tweaked to account for different directory separators? Or the exception could be getting caught at some point? WordPress doesn't put any restrictions on the name of the plugin file. It could be |
I've downloaded the plugin from Woocommerce.com but it's zipped properly (aka no double folder, no __MACOSX folder). I don't know what they are doing. I don't know if they have a CRON that cleans up the archive and in some cases, my WP installs the update before it had a chance to run. Yet again, it should be caught by the validator. 🤷 I don't have time to investigate a lot these days, but I'll to put some logging on the live site to see what gives. |
I tried to debug the problem but your code is too smart for me :) The validator works in the unit tests with my invalid archives. so that's not the problem. It looks like to me, the code should work as intended. I don't know why it doesn't. Is there a way to prevent Satispress from checking the source URL and check the installed source instead? Something like having a flag in src/ReleaseManager.php:L88 that allows you to bypass the source_url and go directly to the "archive_from_source" call? |
Here's something you could try:
That should trigger an update check and automatically cache the latest release. If you inspect that file and it's fixed, then the vendor may have cleaned things up after the initial release. It still doesn't explain why the validator didn't work. Are you certain the invalid artifacts were cached after upgrading to a version of SatisPress with the validator present? There isn't a way to bypass that check at the moment. Archiving from source currently only happens when adding a package to the SatisPress repo or if one of those validators fails and the theme or plugin is updated in WordPress, so it requires manual action. Although with automatic updates enabled, that could potentially work similar to updating from the remote URL. |
So I do something similar (I guess) when it happens:
It works as well.
Yes, it happened with 0.7 and version 1.0 It happened again on April 6th. A customer called me asking why the B2B plugin disappeared (ouch...)
For my use case, it would be perfect. My Satispress install is basically a headless install and its sole purpose is to have auto-update activated and update all my paid plugins. satispress/src/ReleaseManager.php Lines 87 to 93 in 06678c7
This looks where we could bypass it, no? something (pseudo coding) like
What are your thoughts? |
The method I suggested was more for troubleshooting the source URL to double check that it was still coming from the vendor with the hidden directory. By deleting the cached artifact and the There are several use cases where automatic updates wouldn't be desired. Even for a headless SatisPress repo, a bad update could bring the server down. I'm not sure adding a flag there would totally fix the issue because SatisPress would still try to cache available updates, so it'd fall through and throw an exception in the My thinking is this is a bug that and the validators should handle it. I'd prefer to squash that instead of introduce a feature to side step it and potentially introduce more unexpected behavior. Squashing the bug should benefit all the use cases as well. If you really, really want to disable caching from remote URLs, you could register your own validator: add_filter( 'satispress_artifact_validators', function() {
return [
new class implements \SatisPress\Validator\ArtifactValidator {
public function validate( string $filename, \SatisPress\Release $release ): bool {
return false;
}
}
];
} ); Or filter the package download URLs to prevent them from even being downloaded: add_filter( 'satispress_package_download_url', '__return_false' ); I haven't tested either of those methods, but they should work in theory... |
Well I found the problem and I can't believe I didn't catch earlier: The filename is missing Test -> it should be HiddenDirectoryValidatorTest.php and THEN the test fails, the validator doesn't work :) Edit:
It's reported like that as well by pclZip:
|
Dang, I missed that, too! Thanks for digging into it more. Could you send me a copy of that plugin so I can update the test data and fix that validator (brady at blazersix dot com). |
Sent! thank you so much! |
@bradyvercher Just checking with you if you had the time to download the plugin before the link expired? |
Thanks for sending that link, @patrick-leb. I did have a chance to download it, so I'll try to look into that in the next day or two. |
The test file was missing the 'Test' suffix. The test fixture was also updated to use a zip file from a real plugin so the __MACOSX directory would be reported as a file rather than directory when being inspected by PclZip.
Hi @JulienMelissas, sorry to hear you're having an issue with this! Are you running the latest version of SatisPress? If so, could you send me a copy of the plugin and I'll try to do some debugging (brady at blazersix dot com). |
Hey @bradyvercher - thanks for the quick reply. And thanks for the great plugin... I don't know what we'd do without it. So I said I cleared all caches on last week but today after you wrote in I took a look and ran a |
I don't know why, it's intermittent and I'm unable to reproduce on command (aka, the perfect bug...)
Sometimes, the archive for a plugin updated by WordPress is created like this:
Where as it should be:
All I have to do is delete the archive on my satispress install:
Go on the plugin list, uncheck Satispress, check it again and the new archive is constructed properly.
Has this happened to anyone else?
Both my servers are on Ubuntu 20.04 and I don't understand why this
__MACOSX
dir is there.Thanks!
The text was updated successfully, but these errors were encountered: