API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21SystemLis...
The example code used in that page is introduced by the following phrase:
For instance, if you are looking for modules and call
Then the description continues with the following text:
this function will search:
- the core modules directory; i.e., /core/modules
- the profiles directories as defined by the profiles() method.
- the site-wide modules directory; i.e., /modules
- the all-sites directory; i.e., /sites/all/modules
- the site-specific directory; i.e., /sites/example.com/modules
That is not what the code is doing, since the code is the following one.
$scanner = new SystemListing();
$all_profiles = $profiles_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles');
Since the description for the $string parameter is the following one, the shown code should show how to search for modules, not profiles.
The subdirectory name in which the files are found. For example, 'modules' will search all 'modules' directories and their sub-directories as explained above.
Comments
Comment #1
avpadernoThis is a first patch attempt.
Comment #2
jhodgdonGood catch! But the example code is still wrong. The first line is saved as $scanner, and then the second one uses a different variable.
Comment #4
avpadernoWhoops... I missed the thing that was screaming out loud.
:|Let's try again after checking the patch doesn't include any other patch. Let's also use a more appropriate variable name than
$all_profiles, since the code is listing all the existing modules.Comment #5
avpadernoComment #6
jhodgdonLooks good, thanks!
Comment #7
jhodgdonThanks again! Committed to 8.x.
I checked and this is completely new documentation for 8.x. The 7.x equivalent was buried in the body of drupal_system_listing() and that function's documentation is not suffering from the same problem. So, no backport needed.