Commit 69d14155 authored by Christoph Hofmann's avatar Christoph Hofmann

limit the files

parent cfea0465
......@@ -63,6 +63,12 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
*/
protected $storageRepository = NULL;
/**
* ignoreTables
*
* @var array
*/
protected $ignoreTables = array();
/**
* Function executed from the Scheduler.
* Sends an email
......@@ -77,6 +83,12 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
$this->storageRepository = $this->objectManager->get('TYPO3\CMS\Core\Resource\StorageRepository');
$this->configurationManager = $this->objectManager->get('TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface');
$this->persistenceManager = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface');
$fullTs = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$ignoreTablesTS = $fullTs['plugin.']['tx_itsmissingclean.']['ignoreTables.'];
foreach ($ignoreTablesTS as $ignoreTable) {
$this->ignoreTables [] = $ignoreTable;
}
$db = $GLOBALS['TYPO3_DB'];
$missingFiles = array();
......@@ -89,7 +101,14 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
$whereEnabledFields = BackendUtility::BEenableFields($table)
. BackendUtility::deleteClause($table);
$messages = array();
$count = 0;
foreach ($missingFiles as $missingFile) {
$count ++;
if ($count > 1) {
break;
debug1('break;');
}
$file = $this->getFile($missingFile['uid'], $missingFile['storage'], $missingFile['identifier']);
$name = $file->getName();
//find all references
......@@ -122,15 +141,16 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
} else {
//debug1($sys_file_references);
foreach( $sys_file_references as $fileref) {
debug1($fileref['tablenames']);
debug1($fileref['uid_foreign']);
$pid = $this->getPid($fileref['tablenames'],$fileref['uid_foreign']);
$messages[] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
$name ." in table :".$fileref['tablenames']." in page:".$pid." uid:".$fileref['uid_foreign'],
'Important Missing file', // the header is optional
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, // the severity is optional as well and defaults to \TYPO3\CMS\Core\Messaging\FlashMessage::OK
TRUE // optional, whether the message should be stored in the session or only in the \TYPO3\CMS\Core\Messaging\FlashMessageQueue object (default is FALSE)
);
if ($fileref['deleted'] != 1 && $fileref['hidden'] != 1 ) {
debug1($fileref);
$pid = $this->getPid($fileref['tablenames'], $fileref['uid_foreign']);
$messages[] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
$name . " in table :" . $fileref['tablenames'] . " in page:" . $pid . " uid:" . $fileref['uid_foreign'],
'Important Missing file', // the header is optional
\TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, // the severity is optional as well and defaults to \TYPO3\CMS\Core\Messaging\FlashMessage::OK
TRUE // optional, whether the message should be stored in the session or only in the \TYPO3\CMS\Core\Messaging\FlashMessageQueue object (default is FALSE)
);
}
}
}
$flashMessageService = $this->objectManager->get(
......@@ -209,6 +229,7 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
// pid is deleted or hidden
$ret = true;
debug1('--------isImportantFileRef----------');
if ($fileRef['hidden'] == 1 || $fileRef['deleted'] == 1) {
debug1('file is deleted ----------------------------------------------');
if (!$this->pidExists($fileRef['pid'])) {
......@@ -216,7 +237,13 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
$this->deleteEntry($fileRef['uid_foreign'],$fileRef['tablenames']);
} else {
$this->deleteEntryIfHidden($fileRef['uid_foreign'],$fileRef['tablenames']);
}
$this->deleteEntry($fileRef['uid'],'sys_file_reference');
$ret = false;
}
if (in_array($fileRef['tablenames'],$this->ignoreTables)) {
$ret = false;
}
......@@ -246,6 +273,8 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
break;
}
}
debug1('------------------');
debug1($row);
$db->sql_free_result($resultSet);
return $ret;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment