check if file exists in static_export_cron() before using result

Created on 8 January 2023, almost 2 years ago
Updated 22 January 2023, almost 2 years ago

running this module on a vanilla drupal 10, php 8.2, visiting admin pages on the site, this error is thrown:

[08-Jan-2023 09:29:34 America/New_York] TypeError: array_slice(): Argument #1 ($array) must be of type array, bool given in /Users/justinrandell/code/fischey-rando-web/web/modules/contrib/static_suite/modules/static_export/static_export.module on line 539 #0 /Users/justinrandell/code/fischey-rando-web/web/modules/contrib/static_suite/modules/static_export/static_export.module(539): array_slice(false, -10000)
#1 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Core/Cron.php(249): static_export_cron()
#2 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Cron->Drupal\Core\{closure}(Object(Closure), 'static_export')
#3 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Core/Cron.php(232): Drupal\Core\Extension\ModuleHandler->invokeAllWith('cron', Object(Closure))
#4 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Core/Cron.php(136): Drupal\Core\Cron->invokeCronHandlers()
#5 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#6 /Users/justinrandell/code/fischey-rando-web/web/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\Core\ProxyClass\Cron->run()
#7 [internal function]: Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#8 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#9 /Users/justinrandell/code/fischey-rando-web/vendor/symfony/http-kernel/HttpKernel.php(97): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...')
#10 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(63): Symfony\Component\HttpKernel\HttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\big_pipe\Render\BigPipeResponse))
#11 /Users/justinrandell/code/fischey-rando-web/web/core/lib/Drupal/Core/DrupalKernel.php(665): Drupal\Core\StackMiddleware\StackedHttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\big_pipe\Render\BigPipeResponse))
#12 /Users/justinrandell/code/fischey-rando-web/web/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\big_pipe\Render\BigPipeResponse))
#13 {main}

looking at the code, static_export_cron() is using the results of the php builtin file() without checking the result. this patch adds checks for the result of file().

πŸ› Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States drupalshapoopie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024