Extending model - Exception: Could not get value of property
Bug Report
Current Behavior On extending the EXT:news the following exception appears:
#1546632293 RuntimeException Could not get value of property "GeorgRinger\News\Domain\Model\NewsDefault::relatedLinks", make sure the property is either public or has a getter getRelatedLinks(), a hasser hasRelatedLinks() or an isser isRelatedLinks().
Environment
- TYPO3 version: 12.4.23
- news version: 12.0.1
- Is your TYPO3 installation set up with Composer (Composer Mode): yes
- OS: Debian GNU/Linux 11
Possible Solution Model properties should be nullable, e.g.:
/** @var ObjectStorage<Link>|null */
#[Lazy]
protected ?ObjectStorage $relatedLinks = null;
See also: https://docs.typo3.org/m/typo3/reference-exceptions/main/en-us/Exceptions/1546632293.html
Thank you
Can confirm it and can also confirm the possible solution.
Environment
- TYPO3 version: 12.4.23
- news version: 12.2
- PHP version: 8.3
We solved it quickly with this workaround:
$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['related_links']['config']['default'] = 0;
UPDATE tx_news_domain_model_news SET related_links = 0 WHERE related_links IS NULL;
I can confirm this also with the "contentElements" property, for the cores access check all properties with ObjectStorage or DateTime should be nullable due to a core limitation on that subject.
I can confirm the bug and fix with the sql statement as well
can you check https://github.com/georgringer/news/pull/new/2565-nullable ?
can you check https://github.com/georgringer/news/pull/new/2565-nullable ?
Looks good, my error unfortunately came back, switching to 2565-nullable branch worked.
I don't prefer marking ObjectStorages as nullable. Please initialize them as Core has done in TYPO3 10, too: https://github.com/TYPO3/typo3/blob/10.4/typo3/sysext/extbase/Classes/Domain/Model/FrontendUser.php#L140-L147
@akiessling wanna test https://github.com/georgringer/news/compare/2565-initalize-objectstorages?expand=1 thanks!
In combination with https://github.com/georgringer/news/pull/2723 i get my news displayed with https://github.com/georgringer/news/compare/2565-initalize-objectstorages?expand=1 👍 Thanks for taking care!
thanks for your feedback!