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';
60 * Each item is an array with keys:
61 * - name: string, an abstract name
62 * - path: string, a full file path
63 * Files are returned in deletable order (ie children before parents).
65 public function findOrphanedFiles() {
68 foreach ($this->getRemovedFiles() as $file) {
69 $path = Civi
::paths()->getPath($file);
70 if (empty($path) ||
strpos('[civicrm', $path) !== FALSE) {
71 Civi
::log()->warning('Failed to resolve path of old file \"{file}\" ({path})', array(
76 if (file_exists($path)) {
84 usort($orphans, function ($a, $b) {
85 // Children first, then parents.
86 $diff = strlen($b['name']) - strlen($a['name']);
90 if ($a['name'] === $b['name']) {
93 return $a['name'] < $b['name'] ?
-1 : 1;
102 public function checkOrphans() {
103 $orphans = $this->findOrphanedFiles();
104 if (empty($orphans)) {
109 $messages[] = new CRM_Utils_Check_Message(
111 ts('The local system includes old files which should not exist: "%1"',
113 1 => implode('", "', CRM_Utils_Array
::collect('path', $orphans)),
116 \Psr\Log\LogLevel
::WARNING
,