drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1)

Function generates an array of directories ($searchdir) and then scan them in foreach loop.

Function used for different cases of collecting data from folders:

Function $directory
_system_rebuild_module_data() 'modules'
_system_rebuild_theme_data() 'themes'



For this cases it works great.

But for case of building theme registry it doesn't seem so clear.

Simplified callstack (just to know how function is executed with full theme path as a $directory):

  • new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache')
  • _theme_build_registry($theme, $base_theme, 'phptemplate')
  • phptemplate_theme($cache, 'theme_engine', $theme, dirname($theme->filename))
  • drupal_find_theme_templates($cache, '.tpl.php', $path)
  • $files = drupal_system_listing($regex, $path, 'name', 0)

Maximum you can get a list of 4 directories that later are recursively scanned.
Minimum 2, as 2 of them are checked for being exist before adding to array. Marked them in table with *

Dir mask 'modules' 'themes' 'sites/all/themes/custom_theme'
$directory modules themes sites/all/themes/custom_theme
profiles/$profile/$directory * profiles/custom_profile/modules profiles/custom_profile/themes profiles/custom_profile/sites/all/themes/custom_theme
sites/all/$directory sites/all/modules sites/all/themes sites/all/sites/all/themes/custom_theme
$config/$directory * sites/custom_site/modules sites/custom_site/themes sites/custom_site/sites/all/themes/custom_theme



As you can see sites/all/$directory is always added to $searchdir, even with this odd path for case of building current theme registry.

I was thinking - how does it should work for this case? Maybe it should return 'sites/all/themes' instead of 'sites/all/sites/all/themes/custom_theme'? But for this moment i think it should be excluded as we already have themes data gathered by _system_rebuild_theme_data() and best solution - is just add a verification before scanning this directory. Yes, I agree - it's very small improvement overall, but what do you think?

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

mykh created an issue. See original summary.

mykh’s picture

Status: Needs review » Needs work
mykh’s picture

mykh’s picture

Status: Needs work » Needs review
mykh’s picture

Assigned: mykh » Unassigned
mykh’s picture

Added some code optimization

chiranjeeb2410’s picture

FileSize
931 bytes

@mykh,

Fix suggested in patch #7, seems to do the trick alright, appending the directory destinations to $searchdir[]
and then including a verification afterwards to filter the directories recursively.

Also, patches apply cleanly and adding in the interdiff for the two. RTBC for me.

chiranjeeb2410’s picture

Status: Needs review » Reviewed & tested by the community