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(media-uploads): WP's media uploader is uploading to incorrect directory when Give is active #2830

Closed
DevinWalker opened this Issue Feb 21, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@DevinWalker
Member

DevinWalker commented Feb 21, 2018

Issue Overview

Reported on WP.org and I was able to reproduce: https://wordpress.org/support/topic/media-uploading-to-wrong-date/#post-9996779

It was thought that it was multisite related but I was able to reproduce on a standard install.

See video: https://goo.gl/vf2z4E

Expected Behavior

Standard WP media uploads are unaffected by Give plugin.

Current Behavior

Uploads are going to an incorrect folder directory.

Possible Solution

Steps to Reproduce (for bugs)

Watch video: https://goo.gl/vf2z4E

@mehul0810

This comment has been minimized.

Contributor

mehul0810 commented Feb 21, 2018

@ravinderk
After doing research on this issue, I've noticed that code of Give Core is affecting global variable $GLOBALS['post'] due to which when uploading image manipulates get_post fn used in media_handle_upload() when passed with null value returns the latest Give Donation Form object - strange behaviour. Still looking what is affecting this to happen.

To check what happens, print $post and die() here https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/media.php#L296 and then upload an image and check network tab to see the async-upload response

@ravinderk

This comment has been minimized.

Collaborator

ravinderk commented Feb 21, 2018

@DevinWalker @mathetos This is known bug in WP core. To fix this issue I am using get_posts instead of WP_Query #2831 because wp_reset_postdata does not work in admin.

For Ref:
https://ryanwelcher.com/2014/11/resetting-post-wordpress-admin/
https://core.trac.wordpress.org/ticket/18408

DevinWalker added a commit that referenced this issue Feb 21, 2018

Merge pull request #2831 from /issues/2830
fix(media-uploads): upload file to correct folder #2830
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment