Commit 21dba7b1 authored by Michael Oehlhof's avatar Michael Oehlhof Committed by Wouter Wolters
Browse files

[TASK] Doctrine: migrate ext:recycler/Utility

Resolves: #75636
Releases: master
Change-Id: I49611c3d0e6a0ec56e05871c5beb7f7de4bce949
Reviewed-on: https://review.typo3.org/47682


Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
parent ed825b27
......@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Recycler\Utility;
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryContextType;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -83,15 +85,23 @@ class RecyclerUtility
if ($uid === 0) {
return $output;
}
$databaseConnection = static::getDatabaseConnection();
$clause = trim($clause) !== '' ? ' AND ' . $clause : '';
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->getQueryContext()->setContext(QueryContextType::UNRESTRICTED);
$clause = trim($clause);
$loopCheck = 100;
while ($loopCheck > 0) {
$loopCheck--;
$res = $databaseConnection->exec_SELECTquery('uid,pid,title,deleted,t3ver_oid,t3ver_wsid', 'pages', 'uid=' . $uid . $clause);
if ($res !== false) {
$row = $databaseConnection->sql_fetch_assoc($res);
$databaseConnection->sql_free_result($res);
$queryBuilder
->select('uid', 'pid', 'title', 'deleted', 't3ver_oid', 't3ver_wsid')
->from('pages')
->where($queryBuilder->expr()->eq('uid', (int)$uid));
if (!empty($clause)) {
$queryBuilder->andWhere($clause);
}
$row = $queryBuilder->execute()->fetch();
if ($row !== false) {
BackendUtility::workspaceOL('pages', $row);
if (is_array($row)) {
BackendUtility::fixVersioningPid('pages', $row);
......@@ -143,13 +153,17 @@ class RecyclerUtility
if ((int)$pid === 0) {
return false;
}
$db = static::getDatabaseConnection();
$res = $db->exec_SELECTquery('deleted', 'pages', 'uid=' . (int)$pid);
if ($res !== false) {
$record = $db->sql_fetch_assoc($res);
return (bool)$record['deleted'];
}
return false;
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->getQueryContext()->setContext(QueryContextType::UNRESTRICTED);
$deleted = $queryBuilder
->select('deleted')
->from('pages')
->where($queryBuilder->expr()->eq('uid', (int)$pid))
->execute()
->fetchColumn();
return (bool)$deleted;
}
/**
......@@ -161,13 +175,17 @@ class RecyclerUtility
*/
public static function getPidOfUid($uid, $table)
{
$db = static::getDatabaseConnection();
$res = $db->exec_SELECTquery('pid', $table, 'uid=' . (int)$uid);
if ($res !== false) {
$record = $db->sql_fetch_assoc($res);
return $record['pid'];
}
return 0;
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getQueryContext()->setContext(QueryContextType::UNRESTRICTED);
$pid = $queryBuilder
->select('pid')
->from($table)
->where($queryBuilder->expr()->eq('uid', (int)$uid))
->execute()
->fetchColumn();
return (int)$pid;
}
/**
......@@ -185,16 +203,6 @@ class RecyclerUtility
return $TCA;
}
/**
* Returns an instance of DatabaseConnection
*
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
protected static function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
/**
* Returns the BackendUser
*
......
Supports Markdown
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