Commit 31a0d7a2 authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Use correct versioned pid/t3ver_state in various functional tests

This change adapts leftover XML fixtures to use real PIDs instead
of pid=-1.

By this, some drive-by fixes within Extbase:

* Extbase count() queries now respect workspaces
* Extbase's QueryParser now filters out workspace overlays in ANY case

Resolves: #96176
Releases: main, 11.5
Change-Id: Ie249bf13bf27a263ceb9f9561840b570765dd157
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72408


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent c6d013f1
......@@ -2,7 +2,7 @@
<dataset>
<pages>
<uid>1</uid>
<pid>1</pid>
<pid>0</pid>
<title>visible</title>
<deleted>0</deleted>
</pages>
......@@ -26,7 +26,7 @@
</pages>
<pages>
<uid>5</uid>
<pid>-1</pid>
<pid>0</pid>
<title>deletedInWorkspace</title>
<t3_origuid>1</t3_origuid>
<t3ver_oid>1</t3ver_oid>
......
......@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Context\WorkspaceAspect;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\SingletonInterface;
......@@ -332,6 +333,10 @@ class Typo3DbBackend implements BackendInterface, SingletonInterface
} else {
$queryBuilder->count('*');
}
// Ensure to count only records in the current workspace
$context = GeneralUtility::makeInstance(Context::class);
$workspaceUid = (int)$context->getPropertyFromAspect('workspace', 'id');
$queryBuilder->getRestrictions()->add(GeneralUtility::makeInstance(WorkspaceRestriction::class, $workspaceUid));
try {
$count = $queryBuilder->execute()->fetchOne();
......
......@@ -659,7 +659,8 @@ class Typo3DbQueryParser
if (!empty($pageIdStatement)) {
$whereClause[] = $pageIdStatement;
}
} elseif (!empty($GLOBALS['TCA'][$tableName]['ctrl']['versioningWS'])) {
}
if (!empty($GLOBALS['TCA'][$tableName]['ctrl']['versioningWS'])) {
// Always prevent workspace records from being returned (except for newly created records)
$whereClause[] = $this->queryBuilder->expr()->eq($tableAlias . '.t3ver_oid', 0);
}
......
......@@ -251,7 +251,7 @@
<tx_blogexample_domain_model_post>
<uid>101</uid>
<pid>-1</pid>
<pid>0</pid>
<tstamp>121319</tstamp>
<blog>1</blog>
<author>3</author>
......@@ -266,12 +266,12 @@
<deleted>0</deleted>
<related_posts>1</related_posts>
<t3ver_oid>1</t3ver_oid>
<t3ver_state>-1</t3ver_state>
<t3ver_state>0</t3ver_state>
<t3ver_wsid>1</t3ver_wsid>
</tx_blogexample_domain_model_post>
<tx_blogexample_domain_model_post>
<uid>102</uid>
<pid>-1</pid>
<pid>0</pid>
<blog>1</blog>
<author>2</author>
<reviewer>2</reviewer>
......@@ -284,12 +284,12 @@
<sorting>2</sorting>
<deleted>0</deleted>
<t3ver_oid>2</t3ver_oid>
<t3ver_state>-1</t3ver_state>
<t3ver_state>0</t3ver_state>
<t3ver_wsid>1</t3ver_wsid>
</tx_blogexample_domain_model_post>
<tx_blogexample_domain_model_post>
<uid>103</uid>
<pid>-1</pid>
<pid>0</pid>
<blog>1</blog>
<author>2</author>
<reviewer>1</reviewer>
......@@ -302,7 +302,7 @@
<sorting>3</sorting>
<deleted>0</deleted>
<t3ver_oid>3</t3ver_oid>
<t3ver_state>-1</t3ver_state>
<t3ver_state>0</t3ver_state>
<t3ver_wsid>1</t3ver_wsid>
</tx_blogexample_domain_model_post>
</dataset>
......@@ -26,8 +26,8 @@ use ExtbaseTeam\BlogExample\Domain\Repository\PersonRepository;
use ExtbaseTeam\BlogExample\Domain\Repository\PostRepository;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
......@@ -80,7 +80,7 @@ class RelationTest extends FunctionalTestCase
public function attachPostToBlogAtTheEnd(): void
{
$queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tx_blogexample_domain_model_post');
$queryBuilder->getRestrictions()->removeAll()->add(new BackendWorkspaceRestriction(0, false));
$queryBuilder->getRestrictions()->removeAll()->add(new WorkspaceRestriction(0));
$countPostsOriginal = $queryBuilder
->count('*')
->from('tx_blogexample_domain_model_post')
......
......@@ -2,7 +2,7 @@
<dataset>
<pages>
<uid>102</uid>
<pid>-1</pid>
<pid>1</pid>
<title>Dummy WS 91</title>
<t3ver_oid>2</t3ver_oid>
<t3ver_stage>1</t3ver_stage>
......@@ -11,7 +11,7 @@
</pages>
<pages>
<uid>202</uid>
<pid>-1</pid>
<pid>1</pid>
<title>Dummy WS 92</title>
<t3ver_oid>2</t3ver_oid>
<t3ver_stage>1</t3ver_stage>
......@@ -20,7 +20,7 @@
</pages>
<pages>
<uid>104</uid>
<pid>-1</pid>
<pid>3</pid>
<title>Dummy WS 91</title>
<t3ver_oid>4</t3ver_oid>
<t3ver_stage>2</t3ver_stage>
......@@ -29,7 +29,7 @@
</pages>
<pages>
<uid>105</uid>
<pid>-1</pid>
<pid>5</pid>
<title>Dummy WS 91</title>
<t3ver_oid>6</t3ver_oid>
<t3ver_stage>1</t3ver_stage>
......@@ -38,7 +38,7 @@
</pages>
<pages>
<uid>106</uid>
<pid>-1</pid>
<pid>5</pid>
<title>Dummy WS 91</title>
<t3ver_oid>6</t3ver_oid>
<t3ver_stage>2</t3ver_stage>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment