mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 06:37:06 +00:00
Improve the performance of wp_upload_dir():
- Cache the output in non-persistent cache. - Cache the result from `wp_mkdir_p()` in persistent cache (when present). - Introduce `wp_get_upload_dir()` for use when not uploading files. It is equivalent to `wp_upload_dir()` but does not check for the existence or create the upload directory. - Change tests to use the non-cached `_wp_upload_dir()`. They change options on the fly (should never be used in production) to simulate different environments. - Introduce `_upload_dir_no_subdir()` and `_upload_dir_https()` to facilitate testing. These use the proper `upload_dir` filter to simulate different environments. Props kovshenin, azaozz. See #34359. git-svn-id: https://develop.svn.wordpress.org/trunk@36565 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -895,11 +895,8 @@ EOF;
|
||||
function test_wp_calculate_image_srcset_no_date_uploads() {
|
||||
global $_wp_additional_image_sizes;
|
||||
|
||||
// Save the current setting for uploads folders
|
||||
$uploads_use_yearmonth_folders = get_option( 'uploads_use_yearmonth_folders' );
|
||||
|
||||
// Disable date organized uploads
|
||||
update_option( 'uploads_use_yearmonth_folders', 0 );
|
||||
add_filter( 'upload_dir', '_upload_dir_no_subdir' );
|
||||
|
||||
// Make an image.
|
||||
$filename = DIR_TESTDATA . '/images/test-image-large.png';
|
||||
@@ -937,9 +934,7 @@ EOF;
|
||||
|
||||
// Remove the attachment
|
||||
wp_delete_attachment( $id );
|
||||
|
||||
// Leave the uploads option the way you found it.
|
||||
update_option( 'uploads_use_yearmonth_folders', $uploads_use_yearmonth_folders );
|
||||
remove_filter( 'upload_dir', '_upload_dir_no_subdir' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user