WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#44653 closed defect (bug) (invalid)

wp_upload_dir not obeying HTTPS and forces everything to HTTP

Reported by: son9ne Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords: reporter-feedback
Focuses: Cc:

Description

This is a follow-up to #34945.

Bug is still present in 4.7.9. This has even been noted on the docs and a work-a-round is there too: https://developer.wordpress.org/reference/functions/wp_upload_dir/#comment-2576

This is due to a bug with: wp_upload_dir

When using HTTPS it is expected that wp_upload_dir() will respect the protocol, but it is always returning HTTP for URLs.

To test: setup an HTTPS site then use this in a plugin/theme. It will always return HTTP for the URLs

Change History (5)

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


2 years ago

#2 @SergeyBiryukov
2 years ago

  • Keywords reporter-feedback added

Hi @son9ne, welcome to WordPress Trac!

What are your WordPress Address and Site Address in General Settings?

Related: #33092, #44636.

#3 @son9ne
2 years ago

Thank you!

I am using the constants:

define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME'] . '/wordpress');
define('WP_HOME', 'https://' . $_SERVER['SERVER_NAME']);

Just to be safe, I also checked the options table to ensure it is using https:// as well and it is.

#4 @son9ne
2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Ok, after looking more into this issue. It seems this is due to a special setup I have. I am using a single install of WordPress to serve numerous sites. Each site has it's own wp-content and this is defined in their configs.

The issue here is that I needed a global config due to how WordPress steps out a directory to locate the config file. This has a constant using http:// and not obeying the constant. I am then assigning that custom constant to WP_CONTENT_URL and that seems to be the culprit.

I have not tested this theory but I feel pretty confident that is the issue. I saw the issue on the docs so immediately assumed. I should have spent more time looking into this. Sorry to waste your time.

Version 0, edited 2 years ago by son9ne (next)

#5 @netweb
2 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.