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

Set scheme before downloading relative scheme URLs. #1110

Merged
merged 1 commit into from
Jul 9, 2023

Conversation

peterwilsoncc
Copy link
Collaborator

@peterwilsoncc peterwilsoncc commented Jul 6, 2023

Description of the Change

Before calling the WordPress function download_url() in Utils\process_media() check for relative scheme URLs and set a scheme if required.

WordPress isn't a browser so will throw an error if a request is made to download a relative URL. Defaulting to http will ensure the most likelihood of success, if the site redirects to an HTTPS URL then WordPress will follow the redirect.

See #975

How to test the Change

  1. Set up Distributor on two WordPress sites
  2. In the wp-config.php file for each site, define WP_CONTENT_URL to use a relative scheme URL: define( 'WP_CONTENT_URL', '//' . $_SERVER['HTTP_HOST'] . '/wp-content' );
  3. Connect each site as an external connection to the other
  4. On site A, publish a post with a featured image.
  5. On site B, pull the post from site A using Distributor

On this branch the post should include the featured image, on develop the featured image should be missing.

Changelog Entry

Fixed - Account for relative scheme URLs when processing media.

Credits

Props @peterwilsoncc

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@peterwilsoncc peterwilsoncc marked this pull request as ready for review July 6, 2023 22:55
@peterwilsoncc peterwilsoncc requested a review from a team as a code owner July 6, 2023 22:55
@peterwilsoncc peterwilsoncc requested review from ravinderk and removed request for a team July 6, 2023 22:55
Copy link
Contributor

@ravinderk ravinderk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterwilsoncc I could not reproduce the issue but did not see the side effect of a minor change. For this reason, I am approving the pull request.

@jeffpaul jeffpaul added this to the 2.0.0 milestone Jul 7, 2023
@peterwilsoncc peterwilsoncc merged commit 9ef486a into develop Jul 9, 2023
@peterwilsoncc peterwilsoncc deleted the do/975-fix-relative-urls branch July 9, 2023 22:50
@jeffpaul jeffpaul mentioned this pull request Jul 13, 2023
16 tasks
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

Successfully merging this pull request may close these issues.

3 participants