_idn_uri_convert() is not defined. functions.php file is included as soon as the autoload_packages.php file is required by the first plugin which has an older version of guzzle installed and the autoload files option is used by guzzleThe latest version of guzzle's functions.php of all dependencies to be loaded.
The first plugin loaded loads its version of the files rather than the latest version.
Jetpack autoloader should wait for all plugins to be loaded before including any files.
This is not a bug in the Jetpack Autoloader. It has more to do how the 2 different plugins calling the guzzlehttp/guzzle library the wrong way :(
How the autoloader know what file to load from where is by plugins telling the autoloader about the different libraries that are required the libraries.
In order for the autoloader to load the latest library the plugins need to wait for all the plugins to be loaded.
To do this in WordPress, plugins need to call libraries at the earliest on plugins_loaded hook.
Doing it before that results in a PHP error being thrown by the autoloader. See https://github.com/Automattic/jetpack/blob/master/packages/autoloader/src/autoload.php#L92
Hope that helps getting to the bottom of this.
In order for the autoloader to load the latest library the plugins need to wait for all the plugins to be loaded.
To do this in WordPress, plugins need to call libraries at the earliest on plugins_loaded hook.
You're right but even if both plugins wait for plugins_loaded before using guzzle it will still give this error. I can make two simple plugins if you need to be able to reproduce it.
I can make two simple plugins if you need to be able to reproduce it.
That'd be super helpful, thank you!
Here's two simple plugins with reproduce the problem. Both plugins load autoload_packages.php immediately but do not use guzzle until after plugins_loaded
jetpack-autoloader-failuer-example.zip
I like those plugins :smile:
Our Autoloader package only ensures that the latest versions of classes are loaded. As @superdav42 found, the files that just contain functions are loaded from whichever plugin is loaded first. You can see how the files are required here.
In Jetpack, we also autoload a few files. For example, in the Connection package, we autoload legacy/load-ixr.php. All of the autoloaded files for version 8.1 can be found in composer\autoload_files.php.
It looks like we should consider updating the Autoloader so that it requires the latest version of the autoloaded files.
It looks like we should consider updating the Autoloader so that it requires the latest version of the autoloaded files.
Yes, I believe we need to create an array for files just like we do for classes. Record the version with the file and only add files to the array if they are a newer version. Then after plugins_loaded require all the files that are registered.
I can鈥檛 think of any reason not to make this change. We'll need to set the priorities correctly for any add_action('plugins_loaded' calls in our autoloaded files, like this one in /compat/functions.php.