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?

CommentFileSizeAuthor
#2 filefield_paths-2185755-2.patch1.12 KBtreksler
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpfitzsi’s picture

Just to clarify, the files themselves don't break, just links on an actual node get the character stripped.

treksler’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Priority: Normal » Major
Status: Active » Needs review
FileSize
1.12 KB

from 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

dpfitzsi’s picture

Tested on a local install and simplytest.me and I can confirm this patch works. Thanks treksler!

dpfitzsi’s picture

Status: Needs review » Reviewed & tested by the community
Deciphered’s picture

Status: Reviewed & tested by the community » Fixed

Took me a little to reproduce this, but I got there, and confirmed both the issue and the fix.

Patch hugely appreciated, committed and pushed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.