Ensure that updating an uploaded file using AtomPub works correct. Fixes #9233 for trunk props josephscott

git-svn-id: http://svn.automattic.com/wordpress/trunk@10663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-02-27 18:37:02 +00:00
parent 6eb64d687b
commit 1629f412ab
1 changed files with 8 additions and 0 deletions

View File

@ -26,6 +26,9 @@ require_once(ABSPATH . WPINC . '/atomlib.php');
/** Feed Handling API */ /** Feed Handling API */
require_once(ABSPATH . WPINC . '/feed.php'); require_once(ABSPATH . WPINC . '/feed.php');
/** Admin Image API for metadata updating */
require_once(ABSPATH . '/wp-admin/includes/image.php');
$_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); $_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] );
/** /**
@ -814,9 +817,12 @@ EOD;
$this->auth_required(__('Sorry, you do not have the right to edit this post.')); $this->auth_required(__('Sorry, you do not have the right to edit this post.'));
} }
$upload_dir = wp_upload_dir( );
$location = get_post_meta($entry['ID'], '_wp_attached_file', true); $location = get_post_meta($entry['ID'], '_wp_attached_file', true);
$filetype = wp_check_filetype($location); $filetype = wp_check_filetype($location);
$location = "{$upload_dir['basedir']}/{$location}";
if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext'])) if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
$this->internal_error(__('Error ocurred while accessing post metadata for file location.')); $this->internal_error(__('Error ocurred while accessing post metadata for file location.'));
@ -843,6 +849,8 @@ EOD;
$this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.'));
} }
wp_update_attachment_metadata( $postID, wp_generate_attachment_metadata( $postID, $location ) );
log_app('function',"put_file($postID)"); log_app('function',"put_file($postID)");
$this->ok(); $this->ok();
} }