Skip to content

isSitemapIndex() should not be run without fetch() #13

@philipnorton42

Description

@philipnorton42

This is the code to get a sitemap index check:

$sitemapSource = new SitemapXmlSource($client);

$sitemapData = $sitemapSource->fetch($sitemap);

if ($sitemapSource->isSitemapIndex()) {
    echo 'This is an index file';
}

It is possible to run isSitemapIndex() without first running fetch, at which point the check would return false (the default value). We therefore either need to throw an exception or implicitly run fetch(). As running code implicitly is a little suspect and the sitemap data returned still needs to be parsed, it might be better to throw an exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions