news icon indicating copy to clipboard operation
news copied to clipboard

Extending model - Exception: Could not get value of property

Open peterbenke opened this issue 1 year ago • 2 comments

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

peterbenke avatar Nov 19 '24 14:11 peterbenke

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;

ayacoo avatar Feb 08 '25 15:02 ayacoo

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.

featdd avatar Feb 18 '25 11:02 featdd

I can confirm the bug and fix with the sql statement as well

akiessling avatar Oct 15 '25 15:10 akiessling

can you check https://github.com/georgringer/news/pull/new/2565-nullable ?

georgringer avatar Oct 17 '25 09:10 georgringer

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.

akiessling avatar Oct 27 '25 15:10 akiessling

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

sfroemkenjw avatar Oct 29 '25 06:10 sfroemkenjw

@akiessling wanna test https://github.com/georgringer/news/compare/2565-initalize-objectstorages?expand=1 thanks!

georgringer avatar Oct 29 '25 18:10 georgringer

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!

akiessling avatar Oct 29 '25 20:10 akiessling

thanks for your feedback!

georgringer avatar Oct 30 '25 21:10 georgringer