Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Avoid usage of deprecated QueryBuilder::execute() in TYPO3 v12 #393

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Build/phpstan10.neon
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ parameters:
message: '#Property TYPO3\\TestingFramework\\Core\\Acceptance\\Helper\\AbstractPageTree::.*tester .*#'
path: %currentWorkingDirectory%/Tests/Acceptance/Support/PageTree.php
- '#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 protected method getTypoScriptFrontendController\(\) of class TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer.#'
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
Loading