-
Notifications
You must be signed in to change notification settings - Fork 156
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
Use filesystem for copying media when doing a network pull/push #567
Use filesystem for copying media when doing a network pull/push #567
Conversation
@@ -144,7 +144,7 @@ public function push( $post_id, $args = array() ) { | |||
* @return {bool} If Distributor should push the post media. | |||
*/ | |||
if ( apply_filters( 'dt_push_post_media', true, $new_post_id, $media, $post_id, $args, $this ) ) { | |||
\Distributor\Utils\set_media( $new_post_id, $media ); | |||
\Distributor\Utils\set_media( $new_post_id, $media, [ 'use_filesystem' => true ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR works in my test. But I think we only use filesystem for network connection, so we can use DT_IS_NETWORK
to detect multisite installations without introducing a new argument for set_media
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petenelson What do you think about my comment above? (Forgot to tag you 😅)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dinhtungdu So I think the only issue using that constant here is that is only set to true if we are on multisite and if Distributor is network activated. So there's a chance someone could be using multisite but not have the plugin network activated, just activated on the individual sites they want to use. In that case, using that constant wouldn't work
As there's still a requested change on this PR, I'm going to move this to our next release so we can clear the 1.6 milestone and get to a release. |
Made some minor formatting changes and fixed the unit tests. This works well in my tests 👍 |
Hi There, Is there any chance of 2.1 coming out? just regarding the Featured images not pulling through to duplicate sites? Cheers |
Description of the Change
Use filesystem for copying media when doing a network pull/push instead of
download_url()
Benefits
For network/multisite on the same server, there should be no need to make an HTTP request to download media when doing a pull or push. In some instances, due to DNS resolution, firewalls, HTTP authentication, etc, downloading media via a URL may fail. This update uses the filesystem to copy media rather than downloading it.
Possible Drawbacks
None that I am aware of.
Verification Process
Added some debugging code to save
dt_original_file_path
to post meta that is only updated when a file is copied successfully. Performed both multisite pushes and pulls to confirm the media is copied.Checklist:
Applicable Issues
#380
Changelog Entry
download_url()