Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The doxygen for file_scan_directory is wrong and has been wrong for many versions of Drupal.
The docs state about the $key argument:
'key' The key to be used for the returned array of files. Possible values are 'filepath', for the path starting with $dir, 'filename', for the basename of the file, and 'name' for the name of the file without an extension. Defaults to 'filepath'.
'filepath' is not a valid value for this option, it should be 'uri', though I'm not entirely sure what that means in terms of a return value, so I'm not sure what its description should change to!
Comment | File | Size | Author |
---|---|---|---|
#10 | 0001-Issue-623276-Fixed-documentation-for-file_scan_direc-D6.patch | 2.1 KB | mr.baileys |
#9 | 623276-D6.patch | 1.88 KB | jhodgdon |
#6 | 623276.patch | 2.76 KB | jhodgdon |
Comments
Comment #1
jhodgdonIt looks like the doc for Drupal 6 http://api.drupal.org/api/function/file_scan_directory/6 matches the function, for the $key argument. So I am not sure about "has been wrong for many versions of Drupal".
However, in Drupal 7:
So the default is 'uri' and the options are 'uri', 'filename', 'name'.
So in my opinion, this does need a fix for Drupal 7 only.
Comment #2
Steven Jones CreditAttribution: Steven Jones commentedYou are entirely correct, file_scan_directory has incorrect documentation for the return value, in Drupal 6:
Comment #3
jhodgdonUmmm... Do you think the Drupal 6 doc is correct or incorrect?
Comment #4
Steven Jones CreditAttribution: Steven Jones commentedThe drupal 6 docs are wrong too.
Comment #5
jhodgdonAh, I see. In Drupal 6, the $key parameter description is correct, but the Return Value part is incorrect. In Drupal 7, it looks like just the $options['key'] description is incorrect, and the Return Value section is correct.
Thanks!
Comment #6
jhodgdonHere's a patch for Drupal 7. It fixes the problem (I think) and also some formatting issues with that particular function's doc header to bring into compliance with coding standards. And a couple of minor grammar/wording tweaks.
If accepted, please mark as Drupal 6 issue / "active" so we can also patch Drupal 6.
Comment #7
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #8
Steven Jones CreditAttribution: Steven Jones commentedSo now in D6, the return value is:
But should read:
Comment #9
jhodgdonHere's a doc fix for Drupal 6. Fixes issue in #8 above, as well as a few other minor issues (line wrapping, punctuation, wording).
Comment #10
mr.baileysThis is RTBC. Straight re-roll attached since patch from #9 applied with an offset.
Comment #11
jhodgdonPlease don't add a -D6 suffix to D6 patches. It causes the testbot to ignore them. See help text on the attach field.
Comment #12
Gábor HojtsyThanks, committed.