jetpack
jetpack copied to clipboard
Runtime Composer utility `\Composer\InstalledVersions::getInstallPath( 'woocommerce/action-scheduler' )` does not work with `jetpack-autoloader`
Impacted plugin
None / Other
Quick summary
To load Action Scheduler into one of our plugins we use the following code:
$action_scheduler_path = InstalledVersions::getInstallPath( 'woocommerce/action-scheduler' );
require_once $action_scheduler_path . '/action-scheduler.php';
This works if we use the default Composer autoload file:
require_once __DIR__ . '/vendor/autoload.php';
If we switch to https://github.com/automattic/jetpack-autoloader we get an error:
Fatal error: Uncaught Error: Class "Composer\InstalledVersions" not found
Or:
Fatal error: Uncaught OutOfBoundsException: Package "woocommerce/action-scheduler" is not installed
Steps to reproduce
I have created a test plugin to reproduce the issue: https://github.com/remcotolsma/reproduce-composer-utility-issue-with-jetpack-autoloader
A clear and concise description of what you expected to happen.
It would be nice if the runtime Composer utilities still work with the Jetpack autoloader.
What actually happened
The runtime Composer utilities are not available or the utility classes are not aware of the packages loaded via the Jetpack autoloader.
Impact
Some (< 50%)
Available workarounds?
There is no user impact
Platform (Simple and/or Atomic)
No response
Logs or notes
No response