Problem with yyyy, mm, dd tokens
| Project: | Upload path |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
I am using a clear Drupal 5.7 installation with 4 contributed modules - Upload path, Image, Pathauto and Token. My pattern for all kinds of content in Upload path looks like [yyyy]/[mm]/[dd]/[title-raw]. When I am posting a sample story with the title "Sample story" and one file attached to it, Upload path creates a literally the following path in my files folder: [yyyy]/[mm]/[dd]/sample-story/sample_file.jpg. Is it a Token problem? Or an Upload path bug? How to fix it?
The other question (it may be linked with above reported issue) is that when I select a sample_file.jpg from my hard disk and click Attach button, upload progress bar freezes. Though file uploads fine when I click Submit button.

#1
Subscribing.
The problem is that token module needs $node->created (the creation time and date of a node) to replace the tokens [yyyy], [mm], and [dd]. When you create a new node, $node->created is empty, i.e. the tokens can't be replaced.
The problem can be solved by adding the following to your /modules/token/token_node.inc befor line 21 (which says "if (isset($node->created)) {"):
<?phpif (empty($node->created)) {
$node->created = time();
}
?>
I asked to add this to token_node.inc permantly, but the token maintainers argued that this is rather an upload path issue. So here we are. Could this problem be solved in upload path?
#2
#3
Why is this issue closed, has the problem been solved?
#4
yes, fixed in D6 version, or use the misc bugfix setting in the D5 version.