Currently the file_field_widget_uri() function calls token_replace() on the upload directory path, but it improperly duplicates the 'current-user' token by injecting it with $data['user']. And the function also has a mystery $account parameter that is not used at all in core, and so I changed it to $data as an empty array which is passed into token_replace().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Needs review
Issue tags: +token
FileSize
1.38 KB
Dave Reid’s picture

Grr, are patches with '-D7' still being ignored??

Status: Needs review » Needs work

The last submitted patch, 984456-file-field-widget-uri-token-cleanup.patch, failed testing.

Dave Reid’s picture

Status: Needs work » Needs review
FileSize
2.89 KB

Status: Needs review » Needs work

The last submitted patch, 984456-file-field-widget-uri-token-cleanup.patch, failed testing.

moshe weitzman’s picture

Seems like a useful patch. Can we fix the test failure? Migrate is starting to use this function.

bfroehle’s picture

+++ modules/file/tests/file.test	7 Dec 2010 16:19:21 -0000
@@ -938,8 +938,7 @@ class FileFieldPathTestCase extends File
-    $data = array('user' => $this->admin_user);
-    $subdirectory = token_replace('[user:uid]/[user:name]', $data);
+    $subdirectory = token_replace('[current-user:uid]/[current-user:name]');

This breaks the test, as we compare the token for the file (uploaded by uid = 2), with the token replacement for the current-user (uid = 1).

Powered by Dreditor.

bfroehle’s picture

Status: Needs work » Needs review
FileSize
2.11 KB

Implemented.

Dave Reid’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for fixing the test failure. Looks good.

dawehner’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7
Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x and 8.x. Thanks!

aspilicious’s picture

Issue tags: -token, -Needs backport to D7

untagging

Status: Fixed » Closed (fixed)

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