Better error response when fetching attachments. Props DD32. see #7944

git-svn-id: https://develop.svn.wordpress.org/trunk@9327 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-10-24 18:22:43 +00:00
parent 979442ccd6
commit 9e467a6850
2 changed files with 9 additions and 1 deletions

View File

@@ -604,10 +604,16 @@ class WP_Import {
// fetch the remote url and write it to the placeholder file
$headers = wp_get_http($url, $upload['file']);
//Request failed
if ( ! $headers ) {
@unlink($upload['file']);
return new WP_Error( 'import_file_error', __('Remote server did not respond') );
}
// make sure the fetch was successful
if ( $headers['response'] != '200' ) {
@unlink($upload['file']);
return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %d'), intval($headers['response'])) );
return new WP_Error( 'import_file_error', sprintf(__('Remote file returned error response %1$d %2$s'), $headers['response'], get_status_header_desc($headers['response']) ) );
}
elseif ( isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length'] ) {
@unlink($upload['file']);