﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
9233	Updating an uploaded media file via AtomPub PUT fails	josephscott	josephscott	"Tim Armes reported on the wp-xmlrpc email list that attempts to update media uploads via AtomPub PUT are failing:

{{{
Finally, I've discovered a more serious problem.  It's not possible to
PUT an updated image file.  Wordpress returns 200 to say that it's all
worked, but in reality it hasn't.  I tracked it down to this code in
the put_file function:

		$location = get_post_meta($entry['ID'], '_wp_attached_file', true);
		$filetype = wp_check_filetype($location);

		if(!isset($location) || 'attachment' != $entry['post_type'] ||
empty($filetype['ext']))
			$this->internal_error(__('Error ocurred while accessing post
metadata for file location.'));

		$fp = fopen(""php://input"", ""rb"");
		$localfp = fopen($location, ""w+"");
log_app(""tim"", $location);
		while(!feof($fp)) {
			fwrite($localfp,fread($fp, 4096));
		}
		fclose($fp);
		fclose($localfp);

When I PUT to ..../attachement/file/ID the code tries to locate the
physical file and overwrite it.  The problem is that $location
actually gets the path relative to the uploads folder, so it contains
something like 2009/02/myfile.jpg
}}}

I've included a patch to fix the location problem by looking up the proper upload dir via wp_upload_dir().  With the patch I've confirmed that updates to an uploaded file via AtomPub PUT work.

I noticed another problem though, it only updates the original file, not the generated versions or the meta data.  This is particularly bad if the updated image is a different size.  I tried calling wp_generate_attachment_metadata() after updating the image, but it didn't update the generated images or the meta data about the image."	defect (bug)	closed	normal	2.7.2	AtomPub	2.7.1	normal	fixed	has-patch	josephscott westi
