Fixed xf-dev:entity-class-properties incorrectly handles recursion into folders

Xon

Well-known member
Affected version
2.0.10
Code:
$iterator = new \RegexIterator(
   new \RecursiveIteratorIterator(
      new \RecursiveDirectoryIterator($path)
   ), '/\.php$/'
);

foreach ($iterator AS $name => $file)
{
   $name = str_replace('.php', '', $file->getFilename());
   $entities[] = str_replace('/', '\\', $addOnId) . ':' . $name;
}

This is using a RecursiveDirectoryIterator but the namespace for the entity is blindly assumed to not be in a sub-folder.

A fix something like this works;
Code:
foreach ($iterator AS $name => $file)
{
   $name = str_replace('.php', '', $file->getFilename());
   $subFolder = substr($file->getPath(), strlen($path));
   $subFolder = ltrim(str_replace('/', '\\', $subFolder) . '\\', '\\');
   $entities[] = str_replace('/', '\\', $addOnId) . ':' . $subFolder . $name;
}
 
Thank you for reporting this issue. The issue is now resolved and we are aiming to include that in the next XF release (2.0.11).

Change log:
Make xf-dev:entity-class-properties CLI command correctly handle subdirectories
 
Top Bottom