Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid argument supplied for foreach() in /var/www/html/www/modules/contrib/ui_patterns/modules/ui_patterns_library/src/Plugin/Deriver/LibraryDeriver.php on line 141 #349

Open
MaxCSwann opened this issue Mar 29, 2022 · 0 comments

Comments

@MaxCSwann
Copy link

Hi guys,

I've found an error when creating an empty ui_patterns.yml file.
The getPatterns() function in /var/www/html/www/modules/contrib/ui_patterns/modules/ui_patterns_library/src/Plugin/Deriver/LibraryDeriver.php attempts to run Yaml::decode($content) and pass that as an argument to the foreach() function. When the file is empty $content returns an empty string which causes the foreach() to fail.

For anyone who comes across this problem and doesnt want to roll a patch the obvious solution is to just remove any empty ui_patterns.yml files.
Else, just run an empty string check.

+ if (!empty($content)) {
  foreach (Yaml::decode($content) as $id => $definition) {
    $definition['id'] = $id;
    $definition['base path'] = dirname($file_path);
    $definition['file name'] = basename($file_path);
    $definition['provider'] = $provider;
    $patterns[] = $this->getPatternDefinition($definition);
  }
+ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant