3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
33 class CRM_Utils_Check_Component_Source
extends CRM_Utils_Check_Component
{
35 public function getRemovedFiles() {
36 $files[] = '[civicrm.packages]/Auth/SASL';
37 $files[] = '[civicrm.packages]/Auth/SASL.php';
38 $files[] = '[civicrm.packages]/Net/SMTP.php';
39 $files[] = '[civicrm.packages]/Net/Socket.php';
40 $files[] = '[civicrm.packages]/_ORIGINAL_/Net/SMTP.php';
41 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/Readme.md';
42 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/license.txt';
43 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/css/jquery.dataTables.css';
44 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/css/jquery.dataTables.min.css';
45 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/css/jquery.dataTables_themeroller.css';
46 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/js/jquery.dataTables.js';
47 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/js/jquery.dataTables.min.js';
48 $files[] = '[civicrm.packages]/jquery/plugins/DataTables/media/js/jquery.js';
49 $files[] = '[civicrm.vendor]/pear/net_smtp/examples';
50 $files[] = '[civicrm.vendor]/pear/net_smtp/tests';
51 $files[] = '[civicrm.vendor]/pear/net_smtp/phpdoc.sh';
52 $files[] = '[civicrm.vendor]/phpoffice/phpword/samples';
53 $files[] = '[civicrm.root]/templates/CRM/common/version.tpl';
54 $files[] = '[civicrm.packages]/Log.php';
55 $files[] = '[civicrm.packages]/_ORIGINAL_/Log.php';
56 $files[] = '[civicrm.packages]/Log/composite.php';
57 $files[] = '[civicrm.packages]/Log/console.php';
58 $files[] = '[civicrm.packages]/Log/daemon.php';
59 $files[] = '[civicrm.packages]/Log/display.php';
60 $files[] = '[civicrm.packages]/Log/error_log.php';
61 $files[] = '[civicrm.packages]/Log/file.php';
62 $files[] = '[civicrm.packages]/Log/firebug.php';
63 $files[] = '[civicrm.packages]/Log/mail.php';
64 $files[] = '[civicrm.packages]/Log/mcal.php';
65 $files[] = '[civicrm.packages]/Log/mdb2.php';
66 $files[] = '[civicrm.packages]/Log/null.php';
67 $files[] = '[civicrm.packages]/Log/observer.php';
68 $files[] = '[civicrm.packages]/Log/sql.php';
69 $files[] = '[civicrm.packages]/Log/sqlite.php';
70 $files[] = '[civicrm.packages]/Log/syslog.php';
71 $files[] = '[civicrm.packages]/Log/win.php';
78 * Each item is an array with keys:
79 * - name: string, an abstract name
80 * - path: string, a full file path
81 * Files are returned in deletable order (ie children before parents).
83 public function findOrphanedFiles() {
86 foreach ($this->getRemovedFiles() as $file) {
87 $path = Civi
::paths()->getPath($file);
88 if (empty($path) ||
strpos('[civicrm', $path) !== FALSE) {
89 Civi
::log()->warning('Failed to resolve path of old file \"{file}\" ({path})', [
94 if (file_exists($path)) {
102 usort($orphans, function ($a, $b) {
103 // Children first, then parents.
104 $diff = strlen($b['name']) - strlen($a['name']);
108 if ($a['name'] === $b['name']) {
111 return $a['name'] < $b['name'] ?
-1 : 1;
120 public function checkOrphans() {
121 $orphans = $this->findOrphanedFiles();
122 if (empty($orphans)) {
127 $messages[] = new CRM_Utils_Check_Message(
129 ts('The local system includes old files which should not exist: "%1"',
131 1 => implode('", "', CRM_Utils_Array
::collect('path', $orphans)),
134 \Psr\Log\LogLevel
::WARNING
,