[FEATURE] FAL missing files report 43/23143/8
authorFrans Saris <franssaris@gmail.com>
Fri, 16 Aug 2013 20:11:59 +0000 (22:11 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 9 Sep 2013 20:23:11 +0000 (22:23 +0200)
Adds a report about files flagged as missing.

Resolves: #51097
Releases: 6.2
Change-Id: I95f55fe9f0da9247e6960663dd315e82e18cc2b6
Reviewed-on: https://review.typo3.org/23143
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/reports/Classes/Report/Status/FalStatus.php [new file with mode: 0644]
typo3/sysext/reports/ext_tables.php
typo3/sysext/reports/reports/locallang.xlf

diff --git a/typo3/sysext/reports/Classes/Report/Status/FalStatus.php b/typo3/sysext/reports/Classes/Report/Status/FalStatus.php
new file mode 100644 (file)
index 0000000..de65d0c
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+namespace TYPO3\CMS\Reports\Report\Status;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Frans Saris <franssaris@gmail.com>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Performs several checks about the FAL status
+ *
+ * @author Frans Saris <franssaris@gmail.com>
+ */
+class FalStatus implements \TYPO3\CMS\Reports\StatusProviderInterface {
+
+       /**
+        * Determines the status of the FAL index.
+        *
+        * @return array List of statuses
+        */
+       public function getStatus() {
+               $statuses = array(
+                       'MissingFiles' => $this->getMissingFilesStatus()
+               );
+               return $statuses;
+       }
+
+       /**
+        * Checks if there are files marked as missed.
+        *
+        * @return \TYPO3\CMS\Reports\Status An object representing whether there are files marked as missed or not
+        */
+       protected function getMissingFilesStatus() {
+               $value = $GLOBALS['LANG']->getLL('status_none');
+               $count = 0;
+               $maxFilesToShow = 100;
+               $message = '';
+               $severity = \TYPO3\CMS\Reports\Status::OK;
+
+               /** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */
+               $storageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
+               $storageObjects = $storageRepository->findAll();
+               $storages = array();
+
+               /** @var $storageObject \TYPO3\CMS\Core\Resource\ResourceStorage */
+               foreach ($storageObjects as $storageObject) {
+
+                       // We only check missing files for storages that are online
+                       if ($storageObject->isOnline()) {
+                               $storages[$storageObject->getUid()] = $storageObject;
+                       }
+               }
+
+               if (count($storages)) {
+                       $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                               '*',
+                               'sys_file',
+                               'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')'
+                       );
+               }
+
+               if ($count) {
+                       $value = sprintf($GLOBALS['LANG']->getLL('status_missingFilesCount'), $count);
+                       $severity = \TYPO3\CMS\Reports\Status::WARNING;
+
+                       $files = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                               'identifier,storage',
+                               'sys_file',
+                               'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')',
+                               '',
+                               '',
+                               $maxFilesToShow
+                       );
+
+                       $message = '<p>' . $GLOBALS['LANG']->getLL('status_missingFilesMessage') . '</p>';
+                       foreach ($files as $file) {
+                               $message .= $storages[$file['storage']]->getName() . ' ' . $file['identifier'] . '<br />';
+                       }
+
+                       if ($count > $maxFilesToShow) {
+                               $message .= '...<br />';
+                       }
+               }
+
+               return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_missingFiles'), $value, $message, $severity);
+       }
+}
+
+?>
\ No newline at end of file
index 668c8e2..d30290d 100644 (file)
@@ -29,5 +29,6 @@ if (TYPO3_MODE === 'BE') {
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['system'][] = 'TYPO3\\CMS\\Reports\\Report\\Status\\SystemStatus';
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['security'][] = 'TYPO3\\CMS\\Reports\\Report\\Status\\SecurityStatus';
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['configuration'][] = 'TYPO3\\CMS\\Reports\\Report\\Status\\ConfigurationStatus';
+       $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['fal'][] = 'TYPO3\\CMS\\Reports\\Report\\Status\\FalStatus';
 }
 ?>
\ No newline at end of file
index 2f823a5..cc69edd 100644 (file)
                        <trans-unit id="status_referenceIndex" xml:space="preserve">
                                <source>Reference Index</source>
                        </trans-unit>
+                       <trans-unit id="status_fal" xml:space="preserve">
+                               <source>File Abstraction Layer</source>
+                       </trans-unit>
+                       <trans-unit id="status_missingFiles" xml:space="preserve">
+                               <source>Files flagged as missing</source>
+                       </trans-unit>
+                       <trans-unit id="status_missingFilesCount" xml:space="preserve">
+                               <source>%1$s files</source>
+                       </trans-unit>
+                       <trans-unit id="status_missingFilesMessage" xml:space="preserve">
+                               <source>These files are flagged as missing. Restore the files and run the indexer to reset the missing flag.</source>
+                       </trans-unit>
                        <trans-unit id="status_memcachedConfiguration" xml:space="preserve">
                                <source>Memcached Configuration</source>
                        </trans-unit>