Review main Merged

94642[BUGFIX] Fix `Undefined property: stdClass::$name` PHP Warning

Benjamin Franzke CR +2 V +2 Easy +2 −1 updated 07/03/26, 12:40

Commit message

Avoid a PHP warning when trying to read the composer.json
of an active extension that has been removed from the file
system.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oliver Klee +1
    • Garvin Hicking +1
    • Andreas Kienast +1
    • Benni Mack +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
    • Andreas Kienast +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 1

Review log 2124

  1. Benjamin Franzke uploaded patch set 1 07/01/26, 07:57

  2. core-ci voted on patch set 1 V -1 07/01/26, 08:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104130

  3. Benjamin Franzke uploaded patch set 2 V -1 07/01/26, 08:08

  4. core-ci voted on patch set 2 V +1 07/01/26, 08:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104134

  5. Helmut Hummel commented on patch set 2 CR -1 07/01/26, 09:07

    trying to understand the issue at first
  6. Benni Mack voted on patch set 2 CR +1 V +1 07/01/26, 09:07

  7. Benjamin Franzke commented on patch set 2 07/01/26, 09:15

    Reply

    `new \stdClass()` is assigned to `$composerManifest` and if the composer.json file does not exist, the object will be an empty object, therefore `$name` can not be accessed. (as mentioned in the commit message: happened when an active extension was removed but still referenced in PackageStates.php)
  8. Simon Schaufelberger voted on patch set 2 CR +1 V +1 07/01/26, 09:26

  9. Helmut Hummel commented on patch set 2 07/01/26, 09:26

    Reply

    With removed you actually mean removing the files and folders without using the TYPO3 API (extension manager)? Doesn't this break a ton of other things as well? Or do you mean something different?
  10. Helmut Hummel commented on patch set 2 07/01/26, 09:32

    PackageManager.php:923

    I would rather initialize with null here

    PackageManager.php:929

    and move this check outside the file_exists() condition, so that if no composer.json exists an exception is thrown upfront

    PackageManager.php:938

    I think this is confusing to silently ignore the warning here
  11. Benjamin Franzke commented on patch set 2 07/01/26, 10:27

    Reply

    Yes, "from the file system", e.g. when switching away from (Feature) branches, that contain new extensions, they are usually "just" removed from PackageStates.php.

    PackageManager.php:929 Reply

    I tried that in https://review.typo3.org/c/Packages/TYPO3.CMS/+/94642/1 which resulting in "Extension "functional-a41b513" is missing a composer.json file!" to be thrown in functionals, possibly because it seemed also the project root is checked via this method as well: https://git.typo3.org/typo3/CI/cms/-/jobs/5711636

    PackageManager.php:938 Reply

    hm, this does not ignore, but prevent the warning. But I agree that this code should ideally not try to real from that object at all, if it is known to be missing/incorrect. On the other hand, even an available `composer.json` could have been changed (since initial registration) and could therefore miss the `name` field. So at any point after parsing we need to check if the property exists. I'm not against doing that in a pre-check though.
  12. Simon Schaufelberger voted on patch set 2 CR 0 V 0 07/01/26, 10:32

  13. Benni Mack commented on patch set 2 07/01/26, 11:58

    Reply

    this is how i tested it as well
  14. Helmut Hummel commented on patch set 2 CR 0 07/02/26, 06:38

    Reply

    Acknowledged

    PackageManager.php:938 Reply

    > But I agree that this code should ideally not try to real from that object at all, if it is known to be missing/incorrect. Let's get this fixed first and clean up later. Would you mind creating a todo comment reflecting this. Then this should be good to go. Thanks!
  15. Helmut Hummel commented on patch set 2 07/02/26, 06:38

    PackageManager.php:923 Reply

    Acknowledged

    PackageManager.php:929 Reply

    Acknowledged
  16. Benjamin Franzke uploaded patch set 3 CR +1 V +1 07/03/26, 08:39

  17. Benjamin Franzke commented on patch set 3 07/03/26, 08:39

    PackageManager.php:938 Reply

    Ack, done. Thanks!
  18. core-ci voted on patch set 3 V +1 07/03/26, 08:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104271

  19. Benni Mack voted on patch set 3 CR +1 V +1 07/03/26, 09:31

  20. Oliver Klee voted on patch set 3 CR +1 07/03/26, 10:06

  21. Garvin Hicking voted on patch set 3 CR +1 V +1 07/03/26, 10:17

  22. Benjamin Franzke voted on patch set 3 CR +2 V +2 07/03/26, 12:40

  23. Andreas Kienast voted on patch set 3 CR +1 V +1 07/03/26, 12:40

  24. Benjamin Franzke merged patch set 4 07/03/26, 12:40