wilr / silverstripe-googlesitemaps

Google Sitemaps module for the SilverStripe CMS
BSD 3-Clause "New" or "Revised" License
74 stars 95 forks source link

PHP 7 - dates need casting to integers #146

Closed kinglozzer closed 6 years ago

kinglozzer commented 6 years ago

https://github.com/wilr/silverstripe-googlesitemaps/blob/c3fcd84542801331cd29f5705a2b4c15ef688721/src/Extensions/GoogleSitemapExtension.php#L128

This will raise warnings in PHP 7.1 as IntlDateFormatter::format() returns a string. Just needs (int)


Edit: now I’m doubting myself http://php.net/manual/en/migration71.other-changes.php. I don’t think this actually should raise a warning, unless format() is returning an empty string, or a string like '12345a': https://3v4l.org/KXW64


Edit 2: this was originally discussed on Slack with @guyvanbael - $created->format('U') was failing to return a numeric value for some reason. I can’t spot any reason why that would happen, but perhaps we should just code defensively here anyway