Behaviour changes in wp_unique_filename()
|Reported by:||tellyworth||Owned by:||anonymous|
Unit testing picked up two recent changes in wp_unique_filename() behaviour. They might be ok but I thought worth raising as they might affect plugins or l10n.
- The strtolower() introduced in  mangles non-ascii filename characters on many systems. The locale isn't set so accented characters get converted to something unpredictable. This changes the result of the 'tést-imagé.png' case in test_wp_unique_filename():
expected string <testtest-image.png> difference < xxxxxxxxx> got string <testtast-imaga.png>
- Leading paths aren't stripped from the filename if present. They were before . Now, the full path is used with slashes removed (i.e. /path/to/filename.jpg becomes pathtofilename.jpg instead of filename.jpg) test_unique_filename_with_slashes() now fails as a result:
expected string <73bd23e4df5b4cbf9962bb1f4ee8988d.txt> difference < xxxx????????????????????????????????> got string <73bd23e4df5b4cbf9962bb1f4ee8988d73bd23e4df5b4cbf9962bb1f4ee8988d.txt>
It might be reasonable to accept the new behviour - if that's the case I'll update the tests to reflect that. If not, the enclosed patch fixes both issues and restores the previous behaviour. All relevant unit tests pass with the patch applied.