extension_builder icon indicating copy to clipboard operation
extension_builder copied to clipboard

🐛 [BUG] Extending an existing Model throws a typoscript generation error

Open W4ldgeist opened this issue 3 years ago • 0 comments

Describe the bug If you create a Model, that extends an existing Model of another extension and add that in the field "Extend existing model class" and try to save the extension the error pops up "Could not generate typoscript setup".

To Reproduce Steps to reproduce the behavior:

  1. Create new extension
  2. Create new Model
  3. Add extend existing model class to the properties of the Model config
  4. Save extension and observer error "Extension could not be saved: Could not generate static typoscript, error: PHP Warning: Undefined array key "Koch\KochStsimport\Domain\Model\Fixture" in /var/www/html/public/typo3conf/ext/extension_builder/Classes/Domain/Model/Extension.php line 295"

TYPO3 Version TYPO3 11 (11.0.3) + PHP 8.0

Additional context I've tracked down the issue to the place here getClassHierarchy() If you change the line 295 from this: if (!is_array($classHierarchy[$parentClass])) { To this if (!\array_key_exists($parentClass, $classHierarchy) || !is_array($classHierarchy[$parentClass])) { Fixes the warning. But it seems the cleaner approach since in the first run through the key $parentClass cannot be set and the access attempt in is_array is therefore causing a PHP warning.

W4ldgeist avatar Aug 22 '22 08:08 W4ldgeist