Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293174

scanDirectory throwing exceptions not caught in cron

$
0
0

I have just encountered what appears to be a bug in update module, related to changes made in #3035312: Move file_scan_directory() to file_system service.

I do not know what has prompted the conditions for this issue, except that the directory mentioned really doesn't exist beforehand.

On running cron from drush on 8.8.x-dev:

 [notice] Starting execution of update_cron(), execution of system_cron() took 15.08ms.
 [error]  Drupal\Core\File\Exception\NotRegularDirectoryException: temporary://update-cache-7eb5f1fe is not a directory. in Drupal\Core\File\FileSystem->scanDirectory() (line 683 of /.../www/web/core/lib/Drupal/Core/File/FileSystem.php).
 [notice] Execution of update_cron() took 48.91ms.

function update_cron() has:

function update_cron() {
[..snip..]
  // Clear garbage from disk.
  update_clear_update_disk_cache();
}

And in update_clear_update_disk_cache() a list of directories is constructed with the preceding comment:

  // List of update module cache directories. Do not create the directories if
  // they do not exist.

and they are then iterated over, calling:

\Drupal::service('file_system')->scanDirectory($directory,

Unfortunately, for when the directory really didn't exist, the first thing scanDirectory does is

    if (!is_dir($dir)) {}

and throws the NotRegularDirectoryException and then kills cron.

Wrapping the scan in if (file_exists($directory)) {} fixes the problem.


Viewing all articles
Browse latest Browse all 293174

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>