DX: Make file_scan_directory() use save property names as file_load()

c960657 - February 22, 2009 - 13:04
Project:Drupal
Version:7.x-dev
Component:file system
Category:task
Priority:normal
Assigned:Unassigned
Status:closed
Description

This issue is based on the following request on Drupal core improvements » File system:
“file_scan_directory() should return objects that have the same properties as the $file object returned by file_load(). Right now the file path is $file->path instead of $file->filepath, base name is $file->basename instead of $file->filename. The main complication of this patch is that there are quite a few core functions that directly return the results of this function so the change cascades out.”

I've made a patch that changes this, however, it doesn't go all the way and enforce this terminology throughout Drupal. E.g. it does not rename {registry}.filename to {registry}.filepath even though the fields contains a path a not just a path-less filename. Do we want to do that? And do we want to do it in one big issue, or is this better handled in separate issues?

AttachmentSizeStatusTest resultOperations
file_scan_directory-1.patch49.95 KBIdlePassed: 9752 passes, 0 fails, 0 exceptionsView details | Re-test

#1

c960657 - February 22, 2009 - 17:31
Title:DX: Make file_scan_directory() use save property names as file_load()» DX: Make file_scan_directory() use same property names as file_load()

#2

Dries - February 22, 2009 - 18:06
Title:DX: Make file_scan_directory() use same property names as file_load()» DX: Make file_scan_directory() use save property names as file_load()
Status:needs review» fixed

Committed to CVS HEAD. Thanks.

#3

Dries - February 22, 2009 - 22:20

Committed to CVS HEAD. Thanks.

#4

drewish - February 24, 2009 - 01:48
Status:fixed» needs work

Uh wow, record commit time... we do need to document this in the upgrade instructions.

#5

c960657 - February 25, 2009 - 17:30

I suggest the following for http://drupal.org/node/224333. I don't have permission to edit that page.

file_scan_directory() now use same property names as file_load()

(issue) file_scan_directory() previously returned objects with the properties filename, basename, and name (e.g., respectively, "foo/bar.txt," "bar.txt" and "bar"). filename has been renamed to filepath, and basename has been renamed to filename, i.e. the same names as used in objects returned by file_load().

#6

c960657 - March 31, 2009 - 21:49
Status:needs work» fixed

Apparently I now have access to edit the page, so I did:
http://drupal.org/node/224333#file_scan_directory_property_names

#7

System Message - April 14, 2009 - 21:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.