And I have the patches for D6 and D7!

These patches will add documentation to file_save_upload about the members of the object returned.

I inferred the purpose of the members straight from the code of file_save_upload so I may have misinterpreted something on accident.

This is some what related to this issue.

Comments

aj045’s picture

Project: Drupal core » Documentation
Version: 7.x-dev »
Component: file system » New documentation
add1sun’s picture

Project: Documentation » Drupal core
Version: » 7.x-dev
Component: New documentation » documentation
Assigned: aj045 » Unassigned

aw, you had the right project the first time. documentation in code goes in the drupal core queue, under documentation component. :-)

cburschka’s picture

+ *   -filepath - The path to the file after it has been processed and uploaded.  This 
+ *   will contain the unique filename if a unique name was generated.
...
+ *   -destination - The destination path that this file was uploaded to, including 
+ *   the file name and extension.

Having never used this function, I am a good subject for the "idiot test": On reading only this description, without the code below, I was unable to understand what the difference is between filepath and destination. I'll read the code now and possibly understand it, but consider clarifying it in the comment.

cburschka’s picture

Status: Needs review » Needs work

Addendum:

$file->filepath is the temp name for most of the function's work, but before the object is returned we get (unconditionally) this:

 $file->filepath = $file->destination;

It would probably be best to reflect in the comments that the two member's values are identical.

franskuipers’s picture

Status: Needs work » Needs review

newbie eyes too :)

+ * -filepath - The path to the file after it has been processed and uploaded. This
+ * will contain the unique filename if a unique name was generated.
...
+ * -destination - The destination path that this file was uploaded to, including
+ * the file name and extension.

What is the difference between -filepath and -destination?

cburschka’s picture

Status: Needs review » Needs work

cross post.

jhodgdon’s picture

In D7, there is already documentation on http://api.drupal.org/api/group/file/7 (click on "File interface" in Related Topics on http://api.drupal.org/api/function/file_save_upload/7 - generated from a header at the top of includes/file.inc). This doc page contains the common components of the file object. I would advocate not repeating that doc in every function that uses the same file object, but instead making it clear in @return for each of the file functions, where to look to find that information.

It appears that this particular function file_save_upload has added two custom components to the object:
- source
- destination

These two components appear to be unique to file_save_upload, so they should be documented in that function.

For Drupal 6, the corresponding file group page does NOT have the common components documented. So they should be added to http://api.drupal.org/api/groups/files via a header like what's in the D7 version of includes/file.inc (but possibly edited to be accurate for D6).

That's my opinion, anyway.

jhodgdon’s picture

Title: file_save_upload docs need documentation for members » file_save_upload docs need documentation for members of returned object
Category: task » bug
p.brouwers’s picture

Had to search for a while to find out why the returned object of file_save_upload didn't contain filepath anymore.
My first clue come from #566798: Documentation problem with file_scan_directory: filepath => uri, but the documentation at http://api.drupal.org/api/group/file/7 made it clear.

Can this patch be applied, so it gets in the docs of file_save_upload() ?

jhodgdon’s picture

The patch cannot be applied until someone fixes it up so it will pass review.

jhodgdon’s picture

Status: Needs work » Needs review
StatusFileSize
new2.62 KB

Attached is a revised patch for Drupal 7. It fixes up a couple of formatting issues in the doc, and documents return value for file_save_upload().

p.brouwers’s picture

Status: Needs review » Reviewed & tested by the community

Documentation for file_save_upload now matches the "File interface" documentation nicely.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

jhodgdon’s picture

Version: 7.x-dev » 6.x-dev
Status: Fixed » Needs work

Need to do something similar for D6. Probably a bit more extensive. See comment #7 above.

jhodgdon’s picture

Sheesh. Actually, the Drupal 6 doc for the entire file.inc file is a complete mess. It is mosly out of compliance with our doc header standards, filled with typos and punctuation/grammar errors, etc. Sigh. Not sure if anyone cares but me...

jhodgdon’s picture

Title: file_save_upload docs need documentation for members of returned object » file.inc documentation needs overhaul
Status: Needs work » Active
steven jones’s picture

Assigned: Unassigned » steven jones

I totally care, and have a long train journey coming up :-D

jhodgdon’s picture

Steven: Are you still planning on doing this?

jhodgdon’s picture

Assigned: steven jones » Unassigned

I guess Steven is probably not planning on still doing this...

jhodgdon’s picture

See also #841134: Description for the parameter $replace of file_save_upload() is not correct, which is a somewhat related D6 documentation issue in the same area of the same file.

oadaeh’s picture

The Drupal 7 fix did not include the correction to the $source variable in file_save_upload(). Shall I open a new bug report, or modify this one?

jhodgdon’s picture

Probably a new issue.

jhodgdon’s picture

Version: 6.x-dev » 7.x-dev
Issue summary: View changes
Status: Active » Closed (fixed)

I am cleaning up old 6.x documentation issues. At this point, we are not spending effort fixing them. Sorry.

So this one was D7 and it was fixed. Setting back to that.