Changeset 35276
- Timestamp:
- 10/20/2015 04:04:26 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r35170 r35276 1919 1919 while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) { 1920 1920 $new_number = $number + 1; 1921 $filename = str_replace( "$number$ext", "$new_number$ext", $filename );1922 $filename2 = str_replace( "$number$ext2", "$new_number$ext2", $filename2 );1921 $filename = str_replace( array( "-$number$ext", "$number$ext" ), "-$new_number$ext", $filename ); 1922 $filename2 = str_replace( array( "-$number$ext2", "$number$ext2" ), "-$new_number$ext2", $filename2 ); 1923 1923 $number = $new_number; 1924 1924 } … … 1927 1927 1928 1928 while ( file_exists( $dir . "/$filename" ) ) { 1929 if ( '' == "$number$ext" ) 1930 $filename = $filename . ++$number . $ext; 1931 else 1932 $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); 1929 if ( '' == "$number$ext" ) { 1930 $filename = "$filename-" . ++$number; 1931 } else { 1932 $filename = str_replace( array( "-$number$ext", "$number$ext" ), "-" . ++$number . $ext, $filename ); 1933 } 1933 1934 } 1934 1935 } -
trunk/tests/phpunit/tests/functions.php
r35242 r35276 147 147 // check number is appended for file already exists 148 148 $this->assertFileExists( $testdir . 'test-image.png', 'Test image does not exist' ); 149 $this->assertEquals( 'test-image 1.png', wp_unique_filename( $testdir, 'test-image.png' ), 'Number not appended correctly' );150 $this->assertFileNotExists( $testdir . 'test-image 1.png' );149 $this->assertEquals( 'test-image-1.png', wp_unique_filename( $testdir, 'test-image.png' ), 'Number not appended correctly' ); 150 $this->assertFileNotExists( $testdir . 'test-image-1.png' ); 151 151 152 152 // check special chars
Note: See TracChangeset
for help on using the changeset viewer.