Problem/Motivation
method_exists() did not throw exceptions on unexpected values.
TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given in method_exists() (line 123 of /web/modules/contrib/simple_sitemap/src/Plugin/simple_sitemap/UrlGenerator/CustomUrlGenerator.php)
Steps to reproduce
add custom link :/ admin/config/search/simplesitemap/custom
Generate sitemap
Proposed resolution
replace in CustomUrlGenerator.php line 123
'lastmod' =>method_exists($entity, 'getChangedTime') ?
date('c', $entity->getChangedTime()) : NULL,
by
'lastmod' =>($entity !== NULL && method_exists($entity, 'getChangedTime')) ?
date('c', $entity->getChangedTime()) : NULL,
Comments
Comment #2
gbyteThere appears to be a change in PHP 8 where method_exists accepts only an object or string. Drupal is yet to be compatible with PHP 8 so demoting this to task status.
Comment #4
gbyteThanks, pushed to dev.
Comment #5
pierrelbzThanks !