Project

General

Profile

Actions

Bug #79932

closed

extbase: wrong doctrine migration yields wrong DB result

Added by Markus Klein about 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
Start date:
2017-02-21
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
medium
Is Regression:
Yes
Sprint Focus:
On Location Sprint

Description

Using a query that causes a join via MM table yields wrong results due to incorrect transformation of the original query to doctrine.

The reason is that in \TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser::addUnionStatement() formerly the query was made up by LEFT JOINs with ON conditions. Those conditions have no been partially converted to where clauses, which causes rows to be discarded, which could hold null value after a LEFT JOIN.

Compare the queries before the doctrine migration and after.

Before:

SELECT tx_ext_domain_model_thing.uid, tx_ext_domain_model_thing.title, sys_category.title, sys_category_record_mm.* FROM tx_ext_domain_model_thing
  LEFT JOIN sys_category_record_mm AS sys_category_record_mm ON tx_ext_domain_model_thing.uid=sys_category_record_mm.uid_foreign
  LEFT JOIN sys_category AS sys_category ON sys_category_record_mm.uid_local=sys_category.uid AND sys_category_record_mm.tablenames = 'tx_ext_domain_model_thing' AND sys_category_record_mm.fieldname = 'categories'
WHERE 1=1 AND (tx_ext_domain_model_thing.sys_language_uid IN (0,-1))
      AND (((sys_category.sys_language_uid IN (0,-1))) OR sys_category.uid IS NULL)
      AND tx_ext_domain_model_thing.deleted=0
      AND ((sys_category.deleted=0) OR sys_category.uid IS NULL)
ORDER BY sys_category.title ASC, tx_ext_domain_model_thing.uid ASC

After:

SELECT `tx_ext_domain_model_thing`.* FROM `tx_ext_domain_model_thing` `tx_ext_domain_model_thing`
  LEFT JOIN `sys_category_record_mm` `sys_category_record_mm` ON `tx_ext_domain_model_thing`.`uid` = sys_category_record_mm.uid_foreign
  LEFT JOIN `sys_category` `sys_category` ON `sys_category_record_mm`.`uid_local` = sys_category.uid
WHERE ((`sys_category_record_mm`.`tablenames` = 'tx_ext_domain_model_thing') AND (`sys_category_record_mm`.`fieldname` = 'categories'))
      AND (`tx_ext_domain_model_thing`.`sys_language_uid` IN (0, -1))
      AND (`tx_ext_domain_model_thing`.`deleted` = 0)
      AND (((`sys_category`.`sys_language_uid` IN (0, -1)) AND (`sys_category`.`deleted` = 0)) OR (`sys_category`.`uid` IS NULL))
GROUP BY `tx_ext_domain_model_thing`.`uid`
ORDER BY `sys_category`.`title` ASC, `tx_ext_domain_model_thing`.`uid` ASC;

This is a regression to #77379.


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #79931: Extbase ordering of results via child record (through MM) wrongClosed2017-02-20

Actions
Related to TYPO3 Core - Bug #77379: Doctrine: Migrate extbase Typo3DbBackend and Typo3DbQueryParserClosedMarkus Hölzle2016-08-03

Actions
Related to TYPO3 Core - Bug #79988: Fix ensureCorrectPostOrderingByCategoryTitle extbase test on postgresClosed2017-02-24

Actions
Actions #1

Updated by Markus Klein about 7 years ago

  • Description updated (diff)
Actions #2

Updated by Gerrit Code Review about 7 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51782

Actions #3

Updated by Gerrit Code Review about 7 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/51782

Actions #4

Updated by Johannes Kasberger about 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF