Closed remcotolsma closed 10 months ago
Just tested this, but it's not working with automattic/jetpack-autoloader
☹️, reported in:
For now we can't use \Composer\InstalledVersions::getInstallPath( 'vendor/package' );
in our plugins.
If Automattic implements a solution we can review this, for now I will close this issue.
https://github.com/pronamic/wp-pay-core/commit/4afa13bdca7805179c488c849a223d3ff6bab89f
The "Action Scheduler" library is required for correct operation of our payment library:
https://github.com/pronamic/wp-pay-core/blob/529e6f2568a3e2fd380b23a08e32cf4b22af42a0/composer.json#L61
https://github.com/pronamic/wp-pay-core/blob/529e6f2568a3e2fd380b23a08e32cf4b22af42a0/src/Plugin.php#L299-L308
In WordPress plugins such as "Pronamic Pay" or "Pronamic Pay with Mollie for Gravity Forms" it is not immediately known in which folder the "Action Scheduler" library is located. However, we need to know this location to load the "Action Scheduler" library. To do this, we pass the "Action Scheduler" location when creating a plugin instance.
https://github.com/pronamic/wp-pronamic-pay/blob/e17985afe9c984ce9748ac956b98f4a12b884797/pronamic-ideal.php#L48C1-L57C3
https://github.com/pronamic/wp-pronamic-pay-with-mollie-for-gravity-forms/blob/0b20c960ef8174c12da414b4f1b1aa8b0f4046b8/pronamic-pay-with-mollie-for-gravity-forms.php#L44-L49
This works fine, but we have to define the location of the "Action Scheduler" library in more and more places. For example, while writing PHPUnit tests I also encountered the following error:
I can create the plugin instance in the PHPUnit bootstrap routine and pass the path of the "Action Scheduler", but I also recently came across the following:
https://getcomposer.org/doc/07-runtime.md#knowing-the-path-in-which-a-package-is-installed
Shall we change the following code?
https://github.com/pronamic/wp-pay-core/blob/529e6f2568a3e2fd380b23a08e32cf4b22af42a0/src/Plugin.php#L299-L308
To:
@rvdsteege What do you think? Can
\Composer\InstalledVersions::getInstallPath('vendor/package');
be used safely?