Commit e3bd22aa authored by Christoph Hofmann's avatar Christoph Hofmann

update

parent 79ad9d7b
......@@ -52,7 +52,13 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
*/
protected $configurationManager;
/**
/**
* fileCollectionRepository
*
* @var \TYPO3\CMS\Core\Resource\FileCollectionRepository
* @inject
*/
protected $fileCollectionRepository;
/**
......@@ -84,10 +90,15 @@ 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');
$this->fileCollectionRepository = $this->objectManager->get('TYPO3\CMS\Core\Resource\FileCollectionRepository');
$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;
if (is_array($ignoreTablesTS)){
foreach ($ignoreTablesTS as $ignoreTable) {
$this->ignoreTables [] = $ignoreTable;
}
} else {
exit;
}
......@@ -107,7 +118,7 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
$cleaned = array();
foreach ($missingFiles as $missingFile) {
$count++;
if ($count > 50) {
if ($count > 10) {
break;
}
$storageUid = $missingFile['storage'];
......@@ -115,7 +126,7 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
$conf = $storage->getConfiguration();
$fileName = GeneralUtility::getFileAbsFileName($conf['basePath']).ltrim($missingFile['identifier'],"\\\/");
if (!file_exists($fileName)) {
$file = $this->getFile($missingFile['uid'], $missingFile['storage'], $missingFile['identifier']);
//$file = $this->getFile($missingFile['uid'], $missingFile['storage'], $missingFile['identifier']);
if (!is_null($file)) {
$name = $file->getName();
}
......@@ -222,62 +233,12 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
$msgout ,
'The frgments of the following files are cleaned', // the header is optional
'The fragments of the following files are cleaned', // 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)
)
);
}
return TRUE;
foreach ($missingFiles as $missingFile) {
$table = 'sys_file_reference';
if ($missingFile != 20092) {
$resultSet = $db->exec_SELECTquery('*', $table, "uid_local = " . $missingFile);
$sys_file_references = array();
if ($resultSet) {
while ($row = $resultSet->fetch_assoc()) {
$sys_file_references[$row['uid']] = $row;
}
} else {
debug1($db->debug_lastBuiltQuery);
}
// debug1("sys_file_references for file ".$missingFile);
$found = 0;
foreach ($sys_file_references as $sys_file_reference) {
//debug1($sys_file_reference ['tablenames'].' '.$sys_file_reference['uid_foreign']);
$found = 1;
}
$db->sql_free_result($resultSet);
$table = 'sys_refindex';
$whereEnabledFields = BackendUtility::BEenableFields($table)
. BackendUtility::deleteClause($table);
//$missingFiles = array();
//$missingFiles[2092] = 2092;
$resultSet = $db->exec_SELECTquery('*', $table, "ref_uid = " . $missingFile . ' AND ref_table = ' .
$db->fullQuoteStr('sys_file', $table));
$sys_refindexes = array();
while ($row = $resultSet->fetch_assoc()) {
$sys_refindexes[$row['uid']] = $row;
if ($row['tablename'] != 'sys_file_metadata') {
$found = 1;
//debug1($row['tablename']);
}
}
$db->sql_free_result($resultSet);
if ($found == 0) {
debug1('delete File ' . $missingFile);
$table = 'sys_file';
$db->exec_DELETEquery($table,'uid = ' .$missingFile);
$table = 'sys_file_metadata';
$db->exec_DELETEquery($table, 'file = ' .$missingFile);
}
}
}
......@@ -290,6 +251,7 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
}
private function isImportantFileRef($fileRef) {
/** @var \TYPO3\CMS\Core\Resource\Collection\StaticFileCollection $fileCol */
//check if file is important
// deleted
// hidden
......@@ -318,11 +280,6 @@ class MissingClean extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
}
if ($fileRef['tablenames'] == 'sys_file_collection') {
debug1('----------------sys_file_collection----------------------------');
$ret = false;
}
if ($ret) {
if (!$this->isImportantContent($fileRef)) {
$ret = false;
......
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