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

fix: WC_STRIPE_PLUGIN_URL when pointing to symbolic link #3029

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dkoo
Copy link

@dkoo dkoo commented Mar 28, 2024

Changes proposed in this Pull Request:

Description: Fixes an esoteric bug that only seems to happen when the plugin is installed in a server location that is both unavailable for public HTTP requests and then symlinked to the wp-content/plugins folder. Some hosts have a directory structure like this in order to manage plugin versions across multiple sites from a single server directory.

In this scenario, the WC_STRIPE_PLUGIN_URL constant will include the path to the inaccessible server directory instead of the wp-content/plugins directory, potentially resulting in 400 errors when fetching CSS and JS assets using this constant. The resulting errors break user-facing functionality at the point of checkout.

Not sure how this could be unit-tested, but open to adding if you think it's necessary.

Testing instructions

  1. In your test environment, install the plugin in a location where WordPress can't access it via HTTP, but your local environment can. (For example, if using a Docker environment, install it somewhere on the host machine outside of where the Docker container can access the file. This isn't a requirement, but will make the bug more apparent.) Name the plugin directory something different, such as the version number of the plugin (e.g. 8.0.1).
  2. In your test environment's shell environment, cd into the wp-content/plugins directory and create a symbolic link to the "true" location of the plugin: ln -s <absolute path to source directory>/8.0.1 woocommerce-gateway-stripe
  3. If you want to see the constant in action, you can add a var_dump( WC_STRIPE_PLUGIN_URL );after line 31 of ./woocommerce-gateway-stripe.php.
  4. While on develop, visit your site's front-end and observe that the WC_STRIPE_PLUGIN_URL constant points to the source directory's parent directory instead of the symlinked directory:
https://<site URL>/wp-content/plugins/8.0.1
  1. If the source directory isn't accessible to WordPress, try to check out using the Stripe Gateway and see that you can't complete the transaction due to missing JS and CSS assets.
  2. Apply the patch in this PR and repeat, and confirm that the constant now contains the symlinked folder location (https://<site URL>/wp-content/plugins/woocommerce-gateway-stripe) and that you can now complete checkout on the front-end.

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Added changelog entry in both changelog.txt and readme.txt (or does not apply)
  • Tested on mobile (or does not apply)

Post merge

@dkoo dkoo added the type: bug The issue is a confirmed bug. label Mar 28, 2024
@dkoo dkoo self-assigned this Mar 28, 2024
@github-actions github-actions bot added the Stale label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant