Commit 8ac9370c authored by Andreas Wolf's avatar Andreas Wolf

Merge branch 'issue-277-ter-fe2-doctrine' into 'develop'

Rework scheduler tasks to Doctrine

See merge request !266
parents 8b6590ee b0cc1775
Pipeline #2742 passed with stages
in 6 minutes and 56 seconds
......@@ -15,6 +15,7 @@ namespace T3o\TerFe2\Task;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Extbase\Scheduler\Task;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
......@@ -119,15 +120,24 @@ class CheckForOutdatedExtensions extends Task
*/
public function getNotOutdatedAndSecureVersions()
{
$rows = $this->getDatabaseConnection()->exec_SELECTgetRows(
'uid',
'tx_terfe2_domain_model_version',
'NOT deleted AND NOT hidden AND review_state >= 0',
'',
'upload_date ASC'
);
return $rows;
$tableName = 'tx_terfe2_domain_model_version';
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($tableName);
$queryBuilder->getRestrictions()->removeAll();
$statement = $queryBuilder
->select('uid')
->from($tableName)
->where(
$queryBuilder->expr()->eq('deleted', 0),
$queryBuilder->expr()->eq('hidden', 0),
$queryBuilder->expr()->gte('review_state', 0)
)
->orderBy('upload_date', 'ASC')
->execute();
$statement->execute();
return $statement->fetchAll(\PDO::FETCH_ASSOC);
}
/**
......@@ -265,22 +275,27 @@ class CheckForOutdatedExtensions extends Task
}
if ($isOutdated) {
$this->getDatabaseConnection()->exec_UPDATEquery(
'tx_terfe2_domain_model_version',
'uid = ' . $version->getUid(),
[
'review_state' => -2
]
);
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_terfe2_domain_model_version');
$queryBuilder
->update('tx_terfe2_domain_model_version')
->set('review_state', -2)
->where(
$queryBuilder->expr()->eq('uid', $version->getUid())
)
->execute();
if ($version->getExtension() && $version->getExtension()->getUid()) {
$this->getDatabaseConnection()->exec_UPDATEquery(
'tx_terfe2_domain_model_extension',
'uid = ' . $version->getExtension()->getUid(),
[
'tstamp' => time()
]
);
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_terfe2_domain_model_extension');
$queryBuilder
->update('tx_terfe2_domain_model_extension')
->set('tstamp', time())
->where(
$queryBuilder->expr()->eq('uid', $version->getUid())
)
->execute();
$this->solrIndexQueue->updateItem('tx_terfe2_domain_model_extension', $version->getExtension()->getUid());
}
}
......@@ -304,11 +319,4 @@ class CheckForOutdatedExtensions extends Task
}
}
/**
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
private function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
}
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