Review main Merged

79474[BUGFIX] Avoid exception for recent documents

Stephan Großberndt CR +2 V +2 Easy +12 −1 updated 07/06/23, 19:53

Commit message

Backend no longer crashes with an TableNotFoundException if a
table has been removed and an according item is in the list
of recent documents.

The patch catches the exception.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Oliver Klee +1
    • Benni Mack +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1316

  1. Stephan Großberndt uploaded patch set 1 06/21/23, 11:08

  2. core-ci voted on patch set 1 V +1 06/21/23, 11:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/42878

  3. Oliver Klee commented on patch set 1 06/21/23, 13:30

    Also, I propose covering this with a regression (unit) test.

    OpendocsToolbarItem.php:147

    For non-namespaced classes, we usually don't `use` them, but add a leading backslash when they're used: ``` } catch (\Exception) { ``` However, I wonder if we can narrow down the exception class we're catching here. (Catching the `Exception` base class is a code small that indicated that we might be catching too much, which could cause other problems to be swept under rug even if those should bubble up.) Maybe catch the `TableNotFoundException` instead? What do you think?
  4. Stephan Großberndt uploaded patch set 2 V +1 06/21/23, 19:25

  5. core-ci voted on patch set 2 V +1 06/21/23, 19:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/42888

  6. Stephan Großberndt commented on patch set 2 06/21/23, 19:35

    Reply

    Would you help me with this please? If I understood it correctly I would have to set up a mock `BackendUtility::getRecordWSOL()` method that throws a `TableNotFoundException` and then call `OpendocsToolbarItem->getMenuEntry()` which should not fail with the `TableNotFoundException` - but I can't create a mock for `BackendUtility::getRecordWSOL()` because it is a static method.

    OpendocsToolbarItem.php:147 Reply

    There are three other places in core where `use Exception;` is used, so I thought it is ok. Of course it is enough to catch the TableNotFoundException here to avoid the problem I had - I just thought it would be better to catch everything that goes wrong when fetching the record in a list of recent records and display nothing instead like it is done when the record has been deleted instead of breaking the whole backend because of this. If you think TableNotFoundException is enough, I am fine with that.
  7. Oliver Klee commented on patch set 2 06/22/23, 16:19

    Reply

    Ah, I see. Yes, indeed, static methods cannot be mocked. Then I propose we'll use a functional test instead. Do you need help with that? (I won't really be able to put time into this in June, but only in July, so if you need help, you might want to try to ask other folks as well, or we work on this together in July if you like.)
  8. Benni Mack commented on patch set 2 07/05/23, 12:24

    Tests will be rather tricky. This would mean that there was a previously opened document from an extension DB table with TCA ("tx_blabla_domain_model_bla"), which then gets uninstalled and then via a DB compare removed in DB, then the editor gets the open docs and gets a fatal error. TBH: I don't know if the testing framework even supports this kind of test (installing and uninstalling, updated core_caches) yet. All in all, this seems overkill for such a fix (and edge-case). However, I would recommend to add a comment to the catch() why this is caught and how this could happen in the first place.
  9. Stefan Bürk commented on patch set 2 07/05/23, 12:38

    Reply

    > I don't know if the testing framework even supports this kind of test (installing and uninstalling, updated core_caches) yet. All in all, this seems overkill for such a fix (and edge-case). Not really. I guess calling kind of several core internal methods manually would be needed to archieve that. E.g. calling the xtension uninstall, cetting caches to rewrite/clear inbetweeen and the whol "destructive" database compare stuff. To overkill IMO.
  10. Oliver Klee commented on patch set 2 07/06/23, 19:09

    Reply

    Let‘s skip writing the test for now. (I currently don’t have the time to help. Sorry.)
  11. Benni Mack uploaded patch set 3 V +1 07/06/23, 19:19

  12. Oliver Klee voted on patch set 3 CR +1 07/06/23, 19:22

  13. core-ci voted on patch set 3 V +1 07/06/23, 19:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43814

  14. Benni Mack voted on patch set 3 V +1 CR +1 07/06/23, 19:52

  15. Oli Bartsch voted on patch set 3 V +2 CR +2 07/06/23, 19:53

  16. Oli Bartsch merged patch set 4 07/06/23, 19:53