Weissheiten/Weissheiten.Neos.News

Sort operation must accept empty context

Closed this issue · 1 comments

The https://github.com/Weissheiten/Weissheiten.Neos.News/blob/master/Classes/Weissheiten/Neos/News/TypoScript/Eel/FlowQueryOperations/SortOperation.php

Must accept an empty context in canEvaluate as you cannot know if the operations before deliver an empty result set.

Something like this:

    /**
     * {@inheritdoc}
     *
     * @param array (or array-like object) $context onto which this operation should be applied
     * @return boolean TRUE if the operation can be applied onto the $context, FALSE otherwise
     */
    public function canEvaluate($context)
    {
        if (count($context) === 0) {
            return true;
        }

        foreach ($context as $contextNode) {
            if (!$contextNode instanceof NodeInterface) {
                return false;
            }
        }
        return true;
    }

fixed with commit 2b1a415