PluginProbe
ActivityPub / 8.0.2
ActivityPub v8.0.2
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/cache/class-file.php +6 -17 9.3.08.0.2 View file →
@@ -236,19 +236,12 @@
236 236 }
237 237 $file_name = $hash . '.' . $ext;
238 238 $file_path = $paths['basedir'] . '/' . $file_name;
239 239
240 - /*
241 - * Move the file to its destination, once more after re-creating the directory if that
242 - * fails. Caching an entity's file races with invalidating that same entity, which deletes
243 - * the whole directory: when the delete lands between the two, the move has nowhere to put
244 - * the file and the download is lost for no reason.
245 - */
240 + // Move file to destination.
246 241 if ( ! static::get_filesystem()->move( $tmp_file, $file_path, true ) ) {
247 - if ( ! \wp_mkdir_p( $paths['basedir'] ) || ! static::get_filesystem()->move( $tmp_file, $file_path, true ) ) {
248 - \wp_delete_file( $tmp_file );
249 - return false;
250 - }
242 + \wp_delete_file( $tmp_file );
243 + return false;
251 244 }
252 245
253 246 // Optimize image if applicable.
254 247 $max_dimension = $options['max_dimension'] ?? static::get_max_dimension();
@@ -574,9 +567,9 @@
574 567
575 568 // Method 4: Ensure file extension matches MIME type.
576 569 $ext = \pathinfo( $file_path, PATHINFO_EXTENSION );
577 570
578 - if ( \strtolower( $ext ) !== $expected_ext ) {
571 + if ( strtolower( $ext ) !== $expected_ext ) {
579 572 $new_path = \preg_replace( '/\.[^.]+$/', '.' . $expected_ext, $file_path );
580 573 if ( empty( $new_path ) || $new_path === $file_path ) {
581 574 $new_path = $file_path . '.' . $expected_ext;
582 575 }
@@ -667,14 +660,10 @@
667 660
668 661 // Handle result.
669 662 $result_path = $result['path'] ?? $file_path;
670 663
671 - /*
672 - * If the path changed (format conversion), delete the original file. It may already be
673 - * gone: invalidating the entity deletes its whole directory, and that can land while this
674 - * file is being converted. Deleting it again is not an error worth a diagnostic.
675 - */
676 - if ( $result_path !== $file_path && \file_exists( $file_path ) ) {
664 + // If path changed (format conversion), delete the original file.
665 + if ( $result_path !== $file_path ) {
677 666 \wp_delete_file( $file_path );
678 667 }
679 668
680 669 return $result_path;