*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
*/
protected function checkPage($page)
{
- $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow('uid, title, deleted, hidden, starttime, endtime', 'pages', 'uid = ' . (int)$page);
+ // Get page ID on which the content element in fact is located
+ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
+ $queryBuilder->getRestrictions()->removeAll();
+ $row = $queryBuilder
+ ->select('uid', 'title', 'deleted', 'hidden', 'starttime', 'endtime')
+ ->from('pages')
+ ->where($queryBuilder->expr()->eq('uid', (int)$page))
+ ->execute()
+ ->fetch();
$this->responsePage = true;
if ($row) {
if ($row['deleted'] == '1') {
$this->errorParams['page']['title'] = $row['title'];
$this->errorParams['page']['uid'] = $row['uid'];
$this->responsePage = false;
- } elseif ($row['hidden'] == '1' || $GLOBALS['EXEC_TIME'] < (int)$row['starttime'] || $row['endtime'] && (int)$row['endtime'] < $GLOBALS['EXEC_TIME']) {
+ } elseif ($row['hidden'] == '1'
+ || $GLOBALS['EXEC_TIME'] < (int)$row['starttime']
+ || $row['endtime'] && (int)$row['endtime'] < $GLOBALS['EXEC_TIME']
+ ) {
$this->errorParams['errorType']['page'] = self::HIDDEN;
$this->errorParams['page']['title'] = $row['title'];
$this->errorParams['page']['uid'] = $row['uid'];
protected function checkContent($page, $anchor)
{
// Get page ID on which the content element in fact is located
- $res = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
- 'uid, pid, header, deleted, hidden, starttime, endtime',
- 'tt_content',
- 'uid = ' . (int)$anchor
- );
+ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tt_content');
+ $queryBuilder->getRestrictions()->removeAll();
+ $row = $queryBuilder
+ ->select('uid', 'pid', 'header', 'deleted', 'hidden', 'starttime', 'endtime')
+ ->from('tt_content')
+ ->where($queryBuilder->expr()->eq('uid', (int)$anchor))
+ ->execute()
+ ->fetch();
$this->responseContent = true;
// this content element exists
- if ($res) {
+ if ($row) {
// page ID on which this CE is in fact located.
- $correctPageID = $res['pid'];
+ $correctPageID = $row['pid'];
// Check if the element is on the linked page
// (The element might have been moved to another page)
if (!($correctPageID === $page)) {
$this->responseContent = false;
} else {
// The element is located on the page to which the link is pointing
- if ($res['deleted'] == '1') {
+ if ($row['deleted'] == '1') {
$this->errorParams['errorType']['content'] = self::DELETED;
- $this->errorParams['content']['title'] = $res['header'];
- $this->errorParams['content']['uid'] = $res['uid'];
+ $this->errorParams['content']['title'] = $row['header'];
+ $this->errorParams['content']['uid'] = $row['uid'];
$this->responseContent = false;
- } elseif ($res['hidden'] == '1' || $GLOBALS['EXEC_TIME'] < (int)$res['starttime'] || $res['endtime'] && (int)$res['endtime'] < $GLOBALS['EXEC_TIME']) {
+ } elseif ($row['hidden'] == '1' || $GLOBALS['EXEC_TIME'] < (int)$row['starttime'] || $row['endtime'] && (int)$row['endtime'] < $GLOBALS['EXEC_TIME']) {
$this->errorParams['errorType']['content'] = self::HIDDEN;
- $this->errorParams['content']['title'] = $res['header'];
- $this->errorParams['content']['uid'] = $res['uid'];
+ $this->errorParams['content']['title'] = $row['header'];
+ $this->errorParams['content']['uid'] = $row['uid'];
$this->responseContent = false;
}
}
* The TYPO3 project - inspiring people to share!
*/
-use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
/**
// for hidden records is enabled.
if ($reportHiddenRecords) {
$row = $this->getRecordRow($tableName, $rowid, 'disabled');
- if ($row === null) {
+ if ($row === false) {
$response = false;
$errorType = self::DISABLED;
}
// if we can find a non deleted record.
if ($row === null) {
$row = $this->getRecordRow($tableName, $rowid, 'deleted');
- if ($row === null) {
+ if ($row === false) {
$response = false;
$errorType = self::DELETED;
}
// deleted one.
if ($row === null) {
$row = $this->getRecordRow($tableName, $rowid, 'all');
- if ($row === null) {
+ if ($row === false) {
$response = false;
$errorType = '';
}
* @param string $tableName The name of the table from which the record should be fetched.
* @param int $uid The UID of the record that should be fetched.
* @param string $filter A filter setting, can be empty or "disabled" or "deleted".
- * @return array|NULL The result row as associative array or NULL if nothing is found.
+ * @return array|bool The result row as associative array or false if nothing is found.
*/
protected function getRecordRow($tableName, $uid, $filter = '')
{
- $whereStatement = 'uid = ' . (int)$uid;
+ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
switch ($filter) {
case self::DISABLED:
- $whereStatement .= BackendUtility::BEenableFields($tableName) . BackendUtility::deleteClause($tableName);
+ // All default restrictions for the QueryBuilder stay active
break;
case self::DELETED:
- $whereStatement .= BackendUtility::deleteClause($tableName);
+ $queryBuilder->getRestrictions()
+ ->removeAll()
+ ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
break;
+ default:
+ $queryBuilder->getRestrictions()->removeAll();
}
- $row = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
- '*',
- $tableName,
- $whereStatement
- );
-
- // Since exec_SELECTgetSingleRow can return NULL or FALSE we
- // make sure we always return NULL if no row was found.
- if ($row === false) {
- $row = null;
- }
+ $row = $queryBuilder
+ ->select('*')
+ ->from($tableName)
+ ->where($queryBuilder->expr()->eq('uid', (int)$uid))
+ ->execute()
+ ->fetch();
return $row;
}