1

Im using TYPO3 version 7.6.32 with News system extension, and from time to time i get an error who then disappears alone without changing anything :

Error :

Call to undefined method 
GeorgRinger\News\Domain\Model\FileReference::getType()

Error thrown in file /var/www/www.example.com/typo3conf/ext/in_news/Classes/ViewHelpers/IsVideoPlacedViewHelper.php in line 25.

I therefore went to see in the famous file IsVideoPlacedViewHelper.php. And this is what I find from line 24 :

foreach ($media as $key => $mediaEl) {
    if ($mediaEl->getType() >= 101 && $mediaEl->getType() <= 103 ) {
        return true;
    }
}

When I checked the log file, I find this :

2019/06/10 08:17:51 [error] 119340#119340: *4509 FastCGI sent in stderr: "PHP message: http://www.example.com/ - Core: Exception handler (WEB): Uncaught TYPO3 Exception: Call to undefined method GeorgRinger\News\Domain\Model\FileReference::getType() | Error thrown in file /var/www/www.example.com/typo3conf/ext/in_news/Classes/ViewHelpers/IsVideoPlacedViewHelper.php in line 25. Requested URL: http://www.example.com/video/" while reading response header from upstream, client: 188.40.199.147, server: in.fo, request: "GET /video/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.example.com"
Rudy Gnodde
  • 4,286
  • 2
  • 12
  • 34
MAZ
  • 222
  • 1
  • 14

1 Answers1

2

This error occurs because the IsVideoPlacedViewHelper does not support the TYPO3\CMS\Extbase\Domain\Model\FileReference class. (The news extension simply extends this domain model.) It expects a TYPO3\CMS\Core\Resource\FileReference instead which could be retrieved by $mediaEL->getOriginalResource().

So you should update your IsVideoPlacedViewHelper to take this into account:

use TYPO3\CMS\Extbase\Domain\Model\FileReference as ExtbaseFileReference;

foreach ($media as $key => $mediaElement) {
    if ($mediaElement instanceof ExtbaseFileReference) {
        $mediaElement = $mediaElement->getOriginalResource();
    }

    $type = $mediaElement->getType();

    if ($type >= 101 && $type <= 103) {
        return true;
    }
}
Mathias Brodala
  • 5,905
  • 13
  • 30
  • Thank you @Mathias Brodala ! Can you please provide me more information about how to update the `IsVideoPlacedViewHelper`? – MAZ Jun 11 '19 at 15:42
  • Thank you so much! I will test and keep an eye on the log, since the error does not always appear. – MAZ Jun 12 '19 at 14:37