Skip to content
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

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

Closed
kimmenbert opened this issue Feb 26, 2021 · 5 comments
Closed

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

kimmenbert opened this issue Feb 26, 2021 · 5 comments

Comments

@kimmenbert
Copy link

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:

  • Had a plugin installed, but was not recieving updates
  • Deactivated and deleted the plugin
  • Added new version of plugin manually trough WordPress UI
  • Fatal error happened after "Installing plugin"
  • Upgraded version available trough composer, so all seems okay
bradyvercher added a commit that referenced this issue Feb 26, 2021
Removes the type hint on the first parameter in case a WP_Error object is passed
instead of boolean.
@bradyvercher
Copy link
Member

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
Copy link
Author

kimmenbert commented Feb 26, 2021

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants