3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Utils_Check_Component_Source
extends CRM_Utils_Check_Component
{
19 public function getRemovedFiles() {
20 $files[] = '[civicrm.packages]/Auth/SASL';
21 $files[] = '[civicrm.packages]/Auth/SASL.php';
22 $files[] = '[civicrm.packages]/Net/SMTP.php';
23 $files[] = '[civicrm.packages]/Net/Socket.php';
24 $files[] = '[civicrm.packages]/_ORIGINAL_/Net/SMTP.php';
25 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/Readme.md';
26 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/license.txt';
27 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/css/jquery.dataTables.css';
28 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/css/jquery.dataTables.min.css';
29 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/css/jquery.dataTables_themeroller.css';
30 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/js/jquery.dataTables.js';
31 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/js/jquery.dataTables.min.js';
32 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/js/jquery.js';
33 $files[] = '[civicrm.vendor]/pear/net_smtp/examples';
34 $files[] = '[civicrm.vendor]/pear/net_smtp/tests';
35 $files[] = '[civicrm.vendor]/pear/net_smtp/phpdoc.sh';
36 $files[] = '[civicrm.vendor]/phpoffice/phpword/samples';
37 $files[] = '[civicrm.root]/templates/CRM/common/version.tpl';
38 $files[] = '[civicrm.packages]/Log.php';
39 $files[] = '[civicrm.packages]/_ORIGINAL_/Log.php';
40 $files[] = '[civicrm.packages]/Log/composite.php';
41 $files[] = '[civicrm.packages]/Log/console.php';
42 $files[] = '[civicrm.packages]/Log/daemon.php';
43 $files[] = '[civicrm.packages]/Log/display.php';
44 $files[] = '[civicrm.packages]/Log/error_log.php';
45 $files[] = '[civicrm.packages]/Log/file.php';
46 $files[] = '[civicrm.packages]/Log/firebug.php';
47 $files[] = '[civicrm.packages]/Log/mail.php';
48 $files[] = '[civicrm.packages]/Log/mcal.php';
49 $files[] = '[civicrm.packages]/Log/mdb2.php';
50 $files[] = '[civicrm.packages]/Log/null.php';
51 $files[] = '[civicrm.packages]/Log/observer.php';
52 $files[] = '[civicrm.packages]/Log/sql.php';
53 $files[] = '[civicrm.packages]/Log/sqlite.php';
54 $files[] = '[civicrm.packages]/Log/syslog.php';
55 $files[] = '[civicrm.packages]/Log/win.php';
61 * @return CRM_Utils_Check_Message[]
62 * Each item is an array with keys:
63 * - name: string, an abstract name
64 * - path: string, a full file path
65 * Files are returned in deletable order (ie children before parents).
67 public function findOrphanedFiles() {
70 foreach ($this->getRemovedFiles() as $file) {
71 $path = Civi
::paths()->getPath($file);
72 if (empty($path) ||
strpos('[civicrm', $path) !== FALSE) {
73 Civi
::log()->warning('Failed to resolve path of old file \"{file}\" ({path})', [
78 if (file_exists($path)) {
86 usort($orphans, function ($a, $b) {
87 // Children first, then parents.
88 $diff = strlen($b['name']) - strlen($a['name']);
92 if ($a['name'] === $b['name']) {
95 return $a['name'] < $b['name'] ?
-1 : 1;
102 * @return CRM_Utils_Check_Message[]
104 public function checkOrphans() {
105 $orphans = $this->findOrphanedFiles();
106 if (empty($orphans)) {
111 $messages[] = new CRM_Utils_Check_Message(
113 ts('The local system includes old files which should not exist: "%1"',
115 1 => implode('", "', CRM_Utils_Array
::collect('path', $orphans)),
118 \Psr\Log\LogLevel
::WARNING
,