Review main Merged

71532[BUGFIX] Undefined array keys related to workspaces

Francois Suter CR +2 V +2 Easy +3 −3 updated 10/11/21, 18:15

Commit message

Fixes some undefined array key errors which happen in some specific
scenarios related to workspaces usage.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Jochen Roth +1
  • Verified V +2 Done
    • Benni Mack +2
    • Jochen Roth +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1315

  1. Francois Suter uploaded patch set 1 10/11/21, 13:17

  2. Nikita Hovratov commented on patch set 1 CR -1 10/11/21, 13:28

    WorkspaceRecord.php:227

    This does change the behaviour. I would say, just add a null value like before, but with the coalesce operator.
  3. Francois Suter commented on patch set 1 10/11/21, 13:31

    WorkspaceRecord.php:227 Reply

    I can see your point, although I don't think it changes the end result. But I'll upload a new version.
  4. Christian Kuhn commented on patch set 1 CR -1 10/11/21, 13:33

    The change in BackendUserAuthentication is ok. In case we need to discuss the other two places longer, we could also split the change to already bring in the BackendUserAuthentication change since that's also ext:core and not only ext:workspaces.

    AbstractRecord.php:90

    I don't understand this one. AbstractRecord is used for StageRecord and WorkspaceRecord. Both tables have uid's and instances of this class seem to be created via the static fetch() method above, which explicitely uses a uid WHERE. So I wonder how / why there can be no uid here? Maybe this could / should be fixed elsewhere and the getUid() is a misuse here? Maybe actively throw an exception here if getUid() on a non-record is called?
  5. Francois Suter commented on patch set 1 10/11/21, 13:38

    Reply

    OK, makes sense.

    AbstractRecord.php:90 Reply

    I agree that this should probably be fixed upstream, but I don't know where. What I observed is that when you're in the LIVE workspace "$this->record" is actually "null".
  6. core-ci voted on patch set 1 V +1 10/11/21, 13:39 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17918

  7. Christian Kuhn commented on patch set 1 10/11/21, 13:49

    AbstractRecord.php:90 Reply

    I see. Could be worth checking the reason, I'd say, though. Imho instances of these models should not be called / used when they can't be created properly, thus the exception instead.
  8. Francois Suter commented on patch set 1 10/11/21, 13:57

    AbstractRecord.php:90 Reply

    Here's what happens: the ReviewController tries to get all the stages available for the user in the given workspace by calling: "\TYPO3\CMS\Workspaces\Service\StagesService::getStagesForWSUser()". This triggers the following call: $stageRecords = $this->getWorkspaceRecord()->getStages(); \TYPO3\CMS\Workspaces\Service\StagesService::getWorkspaceRecord() does just this: return WorkspaceRecord::get($this->getWorkspaceId()); When the workspace id is 0, an empty array is returned. So we have indeed a situation where AbstractRecord is created with "$this->record" being an empty array, thus no uid. So the correct fix is to do like "\TYPO3\CMS\Workspaces\Service\StagesService::getStagesForWS()": if ($this->getWorkspaceId() === 0) { $stages = []; } I'll do that in a separate patch.
  9. Francois Suter uploaded patch set 2 10/11/21, 13:59

  10. Francois Suter commented on patch set 2 10/11/21, 14:00

    Reply

    I haven't separated it, as the new patch is simpler and I separated the controversial part about AbstractRecord.
  11. Francois Suter commented on patch set 2 10/11/21, 14:07

  12. core-ci voted on patch set 2 V +1 10/11/21, 14:14 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17920

  13. Jochen Roth voted on patch set 2 V +1 CR +1 10/11/21, 15:10

  14. Benni Mack voted on patch set 2 V +2 CR +2 10/11/21, 18:15

  15. Benni Mack merged patch set 3 10/11/21, 18:15