Make WordPress Core


Ignore:
Timestamp:
12/10/2021 08:28:27 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Correct the format of some comments per the documentation standards.

Follow-up to [10357], [10939], [43309], [51003], [51266], [51653], [51738], [52110].

See #53399.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r52215 r52352  
    25392539                }
    25402540
    2541                 // Get the mime type. Uploaded files were already checked with wp_check_filetype_and_ext()
    2542                 // in _wp_handle_upload(). Using wp_check_filetype() would be sufficient here.
     2541                /*
     2542                 * Get the mime type. Uploaded files were already checked with wp_check_filetype_and_ext()
     2543                 * in _wp_handle_upload(). Using wp_check_filetype() would be sufficient here.
     2544                 */
    25432545                $file_type = wp_check_filetype( $filename );
    25442546                $mime_type = $file_type['type'];
    … …  
    25512553                $_dir   = trailingslashit( $dir );
    25522554
    2553                 // If the extension is uppercase add an alternate file name with lowercase extension. Both need to be tested
    2554                 // for uniqueness as the extension will be changed to lowercase for better compatibility with different filesystems.
    2555                 // Fixes an inconsistency in WP < 2.9 where uppercase extensions were allowed but image sub-sizes were created with
    2556                 // lowercase extensions.
     2555                /*
     2556                 * If the extension is uppercase add an alternate file name with lowercase extension.
     2557                 * Both need to be tested for uniqueness as the extension will be changed to lowercase
     2558                 * for better compatibility with different filesystems. Fixes an inconsistency in WP < 2.9
     2559                 * where uppercase extensions were allowed but image sub-sizes were created with
     2560                 * lowercase extensions.
     2561                 */
    25572562                if ( $ext && $lc_ext !== $ext ) {
    25582563                        $lc_filename = preg_replace( '|' . preg_quote( $ext ) . '$|', $lc_ext, $filename );
    25592564                }
    25602565
    2561                 // Increment the number added to the file name if there are any files in $dir whose names match one of the
    2562                 // possible name variations.
     2566                /*
     2567                 * Increment the number added to the file name if there are any files in $dir
     2568                 * whose names match one of the possible name variations.
     2569                 */
    25632570                while ( file_exists( $_dir . $filename ) || ( $lc_filename && file_exists( $_dir . $lc_filename ) ) ) {
    25642571                        $new_number = (int) $number + 1;
    25652572
    25662573                        if ( $lc_filename ) {
    2567                                 $lc_filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $lc_filename );
     2574                                $lc_filename = str_replace(
     2575                                        array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ),
     2576                                        "-{$new_number}{$lc_ext}",
     2577                                        $lc_filename
     2578                                );
    25682579                        }
    25692580
    … …  
    25712582                                $filename = "{$filename}-{$new_number}";
    25722583                        } else {
    2573                                 $filename = str_replace( array( "-{$number}{$ext}", "{$number}{$ext}" ), "-{$new_number}{$ext}", $filename );
     2584                                $filename = str_replace(
     2585                                        array( "-{$number}{$ext}", "{$number}{$ext}" ),
     2586                                        "-{$new_number}{$ext}",
     2587                                        $filename
     2588                                );
    25742589                        }
    25752590
    … …  
    25822597                }
    25832598
    2584                 // Prevent collisions with existing file names that contain dimension-like strings
    2585                 // (whether they are subsizes or originals uploaded prior to #42437).
     2599                /*
     2600                 * Prevent collisions with existing file names that contain dimension-like strings
     2601                 * (whether they are subsizes or originals uploaded prior to #42437).
     2602                 */
    25862603
    25872604                $files = array();
    … …  
    26182635                                $count = count( $files );
    26192636
    2620                                 // Ensure this never goes into infinite loop
    2621                                 // as it uses pathinfo() and regex in the check, but string replacement for the changes.
     2637                                /*
     2638                                 * Ensure this never goes into infinite loop as it uses pathinfo() and regex in the check,
     2639                                 * but string replacement for the changes.
     2640                                 */
    26222641                                $i = 0;
    26232642
    … …  
    26262645
    26272646                                        // If $ext is uppercase it was replaced with the lowercase version after the previous loop.
    2628                                         $filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $filename );
     2647                                        $filename = str_replace(
     2648                                                array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ),
     2649                                                "-{$new_number}{$lc_ext}",
     2650                                                $filename
     2651                                        );
    26292652
    26302653                                        $number = $new_number;
    … …  
    26342657                }
    26352658
    2636                 // Check if an image will be converted after uploading or some existing images sub-sizes file names may conflict
    2637                 // when regenerated. If yes, ensure the new file name will be unique and will produce unique sub-sizes.
     2659                /*
     2660                 * Check if an image will be converted after uploading or some existing image sub-size file names may conflict
     2661                 * when regenerated. If yes, ensure the new file name will be unique and will produce unique sub-sizes.
     2662                 */
    26382663                if ( $is_image ) {
    26392664                        /** This filter is documented in wp-includes/class-wp-image-editor.php */
    … …  
    26692694
    26702695                        if ( ! empty( $alt_filenames ) ) {
    2671                                 // Add the original filename. It needs to be checked again together with the alternate filenames
    2672                                 // when $number is incremented.
     2696                                /*
     2697                                 * Add the original filename. It needs to be checked again
     2698                                 * together with the alternate filenames when $number is incremented.
     2699                                 */
    26732700                                $alt_filenames[ $lc_ext ] = $filename;
    26742701
    … …  
    26802707
    26812708                                        foreach ( $alt_filenames as $alt_ext => $alt_filename ) {
    2682                                                 $alt_filenames[ $alt_ext ] = str_replace( array( "-{$number}{$alt_ext}", "{$number}{$alt_ext}" ), "-{$new_number}{$alt_ext}", $alt_filename );
     2709                                                $alt_filenames[ $alt_ext ] = str_replace(
     2710                                                        array( "-{$number}{$alt_ext}", "{$number}{$alt_ext}" ),
     2711                                                        "-{$new_number}{$alt_ext}",
     2712                                                        $alt_filename
     2713                                                );
    26832714                                        }
    26842715
    2685                                         // Also update the $number in (the output) $filename.
    2686                                         // If the extension was uppercase it was already replaced with the lowercase version.
    2687                                         $filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $filename );
     2716                                        /*
     2717                                         * Also update the $number in (the output) $filename.
     2718                                         * If the extension was uppercase it was already replaced with the lowercase version.
     2719                                         */
     2720                                        $filename = str_replace(
     2721                                                array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ),
     2722                                                "-{$new_number}{$lc_ext}",
     2723                                                $filename
     2724                                        );
    26882725
    26892726                                        $number = $new_number;
Note: See TracChangeset for help on using the changeset viewer.