Bug #90073

Change sorting of records in list module / draft workspaces breaks workspace module

Added by This Mächler 3 months ago. Updated 24 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Workspaces
Target version:
Start date:
2020-01-09
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
workkspace sorting
Complexity:
no-brainer
Is Regression:
Yes
Sprint Focus:

Description

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Argument 1 passed to TYPO3\CMS\Workspaces\Service\GridDataService::getSystemLanguages() must be of the type integer, null given, called in ..../typo3_src-9.5.13/typo3/sysext/workspaces/Classes/Service/GridDataService.php on line 601 | TypeError thrown in file ...../typo3_src-9.5.13/typo3/sysext/workspaces/Classes/Service/GridDataService.php in line 614. Requested URL: https://dev.sgparch.ch/typo3/index.php?route=%%2Fajax%%2Fworkspace%%2Fdispatch&token=--AnonymizedToken--

This breaks the workspace-module functionality (doesn't load properly), up the whole tree, appears when I change the sorting of records in a sys-folder in list module. This sys-folder and all ancestors produce the bug when I open the list module.

The only way to overcome this redactionally is to edit something in a sibling page/folder and do a workspace mass action there. Else you are stuck. Very annoying.

History

#1 Updated by This Mächler 3 months ago

The same thing also happens after moving a record from one sys-folder to another. The error occurs then when selecting the target folder in the workspace-module.

#2 Updated by This Mächler 3 months ago

When I create a NEW record in draft workspace, and move it then, the error does not show up.
I should tell my customers "it's safer to not use workspaces at all. But it might work if you are lucky" :-)

#3 Updated by rene elsaesser 2 months ago

This Mächler wrote:

The same thing also happens after moving a record from one sys-folder to another. The error occurs then when selecting the target folder in the workspace-module.

Hi,
moving records on pages also.

I changed the code(type hinting) in typo3/sysext/workspaces/Classes/Service/GridDataService.php : Line 613 to:

/**
 * @param int|null $pageId
 *
 * @return array
 */
public function getSystemLanguages(?int $pageId)
{
    if (!isset($this->systemLanguages)) {
        $translateTools = GeneralUtility::makeInstance(TranslationConfigurationProvider::class);
        $this->systemLanguages = $translateTools->getSystemLanguages($pageId);
    }
    return $this->systemLanguages;
}

and that seems does the trick

same as Bug https://forge.typo3.org/issues/89692?

#4 Updated by This Mächler 2 months ago

I can confirm that this solves the issue.
Nullable type hint does it:

...    
611: * @param int|null $pageId
...
614: public function getSystemLanguages(?int $pageId)

#5 Updated by This Mächler 2 months ago

  • Tags set to workkspace sorting
  • Complexity set to no-brainer

#6 Updated by Andreas Kiessling 24 days ago

I can confirm the error, the fix seems to work. But i think that it needs to be tackled differently.

The missing pid originates from \TYPO3\CMS\Workspaces\Service\WorkspaceService::getMoveToPlaceHolderFromPages -> the generated query does not contain any pid, but only wspid.
https://github.com/TYPO3/TYPO3.CMS/blob/d794b188606c0e9cd93d764ed71cedd92a051248/typo3/sysext/workspaces/Classes/Service/WorkspaceService.php#L532

And at another place, wspid is used instead of just using the pid property:
https://github.com/TYPO3/TYPO3.CMS/blob/d794b188606c0e9cd93d764ed71cedd92a051248/typo3/sysext/workspaces/Classes/Service/WorkspaceService.php#L686

So replacing the code in here seems to work https://github.com/TYPO3/TYPO3.CMS/blob/ca19817b4ccf312498f59428d215dfb26fb02074/typo3/sysext/workspaces/Classes/Service/GridDataService.php#L183

Before:

$pageId = $table === 'pages' ? $record['uid'] : $record['pid'];

After

$pageIdField = $table === 'pages' ? 'uid' : 'wspid';
$pageId = isset($record[$pageIdField]) ? (int)$record[$pageIdField] : null;

Also available in: Atom PDF