cedaro / satispress

Expose installed WordPress plugins and themes as Composer packages.
500 stars 48 forks source link

Fatal error, array passed as argument 1 in archive_on_upgrade #152

Closed kimmenbert closed 3 years ago

kimmenbert commented 3 years ago

Hi,

When adding new plugins we get this error: PHP Fatal error: Uncaught TypeError: Argument 1 passed to SatisPress\Provider\PackageArchiver::archive_on_upgrade() must be of the type boolean, array given, called in /home/satispress/****/www/wp-includes/class-wp-hook.php on line 287 and defined in /home/satispress/****/www/wp-content/plugins/satispress/src/Provider/PackageArchiver.php:214

Despite this, everything seems to work okay.

I think this happens on all plugin additions, but this was the process when I recieved this error now:

bradyvercher commented 3 years ago

I'm not sure what exactly was going on here, but I believe it should be fixed in ff73b3b. Is this just an issue with a single plugin?

kimmenbert commented 3 years ago

I think (need to test) this happens to every plugin we install.

Will test current release and add some logging to see what data is actually passed.

I guess the change you reference to here will fix the error, but maybe there is some underlying issue (perhaps in our setup) that I can find when logging.

bradyvercher commented 3 years ago

It could be a conflict with a single plugin or a server configuration issue of some sort. I'm not sure exactly, but let me know what you find out.

kimmenbert commented 2 years ago

Took a while, haven't really looked into it before now. This was caused by a single plugin that hooked into upgrader_post_install, wrongly returning the third parameter instead of the first, hence turning the first parameter of upgrader_post_install into an array (where you correctly expect to get an boolean)

The plugin has obviously used this guide when setting up a solution for plugin upgrades: https://code.tutsplus.com/tutorials/distributing-your-plugins-in-github-with-automatic-updates--wp-34817

And as you can see that guide contains a mistake:

public function postInstall( $true, $hook_extra, $result ) {
    return $result;
}
bradyvercher commented 2 years ago

Thanks for the follow up @kimmenbert. I don't think there's much I can do about that, so it'd probably be best to alert the developers of the plugin.

Even though a boolean is expected, it does look like WordPress will allow a WP_Error object, which is why I ended up making this particular change.