The routine drupal_system_listing calls file_scan_directory, passing it a $key value. The latter lists possible keys as:

'uri', for the file's URI; 'filename', for the basename of the file; and 'name' for the name of the file without the extension. Defaults to 'uri'.

while the former indicates the possible keys as:

name, basename, or filename. Using name or basename will cause site-specific files to be prioritized over similar files in the default directories. That is, if a file with the same name appears in both the site-wide directory and site-specific directory, only the site-specific version will be included.

Should the former indicate possible keys as: uri, filename, and name, with uri the default?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

solotandem’s picture

Patch file attached.

jhodgdon’s picture

FileSize
1.17 KB

Good catch! This is a D7 change from D6.

Here's a new patch for the drupal_system_listing() doc also fixes a minor formatting problem.

jhodgdon’s picture

Status: Active » Needs review
hefox’s picture

FileSize
1.26 KB

Patch applies cleanly and makes sense.

For constituency sake should there be an example of profiles directory?

 * the profiles directory (i.e. profiles/profile/modules), and the site-specific directory
 * (i.e. sites/somesite/modules/). The returned array will be keyed using the

(If memory serves me right, that is where profiles store modules at least in d6).

jhodgdon’s picture

Status: Needs review » Needs work

Adding an example for the profile directory is a great idea... But rather than relying on your memory, take a look at the code: http://api.drupal.org/api/function/drupal_system_listing/7 :)

It looks like it will look in profiles/your_site_profile/modules, not profiles/profile/modules

hefox’s picture

Status: Needs work » Needs review
FileSize
1.26 KB

Changed to your_site_profile, which resulted in more line bumping.

hefox’s picture

FileSize
1.26 KB

Added a / to the end so matches with the others

hefox’s picture

FileSize
1.53 KB

...wrong patch /face palm
Second time this week!

hefox’s picture

FileSize
1.53 KB

Changing to your_site_dir for modules and removing white space

hefox’s picture

FileSize
1.53 KB

Swt, twice in a row. Wrong patch.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Assuming the test bot agrees, I like the patch in #10. Good work hefox!

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Thanks! Committed to HEAD, since the old documentation is just wrong.

But this really feels like it also could use a general clean-up for readability; it took me at least 3 reads to understand what the heck this function returns. Could we maybe augment it with some @example hunks like in http://api.drupal.org/api/function/t?

jhodgdon’s picture

Assigned: Unassigned » jhodgdon

OK.

jhodgdon’s picture

Assigned: jhodgdon » Unassigned
Status: Needs work » Needs review
FileSize
3.99 KB

Here's a patch with a more comprehensive rewrite of the function doc for drupal_system_listing().

mr.baileys’s picture

Status: Needs review » Needs work

That is a *huge* improvement over the current documentation for drupal_system_listing...

One issue:

+++ includes/common.inc	17 Feb 2010 16:25:20 -0000
@@ -4175,31 +4175,51 @@
+ *   An associative array of file objects, keyed on the chosen key. Each element
+ *   in the array is an associative array of file information, with elements:

Should read: "Each element in the array is an object of file information..."

Powered by Dreditor.

jhodgdon’s picture

Status: Needs work » Needs review

No, it returns an array of associatiave arrays.

mr.baileys’s picture

Hmmm... On a relatively fresh install, running:

print_r(drupal_system_listing('/\.script/', 'modules', 2));

gives me

Array
(
    [modules/simpletest/files/javascript-2.script] => stdClass Object
        (
            [uri] => modules/simpletest/files/javascript-2.script
            [filename] => javascript-2.script
            [name] => javascript-2
        )

)

And drupal_system_listing() basically merges the results from different calls to file_scan_directory, which returns

An associative array (keyed on the provided key) of objects...

So either I'm misunderstanding something (very well possible at this hour), or drupal_system_listing returns an associative array of objects, not an array of associative arrays.

jhodgdon’s picture

Status: Needs review » Needs work

My mistake -- you read the doc better than I did. Thanks!

jhodgdon’s picture

Status: Needs work » Needs review
FileSize
3.99 KB

Here's a patch, fixing #15.

mr.baileys’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

realityloop’s picture

#19: 713028revised.patch queued for re-testing.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

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