Skip to content

Commit

Permalink
[TASK] Avoid usage of deprecated QueryBuilder::execute() in TYPO3 v12
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-appelt committed Jul 16, 2023
1 parent 006cef5 commit 1aecde1
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 43 deletions.
2 changes: 2 additions & 0 deletions Build/phpstan10.neon
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ parameters:
- '#Constant LF not found.#'
- '#Cannot call method fetchAllAssociative\(\) on Doctrine\\DBAL\\Driver\\ResultStatement\|int.#'
- '#Cannot call method fetchAssociative\(\) on Doctrine\\DBAL\\Driver\\ResultStatement\|int.#'
- '#Call to an undefined method TYPO3\\CMS\\Core\\Database\\Query\\QueryBuilder::executeQuery\(\).#'
- '#Call to an undefined method TYPO3\\CMS\\Core\\Database\\Query\\QueryBuilder::executeStatement\(\).#'
-
message: '#Call to an undefined method TYPO3\\CMS\\Frontend\\ContentObject\\RecordsContentObject::setRequest\(\).#'
path: %currentWorkingDirectory%/Classes/DataProcessing/ContainerProcessor.php
Expand Down
48 changes: 36 additions & 12 deletions Classes/Domain/Factory/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ public function fetchRecordsByPidAndLanguage(int $pid, int $language): array
$queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
)
)
->orderBy('sorting', 'ASC')
->execute();
->orderBy('sorting', 'ASC');
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
return (array)$stm->fetchAll();
}
Expand All @@ -104,8 +108,12 @@ public function fetchOneRecord(int $uid): ?array
'uid',
$queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$record = $stm->fetch();
} else {
Expand All @@ -131,8 +139,12 @@ public function fetchOneDefaultRecord(array $record): ?array
'sys_language_uid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$record = $stm->fetch();
} else {
Expand Down Expand Up @@ -160,8 +172,12 @@ public function fetchRecordsByParentAndLanguage(int $parent, int $language): arr
$queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
)
)
->orderBy('sorting', 'ASC')
->execute();
->orderBy('sorting', 'ASC');
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
return (array)$stm->fetchAll();
}
Expand Down Expand Up @@ -189,8 +205,12 @@ public function fetchOverlayRecords(array $records, int $language): array
'sys_language_uid',
$queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
return (array)$stm->fetchAll();
}
Expand All @@ -211,8 +231,12 @@ public function fetchOneOverlayRecord(int $uid, int $language): ?array
'sys_language_uid',
$queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$record = $stm->fetch();
} else {
Expand Down
48 changes: 36 additions & 12 deletions Classes/Hooks/Datahandler/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ public function fetchOneRecord(int $uid): ?array
'uid',
$queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$record = $stm->fetch();
} else {
Expand All @@ -67,8 +71,12 @@ public function fetchOverlayRecords(array $record): array
'l18n_parent',
$queryBuilder->createNamedParameter((int)$record['uid'], Connection::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
return (array)$stm->fetchAll();
}
Expand All @@ -89,8 +97,12 @@ public function fetchOneTranslatedRecordByl10nSource(int $uid, int $language): ?
'sys_language_uid',
$queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$record = $stm->fetch();
} else {
Expand All @@ -116,8 +128,12 @@ public function fetchOneTranslatedRecordByLocalizationParent(int $uid, int $lang
'sys_language_uid',
$queryBuilder->createNamedParameter($language, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$record = $stm->fetch();
} else {
Expand Down Expand Up @@ -148,8 +164,12 @@ public function fetchRecordsByParentAndLanguage(int $parent, int $language): arr
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
)
)
->orderBy('sorting', 'ASC')
->execute();
->orderBy('sorting', 'ASC');
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
return (array)$stm->fetchAll();
}
Expand Down Expand Up @@ -178,8 +198,12 @@ public function fetchContainerRecordLocalizedFreeMode(int $defaultUid, int $lang
't3ver_oid',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$record = $stm->fetch();
} else {
Expand Down
48 changes: 36 additions & 12 deletions Classes/Integrity/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ public function getNonDefaultLanguageContainerRecords(array $cTypes): array
'sys_language_uid',
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$results = $stm->fetchAll();
} else {
Expand Down Expand Up @@ -75,8 +79,12 @@ public function getNonDefaultLanguageContainerChildRecords(): array
'sys_language_uid',
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$results = $stm->fetchAll();
} else {
Expand Down Expand Up @@ -109,8 +117,12 @@ public function getChildrenByContainerAndColPos(int $containerId, int $colPos, i
$queryBuilder->createNamedParameter($colPos, Connection::PARAM_INT)
)
)
->orderBy('sorting')
->execute();
->orderBy('sorting');
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
return (array)$stm->fetchAll();
}
Expand All @@ -132,8 +144,12 @@ public function getContainerRecords(array $cTypes): array
'sys_language_uid',
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$results = $stm->fetchAll();
} else {
Expand Down Expand Up @@ -165,8 +181,12 @@ public function getContainerRecordsFreeMode(array $cTypes): array
'l18n_parent',
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$results = $stm->fetchAll();
} else {
Expand Down Expand Up @@ -194,8 +214,12 @@ public function getContainerChildRecords(): array
'sys_language_uid',
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$results = $stm->fetchAll();
} else {
Expand Down
15 changes: 12 additions & 3 deletions Classes/Integrity/IntegrityFix.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use B13\Container\Integrity\Error\WrongPidError;
use B13\Container\Tca\Registry;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand Down Expand Up @@ -72,8 +73,12 @@ public function changeContainerParentToDefaultLanguageContainer(ChildInTranslate
'uid',
$queryBuilder->createNamedParameter($child['uid'], \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$queryBuilder->executeStatement();
} else {
$queryBuilder->execute();
}
}

/**
Expand Down Expand Up @@ -120,7 +125,11 @@ public function languageMode(array $errors): void
// i think this is always true
$stm->set('l10n_source', $defaultChildRecord['uid']);
}
$stm->execute();
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeStatement();
} else {
$stm = $stm->execute();
}
}
}
// disconnect container ?
Expand Down
16 changes: 12 additions & 4 deletions Classes/Service/RecordLocalizeSummaryModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ protected function getContainerUids(array $uids): array
'CType',
$queryBuilder->createNamedParameter($containerCTypes, Connection::PARAM_STR_ARRAY)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$rows = $stm->fetchAll();
} else {
Expand Down Expand Up @@ -148,8 +152,12 @@ protected function getContainerChildren(array $uids): array
'tx_container_parent',
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
)
)
->execute();
);
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() >= 12) {
$stm = $stm->executeQuery();
} else {
$stm = $stm->execute();
}
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() === 10) {
$rows = $stm->fetchAll();
} else {
Expand Down

0 comments on commit 1aecde1

Please sign in to comment.