mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-29 04:28:07 +01:00
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. Built from https://develop.svn.wordpress.org/branches/4.9@43285 git-svn-id: http://core.svn.wordpress.org/branches/4.9@43114 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2062f3f891
commit
f4a436c522
@ -1886,9 +1886,8 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
}
|
||||
|
||||
// Create the exports folder if needed.
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' );
|
||||
$exports_url = trailingslashit( $upload_dir['baseurl'] . '/exports' );
|
||||
$exports_dir = wp_privacy_exports_dir();
|
||||
$exports_url = wp_privacy_exports_url();
|
||||
|
||||
$result = wp_mkdir_p( $exports_dir );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
|
@ -5936,6 +5936,52 @@ function wp_privacy_anonymize_data( $type, $data = '' ) {
|
||||
return apply_filters( 'wp_privacy_anonymize_data', $anonymous, $type, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @see wp_privacy_exports_url
|
||||
*
|
||||
* @return string Exports directory.
|
||||
*/
|
||||
function wp_privacy_exports_dir() {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';
|
||||
|
||||
/**
|
||||
* Filters the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @param string $exports_dir Exports directory.
|
||||
*/
|
||||
return apply_filters( 'wp_privacy_exports_dir', $exports_dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL of the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @see wp_privacy_exports_dir
|
||||
*
|
||||
* @return string Exports directory URL.
|
||||
*/
|
||||
function wp_privacy_exports_url() {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/';
|
||||
|
||||
/**
|
||||
* Filters the URL of the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @param string $exports_url Exports directory URL.
|
||||
*/
|
||||
return apply_filters( 'wp_privacy_exports_url', $exports_url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a `WP_Cron` job to delete expired export files.
|
||||
*
|
||||
@ -5965,8 +6011,7 @@ function wp_schedule_delete_old_privacy_export_files() {
|
||||
function wp_privacy_delete_old_export_files() {
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' );
|
||||
$exports_dir = wp_privacy_exports_dir();
|
||||
$export_files = list_files( $exports_dir, 100, array( 'index.html' ) );
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9.6-RC1-43283';
|
||||
$wp_version = '4.9.6-RC1-43285';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user