Review main Merged

70741[BUGFIX] PHP 8 warnings: Undefined array key in EXT:impexp

Alexander Nitsche CR +2 V +2 Hard +220 −55 updated 09/13/21, 13:01

Commit message

Some EXT:impexp functional tests threw warnings of the
type "Undefined array key" which did not abort the test
but were written unnoticed to the TYPO3 logs. These
warnings are fixed in this patch.

Review

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

Issues 1

Files 15

Review log 2533

Show 48 earlier messages
  1. Alexander Nitsche uploaded patch set 1 08/24/21, 15:43

  2. core-ci voted on patch set 1 V +1 08/24/21, 16:02 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15521

  3. Alexander Nitsche uploaded patch set 2 08/24/21, 20:55

  4. core-ci voted on patch set 2 V -1 08/24/21, 21:25 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15537

  5. Alexander Nitsche uploaded patch set 3 08/25/21, 10:49

  6. core-ci voted on patch set 3 V -1 08/25/21, 10:53 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15580

  7. Alexander Nitsche uploaded patch set 4 08/25/21, 11:13

  8. core-ci voted on patch set 4 V +1 08/25/21, 11:35 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15581

  1. Alexander Nitsche updated the commit message in patch set 5 08/25/21, 12:34

  2. core-ci voted on patch set 5 V +1 08/25/21, 12:57 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15589

  3. Alexander Nitsche commented on patch set 5 08/25/21, 13:10

    All changes are covered by existing functional tests. This patch is mainly about adding all sorts of `??` to array field accesses and to extend the testing fixtures by some new default array fields. Furthermore the code lines which print the fixture files on demand are added to ImportTest.php class similar to ExportTest.php.
  4. Christian Kuhn commented on patch set 5 08/26/21, 05:07

    that's weird. those warnings should trigger functional fail. i mean, we had tons of php8 related warnings that we fixed due to functional fails. did we (I?) somehow managed to fuck the functional setup up in this regard lately? or does the impexp extension fiddle with log setup, or has a central place where generic exceptions are caught or something like that? should be investigated, but does not affect this patch directly.
  5. Alexander Nitsche commented on patch set 5 08/26/21, 13:47

    Reply

    Good question .. i did not actively change the logging behaviour but .. for the time being i will watch the logs manually (script command ready :) and have a look into the logging after the next patch (#95007). Maybe the recent changes in the logging area have an impact here.
  6. Jochen Roth uploaded patch set 6 09/06/21, 07:27

  7. core-ci voted on patch set 6 V +1 09/06/21, 07:45 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16305

  8. Alexander Nitsche commented on patch set 6 09/06/21, 07:55

    ImportExport.php:898

    I would test for the full `$softref['subst']['tokenID']` here as is used one line below.
  9. Jochen Roth uploaded patch set 7 09/06/21, 08:16

  10. Jochen Roth commented on patch set 7 09/06/21, 08:18

    ImportExport.php:898 Reply

    Ack
  11. core-ci voted on patch set 7 V +1 09/06/21, 08:34 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16308

  12. Alexander Nitsche commented on patch set 7 V +1 CR +1 09/06/21, 09:01

    No "Undefined array key .." appearing in EXT:impexp functional tests run with ``` ./Build/Scripts/runTests.sh -s functional -d mariadb -p 8.0 -e "-v typo3/sysext/impexp/Tests/Functional" find typo3temp/var/tests/**/typo3temp/var/log -name "*.log" -exec cat {} \; ```
  13. Jochen Roth voted on patch set 7 V +1 CR +1 09/10/21, 08:23

  14. Jochen Roth wrote 09/10/21, 08:30

    Removed Verified+1 by Jochen <rothjochen@gmail.com>
  15. Jochen Roth wrote 09/10/21, 08:30

    Removed Code-Review+1 by Jochen <rothjochen@gmail.com>
  16. Jochen Roth voted on patch set 7 V +1 CR +1 09/10/21, 08:35

  17. Oli Bartsch commented on patch set 7 09/10/21, 09:45

    Export.php:1180

    Shouldn't this be skipped if not set? Or do we rely on this being serialized as NULL?

    Import.php:727

    Isn't this change of behaviour? Previously if this was not set, $this->pid was used. Now, the assignment "$this->addSingle($importData, 'pages', (int)$pageUid, $pid)" as well as the "unset($remainingPages[$pageUid]);" is completely skipped.

    ImportExport.php:742

    Might be changed to "false", making the intention clear.

    ImportExport.php:778

    Let's change this to "false"

    ImportExport.php:898

    This if/else could simply be done like this: $mode = $this->softrefCfg[$softref['subst']['tokenID'] ?? null]['mode'] ?? '';

    ImportExport.php:998

    Let's just use $cfg['title'] ?? false here. This implicit checks for "not empty".

    ExportPageTreeView.php:183

    Looks like the initial intention was to check for "not empty", right?
  18. crell commented on patch set 7 09/10/21, 13:34

    Otherwise I agree with Oliver's comments here. Thanks!

    Export.php:1180 Reply

    The change here most accurately mimics what the behavior was in 7.4. Whether or not that's actually the desired behavior is another question. My gut feeling is that it probably should be skipped, which could be done either with a wrapping if (isset()) or with a ternary with empty string default. I also wonder if the other keys here might sometimes be empty. (This is why array pseudo-structures are so not nice. 😊 )

    ExportPageTreeView.php:183 Reply

    I think in other similar places we ended up doing: $pageTreeState = ($pageTreeState['stateHash'] ?? []) ?: []; Although that is highly ugly and a sign that something else is wrong. It is the most compact way to maintain the current logic.

    ImportTest.php:101

    Why is this added but commented out immediately? I don't follow.
  19. Alexander Nitsche commented on patch set 7 09/10/21, 18:08

    Thanks for your extensive feedback. I incorporated most of it.

    Export.php:1180 Reply

    I would like to move changes in logic into a separate patch and handle only those PHP 8 array key warnings in this one.

    Import.php:727 Reply

    Ack

    ImportExport.php:742 Reply

    Ack

    ImportExport.php:778 Reply

    Ack

    ImportExport.php:898 Reply

    Ack

    ImportExport.php:998 Reply

    Ack

    ExportPageTreeView.php:183 Reply

    ImportTest.php:101 Reply

    This is to facilitate updating fixtures. If the implementation changes, comment out these lines, run the test which updates the fixture, and comment those lines in again.
  20. Alexander Nitsche uploaded patch set 8 09/10/21, 18:10

  21. core-ci voted on patch set 8 V +1 09/10/21, 18:26 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16509

  22. Jochen Roth voted on patch set 8 V +1 CR +1 09/13/21, 11:44

  23. Oli Bartsch commented on patch set 8 V +1 CR +1 09/13/21, 11:45

    ExportPageTreeView.php:183 Reply

    Ack
  24. Oli Bartsch voted on patch set 8 V +2 CR +2 09/13/21, 13:01

  25. Oli Bartsch merged patch set 9 09/13/21, 13:01