Make WordPress Core

Ticket #43990: 43990.patch

File 43990.patch, 6.6 KB (added by macbookandrew, 7 years ago)
  • src/wp-admin/includes/class-file-upload-upgrader.php

     
    124124                        wp_delete_attachment( $this->id );
    125125
    126126                } elseif ( file_exists( $this->package ) ) {
    127                         return @unlink( $this->package );
     127                        return @wp_delete_file( $this->package );
    128128                }
    129129
    130130                return true;
  • src/wp-admin/includes/class-wp-upgrader.php

     
    324324
    325325                // Once extracted, delete the package if required.
    326326                if ( $delete_package ) {
    327                         unlink( $package );
     327                        wp_delete_file( $package );
    328328                }
    329329
    330330                if ( is_wp_error( $result ) ) {
  • src/wp-admin/includes/file.php

     
    610610
    611611/**
    612612 * Returns a filename of a Temporary unique file.
    613  * Please note that the calling function must unlink() this itself.
     613 * Please note that the calling function must wp_delete_file() this itself.
    614614 *
    615615 * The filename is based off the passed parameter or defaults to the current unix timestamp,
    616616 * while the directory can either be passed as well, or by leaving it blank, default to a writable temporary directory.
     
    848848                if ( 'wp_handle_upload' === $action ) {
    849849                        $move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file );
    850850                } else {
    851                         // use copy and unlink because rename breaks streams.
     851                        // use copy and wp_delete_file because rename breaks streams.
    852852                        $move_new_file = @ copy( $file['tmp_name'], $new_file );
    853                         unlink( $file['tmp_name'] );
     853                        wp_delete_file( $file['tmp_name'] );
    854854                }
    855855
    856856                if ( false === $move_new_file ) {
     
    960960/**
    961961 * Downloads a URL to a local temporary file using the WordPress HTTP API.
    962962 *
    963  * Please note that the calling function must unlink() the file.
     963 * Please note that the calling function must wp_delete_file() the file.
    964964 *
    965965 * @since 2.5.0
    966966 *
     
    969969 * @return string|WP_Error Filename on success, WP_Error on failure.
    970970 */
    971971function download_url( $url, $timeout = 300 ) {
    972         //WARNING: The file is not automatically deleted, The script must unlink() the file.
     972        //WARNING: The file is not automatically deleted, The script must wp_delete_file() the file.
    973973        if ( ! $url ) {
    974974                return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
    975975        }
     
    990990        );
    991991
    992992        if ( is_wp_error( $response ) ) {
    993                 unlink( $tmpfname );
     993                wp_delete_file( $tmpfname );
    994994                return $response;
    995995        }
    996996
     
    10181018                        fclose( $tmpf );
    10191019                }
    10201020
    1021                 unlink( $tmpfname );
     1021                wp_delete_file( $tmpfname );
    10221022                return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data );
    10231023        }
    10241024
     
    10261026        if ( $content_md5 ) {
    10271027                $md5_check = verify_file_md5( $tmpfname, $content_md5 );
    10281028                if ( is_wp_error( $md5_check ) ) {
    1029                         unlink( $tmpfname );
     1029                        wp_delete_file( $tmpfname );
    10301030                        return $md5_check;
    10311031                }
    10321032        }
     
    21582158        }
    21592159
    21602160        // And remove the HTML file.
    2161         unlink( $html_report_pathname );
     2161        wp_delete_file( $html_report_pathname );
    21622162
    21632163        if ( $error ) {
    21642164                wp_send_json_error( $error );
     
    23462346        $export_path = get_post_meta( $request_id, '_export_file_path', true );
    23472347        if ( ! empty( $export_path ) ) {
    23482348                delete_post_meta( $request_id, '_export_file_path' );
    2349                 @unlink( $export_path );
     2349                @wp_delete_file( $export_path );
    23502350        }
    23512351        delete_post_meta( $request_id, '_export_file_url' );
    23522352
  • src/wp-includes/class-snoopy.php

     
    10811081                else
    10821082                        $this->results = $results;
    10831083
    1084                 unlink("$headerfile");
     1084                wp_delete_file("$headerfile");
    10851085
    10861086                return true;
    10871087        }
  • src/wp-includes/functions.php

     
    18961896        }
    18971897        fclose( $f );
    18981898        if ( $should_delete_tmp_file ) {
    1899                 unlink( $path );
     1899                wp_delete_file( $path );
    19001900        }
    19011901        return true;
    19021902}
     
    63076307                $file_age_in_seconds = time() - filemtime( $export_file );
    63086308
    63096309                if ( $expiration < $file_age_in_seconds ) {
    6310                         unlink( $export_file );
     6310                        wp_delete_file( $export_file );
    63116311                }
    63126312        }
    63136313}
  • src/wp-includes/post.php

     
    52865286                        $thumbfile = str_replace( basename( $file ), $meta['thumb'], $file );
    52875287                        /** This filter is documented in wp-includes/functions.php */
    52885288                        $thumbfile = apply_filters( 'wp_delete_file', $thumbfile );
    5289                         @ unlink( path_join( $uploadpath['basedir'], $thumbfile ) );
     5289                        @ wp_delete_file( path_join( $uploadpath['basedir'], $thumbfile ) );
    52905290                }
    52915291        }
    52925292
     
    52965296                        $intermediate_file = str_replace( basename( $file ), $sizeinfo['file'], $file );
    52975297                        /** This filter is documented in wp-includes/functions.php */
    52985298                        $intermediate_file = apply_filters( 'wp_delete_file', $intermediate_file );
    5299                         @ unlink( path_join( $uploadpath['basedir'], $intermediate_file ) );
     5299                        @ wp_delete_file( path_join( $uploadpath['basedir'], $intermediate_file ) );
    53005300                }
    53015301        }
    53025302
     
    53055305                        $del_file = path_join( dirname( $meta['file'] ), $size['file'] );
    53065306                        /** This filter is documented in wp-includes/functions.php */
    53075307                        $del_file = apply_filters( 'wp_delete_file', $del_file );
    5308                         @ unlink( path_join( $uploadpath['basedir'], $del_file ) );
     5308                        @ wp_delete_file( path_join( $uploadpath['basedir'], $del_file ) );
    53095309                }
    53105310        }
    53115311
  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

     
    565565                $sideloaded = wp_handle_sideload( $file_data, $overrides );
    566566
    567567                if ( isset( $sideloaded['error'] ) ) {
    568                         @unlink( $tmpfname );
     568                        @wp_delete_file( $tmpfname );
    569569
    570570                        return new WP_Error( 'rest_upload_sideload_error', $sideloaded['error'], array( 'status' => 500 ) );
    571571                }