Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sitemap] DocumentTypeFilter ignores Hardlinks #6053

Open
MosiiAUT opened this issue Mar 17, 2020 · 2 comments
Open

[Sitemap] DocumentTypeFilter ignores Hardlinks #6053

MosiiAUT opened this issue Mar 17, 2020 · 2 comments
Assignees
Labels
Bug

Comments

@MosiiAUT
Copy link
Contributor

@MosiiAUT MosiiAUT commented Mar 17, 2020

Bug Report

Expected behavior

DocumentTypeFilter should check if element is of type page/link/hardlink

Actual behavior

DocumentTypeFilter ignores hardlinks because it is of the type 'Pimcore\Model\Document\Hardlink\Wrapper\Page' and returns 'page' instead of 'hardlink' on the function $element->getType()

https://github.com/pimcore/pimcore/blob/master/lib/Sitemap/Document/Filter/DocumentTypeFilter.php

@brusch brusch added the Bug label Mar 24, 2020
@brusch

This comment has been minimized.

Copy link
Member

@brusch brusch commented Mar 24, 2020

Hardlinks should be ignored in the sitemap anyway, right? Because they send a canonical header to the source anyway, see:

$response->headers->set('Link', '<' . $canonical . '>; rel="canonical"', false);

@MosiiAUT

This comment has been minimized.

Copy link
Contributor Author

@MosiiAUT MosiiAUT commented Mar 24, 2020

Yes, I modified the "canBeAdded"- function in the DocumentTypesFilter.php so it ignores every hardlink. The "handlesChildren"- function could stay as it is

    public function canBeAdded(AbstractElement $element, GeneratorContextInterface $context): bool
    {
        if (!$element instanceof Document || $element instanceof Hardlink\Wrapper\Page) {
            return false;
        }

        return in_array($element->getType(), $this->documentTypes);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.