Changeset 46174 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 09/19/2019 01:25:14 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r46155 r46174 2423 2423 } 2424 2424 2425 // Using Plupload `file.id` as ref. 2426 if ( ! empty( $_POST['_wp_temp_image_ref'] ) ) { 2427 $image_ref = preg_replace( '/[^a-zA-Z0-9_]/', '', $_POST['_wp_temp_image_ref'] ); 2425 if ( ! empty( $_POST['_wp_temp_upload_ref'] ) ) { 2426 // Uploading of images usually fails while creating the sub-sizes, either because of a timeout or out of memory. 2427 // At this point the file has been uploaded and an attachment post created, but because of the PHP fatal error 2428 // the cliend doesn't know the attachment ID yet. 2429 // To be able to find the new attachment_id in these cases we temporarily store an upload reference sent by the client 2430 // in the original upload request. It is used to save a transient with the attachment_id as value. 2431 // That reference currently is Plupload's `file.id` but can be any sufficiently random alpha-numeric string. 2432 $attachment_id = _wp_get_upload_ref_attachment_id( $_POST['_wp_temp_upload_ref'] ); 2428 2433 } else { 2429 2434 wp_send_json_error( array( 'message' => __( 'Invalid file reference.' ) ) ); 2430 2435 } 2431 2432 // Uploading of images usually fails while creating the sub-sizes, either because of a timeout or out of memory.2433 // At this point the file has been uploaded and an attachment post created, but because of the PHP fatal error2434 // the cliend doesn't know the attachment ID yet.2435 // To be able to find the new attachment_id in these cases we temporarily store an upload reference sent by the client2436 // in the original upload request. It is used to save a transient with the attachment_id as value.2437 // That reference currently is Plupload's `file.id` but can be any sufficiently random alpha-numeric string.2438 $attachment_id = get_transient( '_wp_temp_image_ref:' . $image_ref );2439 2436 2440 2437 if ( empty( $attachment_id ) ) { … … 2482 2479 2483 2480 // At this point the image has been uploaded successfully. 2484 delete_transient( '_wp_temp_image_ref:' . $image_ref);2481 _wp_clear_upload_ref( $_POST['_wp_temp_upload_ref'] ); 2485 2482 2486 2483 wp_send_json_success( $response );
Note: See TracChangeset
for help on using the changeset viewer.