Make WordPress Core

Changeset 43285


Ignore:
Timestamp:
05/15/2018 08:32:01 PM (7 years ago)
Author:
azaozz
Message:

Privacy: Rename exports folder to avoid deleting other files.

Previously, personal data exports were stored in wp-content/uploads/exports, which is generic enough that it's likely there are existing folders with that name, either created by plugins or manually by administrators. If that folder were reused by Core, then wp_privacy_delete_old_export_files() would delete all of the existing files inside it, which is almost certainly not what the site owner wants or expects.

To avoid that, the folder is being renamed to include a specific reference to Core, and a more verbose description of its purpose. With those factored in, it's very unlikely that there will be any conflicts with existing folders.

The wp_privacy_exports_dir() and wp_privacy_exports_url() functions were introduced to provide a canonical source for the location, and the wp_privacy_exports_dir and wp_privacy_exports_url filters were introduced to allow plugins to customize it.

Props johnjamesjacoby, allendav.
Merges [43284] to the 4.9 branch.
Fixes #44091.

Location:
branches/4.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/includes/file.php

    r43235 r43285  
    18871887
    18881888    // Create the exports folder if needed.
    1889     $upload_dir  = wp_upload_dir();
    1890     $exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' );
    1891     $exports_url = trailingslashit( $upload_dir['baseurl'] . '/exports' );
     1889    $exports_dir = wp_privacy_exports_dir();
     1890    $exports_url = wp_privacy_exports_url();
    18921891
    18931892    $result = wp_mkdir_p( $exports_dir );
  • branches/4.9/src/wp-includes/functions.php

    r43225 r43285  
    59385938
    59395939/**
     5940 * Returns the directory used to store personal data export files.
     5941 *
     5942 * @since 4.9.6
     5943 *
     5944 * @see wp_privacy_exports_url
     5945 *
     5946 * @return string Exports directory.
     5947 */
     5948function wp_privacy_exports_dir() {
     5949    $upload_dir  = wp_upload_dir();
     5950    $exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';
     5951
     5952    /**
     5953     * Filters the directory used to store personal data export files.
     5954     *
     5955     * @since 4.9.6
     5956     *
     5957     * @param string $exports_dir Exports directory.
     5958     */
     5959    return apply_filters( 'wp_privacy_exports_dir', $exports_dir );
     5960}
     5961
     5962/**
     5963 * Returns the URL of the directory used to store personal data export files.
     5964 *
     5965 * @since 4.9.6
     5966 *
     5967 * @see wp_privacy_exports_dir
     5968 *
     5969 * @return string Exports directory URL.
     5970 */
     5971function wp_privacy_exports_url() {
     5972    $upload_dir  = wp_upload_dir();
     5973    $exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/';
     5974
     5975    /**
     5976     * Filters the URL of the directory used to store personal data export files.
     5977     *
     5978     * @since 4.9.6
     5979     *
     5980     * @param string $exports_url Exports directory URL.
     5981     */
     5982    return apply_filters( 'wp_privacy_exports_url', $exports_url );
     5983}
     5984
     5985/**
    59405986 * Schedule a `WP_Cron` job to delete expired export files.
    59415987 *
     
    59666012    require_once( ABSPATH . 'wp-admin/includes/file.php' );
    59676013
    5968     $upload_dir   = wp_upload_dir();
    5969     $exports_dir  = trailingslashit( $upload_dir['basedir'] . '/exports' );
     6014    $exports_dir  = wp_privacy_exports_dir();
    59706015    $export_files = list_files( $exports_dir, 100, array( 'index.html' ) );
    59716016
Note: See TracChangeset for help on using the changeset viewer.