hofff / contao-social-tags

GNU Lesser General Public License v3.0
2 stars 5 forks source link

Fix type error #8

Closed fritzmg closed 4 years ago

fritzmg commented 4 years ago

On a customer's installation, the teaser can be null for some reason, resulting in the following error:

ErrorException: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to Hofff\Contao\SocialTags\Data\Extractor\NewsExtractor::replaceInsertTags() must be of the type string, null given, called in …/htdocs/vendor/hofff/contao-social-tags/src/Data/Extractor/NewsExtractor.php on line 246 in …/htdocs/vendor/hofff/contao-social-tags/src/Data/Extractor/NewsExtractor.php:198
Stack trace:
#0 …/htdocs/vendor/hofff/contao-social-tags/src/Data/Extractor/NewsExtractor.php(246): Hofff\Contao\SocialTags\Data\Extractor\NewsExtractor->replaceInsertTags(NULL, false)
#1 …/htdocs/vendor/hofff/contao-social-tags/src/Data/Extractor/NewsExtractor.php(171): Hofff\Contao\SocialTags\Data\Extractor\NewsExtractor->getNewsDescription(Object(NewsCategories\NewsModel))
#2 …/htdocs/vendor/hofff/contao-social-tags/src/Data/Extractor/NewsExtractor.php(67): Hofff\Contao\SocialTags\Data\Extractor\News
#1 vendor/hofff/contao-social-tags/src/Data/Extractor/NewsExtractor.php(198): handleFatalError
#0 vendor/sentry/sentry/lib/Raven/ErrorHandler.php(0): null

This PR also checks if there is actual content in the teaser.