getRemovedFiles() as $file) { $path = Civi::paths()->getPath($file); if (empty($path) || strpos('[civicrm', $path) !== FALSE) { Civi::log()->warning('Failed to resolve path of old file \"{file}\" ({path})', [ 'file' => $file, 'path' => $path, ]); } if (file_exists($path)) { $orphans[] = [ 'name' => $file, 'path' => $path, ]; } } usort($orphans, function ($a, $b) { // Children first, then parents. $diff = strlen($b['name']) - strlen($a['name']); if ($diff !== 0) { return $diff; } if ($a['name'] === $b['name']) { return 0; } return $a['name'] < $b['name'] ? -1 : 1; }); return $orphans; } /** * @return array */ public function checkOrphans() { $orphans = $this->findOrphanedFiles(); if (empty($orphans)) { return []; } $messages = []; $messages[] = new CRM_Utils_Check_Message( __FUNCTION__, ts('The local system includes old files which should not exist: "%1"', [ 1 => implode('", "', CRM_Utils_Array::collect('path', $orphans)), ]), ts('Old files'), \Psr\Log\LogLevel::WARNING, 'fa-server' ); return $messages; } }