Skip to content

Commit d223920

Browse files
weitzmanChi-teck
authored andcommitted
Remove static caching from \DrupalCodeGenerator\Utils::getExtensionRoot
This static variable doesn't buy us much and it actively harms when passing --directory in a `drush generate` command. This method gets called with multiple values in a Drush request. In this case, the first call determines the return value forever.
1 parent f118cad commit d223920

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/Utils.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,14 @@ public static function defaultPluginQuestions() {
144144
* Extension root directory or false if it was not found.
145145
*/
146146
public static function getExtensionRoot($directory) {
147-
static $extension_root;
148-
if ($extension_root === NULL) {
149-
$extension_root = FALSE;
150-
for ($i = 1; $i <= 5; $i++) {
151-
$info_file = $directory . '/' . basename($directory) . '.info';
152-
if (file_exists($info_file) || file_exists($info_file . '.yml')) {
153-
$extension_root = $directory;
154-
break;
155-
}
156-
$directory = dirname($directory);
147+
$extension_root = FALSE;
148+
for ($i = 1; $i <= 5; $i++) {
149+
$info_file = $directory . '/' . basename($directory) . '.info';
150+
if (file_exists($info_file) || file_exists($info_file . '.yml')) {
151+
$extension_root = $directory;
152+
break;
157153
}
154+
$directory = dirname($directory);
158155
}
159156
return $extension_root;
160157
}

0 commit comments

Comments
 (0)