Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When switching file systems the path replace function fires and updates my paths for all of my files. However, I noticed that files that started with a number, like for example 306.pdf, would become 06.pdf, and would break the links I have on my page.
Has anyone else come across this problem?
Comment | File | Size | Author |
---|---|---|---|
#2 | filefield_paths-2185755-2.patch | 1.12 KB | treksler |
Comments
Comment #1
dpfitzsi CreditAttribution: dpfitzsi commentedJust to clarify, the files themselves don't break, just links on an actual node get the character stripped.
Comment #2
treksler CreditAttribution: treksler commentedfrom http://ca1.php.net/preg_replace
"When working with a replacement pattern where a backreference is immediately followed by another number (i.e.: placing a literal number immediately after a matched pattern), you cannot use the familiar \\1 notation for your backreference. \\11, for example, would confuse preg_replace() since it does not know whether you want the \\1 backreference followed by a literal 1, or the \\11 backreference followed by nothing. In this case the solution is to use \${1}1. This creates an isolated $1 backreference, leaving the 1 as a literal."
The attached patch fixes the issue
Comment #3
dpfitzsi CreditAttribution: dpfitzsi commentedTested on a local install and simplytest.me and I can confirm this patch works. Thanks treksler!
Comment #4
dpfitzsi CreditAttribution: dpfitzsi commentedComment #5
Deciphered CreditAttribution: Deciphered commentedTook me a little to reproduce this, but I got there, and confirmed both the issue and the fix.
Patch hugely appreciated, committed and pushed.