pecotamic / sitemap

Sitemap for Statamic v3
6 stars 9 forks source link

Got error isAbsoluteUrl() must be of the type string, #11

Closed koyanyaroo closed 3 years ago

koyanyaroo commented 3 years ago

Hi,

Thanks for your amazing addons, I really loved that.

Lately I got an issue while try to accessing the /sitemap.xml

Argument 1 passed to Pecotamic\Sitemap\Models\Sitemap::isAbsoluteUrl() must be of the type string, null given, called in

here's some details about my environment PHP Version: 7.4.20 Statamic version: 3.1.25 pecotamic/sitemap version: 1.2.3

without any custom configuration or view

but after I change on vendor/pecotamic/sitemap/src/Models/Sitemap.php

 protected static function isAbsoluteUrl(string $url): bool
    {
        return preg_match('#^https?://#', $url);
    }

become

 protected static function isAbsoluteUrl(?string $url): bool
    {
        return preg_match('#^https?://#', $url);
    }

the error disappear.

just wondering if the tweak are save or wont making any other breakage under the hood?

Thank you

werner-freytag commented 3 years ago

Thanks for your submission!

This is a good workaround, however it is better to validate the value before calling isAbsoluteUrl instead of allowing the function to be called with an incorrect argument.

I'm going to release an update fixing this issue.

werner-freytag commented 3 years ago

Fixed in 1.2.4