Warning: foreach() argument must be of type array|object, bool given в Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGenerator->generate() (строка 219 из /DATA/home-sites/lom/web/modules/contrib/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php)
#0 /DATA/home-sites/lom/web/core/includes/bootstrap.inc(312): _drupal_error_handler_real(2, 'foreach() argum...', '/DATA/home-site...', 219)
#1 /DATA/home-sites/lom/web/modules/contrib/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php(219): _drupal_error_handler(2, 'foreach() argum...', '/DATA/home-site...', 219)
#2 /DATA/home-sites/lom/web/modules/contrib/simple_sitemap/src/Queue/QueueWorker.php(297): Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGenerator->generate(Array)
#3 /DATA/home-sites/lom/web/modules/contrib/simple_sitemap/src/Queue/QueueWorker.php(263): Drupal\simple_sitemap\Queue\QueueWorker->generateResultsFromElement(Object(stdClass))
#4 /DATA/home-sites/lom/web/modules/contrib/simple_sitemap/src/Simplesitemap.php(355): Drupal\simple_sitemap\Queue\QueueWorker->generateSitemap('cron')
#5 /DATA/home-sites/lom/web/modules/contrib/simple_sitemap/simple_sitemap.module(164): Drupal\simple_sitemap\Simplesitemap->generateSitemap('cron')
#6 [internal function]: simple_sitemap_cron(Object(Drupal\ultimate_cron\Entity\CronJob))
#7 /DATA/home-sites/lom/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(325): call_user_func('simple_sitemap_...', Object(Drupal\ultimate_cron\Entity\CronJob))
#8 /DATA/home-sites/lom/web/modules/contrib/ultimate_cron/src/Entity/CronJob.php(471): Drupal\ultimate_cron\Entity\CronJob->invokeCallback()
#9 /DATA/home-sites/lom/web/modules/contrib/ultimate_cron/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php(219): Drupal\ultimate_cron\Entity\CronJob->run(Object(Drupal\Core\StringTranslation\TranslatableMarkup))
#10 /DATA/home-sites/lom/web/modules/contrib/ultimate_cron/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php(342): Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher\SerialLauncher->launch(Object(Drupal\ultimate_cron\Entity\CronJob))
#11 /DATA/home-sites/lom/web/modules/contrib/ultimate_cron/src/Plugin/ultimate_cron/Launcher/SerialLauncher.php(317): Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher\SerialLauncher->runThread('3888413', 1, Array)
#12 /DATA/home-sites/lom/web/modules/contrib/ultimate_cron/src/UltimateCron.php(64): Drupal\ultimate_cron\Plugin\ultimate_cron\Launcher\SerialLauncher->launchJobs(Array)
#13 /DATA/home-sites/lom/web/modules/contrib/ultimate_cron/src/ProxyClass/UltimateCron.php(73): Drupal\ultimate_cron\UltimateCron->run()
#14 /DATA/home-sites/lom/web/core/modules/system/src/CronController.php(46): Drupal\ultimate_cron\ProxyClass\UltimateCron->run()
#15 [internal function]: Drupal\system\CronController->run()
#16 /DATA/home-sites/lom/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#17 /DATA/home-sites/lom/web/core/lib/Drupal/Core/Render/Renderer.php(578): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /DATA/home-sites/lom/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#19 /DATA/home-sites/lom/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#20 /DATA/home-sites/lom/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#21 /DATA/home-sites/lom/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#22 /DATA/home-sites/lom/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /DATA/home-sites/lom/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /DATA/home-sites/lom/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(191): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /DATA/home-sites/lom/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(128): Drupal\page_cache\StackMiddleware\PageCache->fetch(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /DATA/home-sites/lom/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(82): Drupal\page_cache\StackMiddleware\PageCache->lookup(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /DATA/home-sites/lom/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /DATA/home-sites/lom/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /DATA/home-sites/lom/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /DATA/home-sites/lom/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /DATA/home-sites/lom/web/core/lib/Drupal/Core/DrupalKernel.php(717): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /DATA/home-sites/lom/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#33 {main}
For first I guess it will be useful to log this incorrect value.
Issue fork simple_sitemap-3230346
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3230346-warning-foreach-argument
changes, plain diff MR !30
Comments
Comment #2
mmjvb commentedTry replacing line 169:
return false;
with
return [];
Otherwise precede line 219 with: is_array($path_data_sets) and
which should not process the foreach unless it is an array.
Comment #3
gbytePlease create a merge request or a patch, if possible.
Comment #6
mohit.bansal623 commentedPlease review the merge request. Added case for array check.
Comment #8
gbyteThe whole code block beneath doesn't need to be executed if the output of processDataSet() is empty, hence I changed the logic there. Please test and reopen if anything breaks.