Bug #38406
closedExtension Import not working with postgresql and DBAL
100%
Description
the import of extensions is not working completely with DBAL on postgresql.
the problem lies in the function "insertLastVersion" in the file:
"/typo3/sysext/em/classes/database/class.tx_em_database.php"
on line 220, the following code:
$groupedRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'extkey, version, max(intversion) maxintversion',
'cache_extensions',
'repository=' . intval($repositoryUid),
'extkey'
);
... results in the following SQL-statement:
SELECT "extkey", "version", max("intversion") "maxintversion" FROM "cache_extensions" WHERE "repository" = 1 GROUP BY "extkey"
this is not valid in postgres due to:
1. "as" missing between max("intversion") and "maxintversion"
2. "version" missing from the group-clause
thus, the code must be changed to the following:
$groupedRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
'extkey, version, max(intversion) as maxintversion',
'cache_extensions',
'repository=' . intval($repositoryUid),
'extkey, version'
);
Updated by Jan Schreier over 12 years ago
I think the current (and the suggested code) should not have version in this statement at all. Otherwise the result set will include each row of the table. this is probably the reason why I and others got timeout problems with EM often. Also the goal is to identify the highest version and assign this row lastversion=1 a few lines down the code.
so the code should be:
$groupedRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 'extkey, max(intversion) as maxintversion', 'cache_extensions', 'repository=' . intval($repositoryUid), 'extkey' );
Updated by Gerrit Code Review over 12 years ago
- Status changed from New to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12898
Updated by Ernesto Baschny over 12 years ago
- % Done changed from 0 to 50
- TYPO3 Version changed from 4.7 to 4.5
The timeout of Jan doesn't seem to be related to this particular query (see #39056).
Anyway, the query proposed by Jan sounds reasonable. The "version" in the field list is not really required as it is not even used (although it won't break the GROUP BY) and fixing the "AS" for DBAL compatibility seems easy enough.
But since I won't be able to test or verify the fix, I'm glad if someone else can. The review request http://review.typo3.org/12898 provides the proper change (for master = 6.0, but will be backported up to 4.5, since the code hasn't changed in between).
Updated by Ernesto Baschny about 12 years ago
- Status changed from Under Review to Resolved
- % Done changed from 50 to 100
Applied in changeset 17b1d65787dabeea128f8e2c7c30772be4ebd491.