getgrav/grav · error · RuntimeException

Cannot reorder a page which has no parent

Error message

Cannot reorder a page which has no parent

What it means

Error "Cannot reorder a page which has no parent" thrown in getgrav/grav.

Source

Thrown at system/src/Grav/Common/Flex/Types/Pages/PageObject.php:419

    }

    /**
     * @param array $ordering
     * @return PageCollection|null
     * @phpstan-return ObjectCollection<string,PageObject>|null
     */
    protected function reorderSiblings(array $ordering)
    {
        $storageKey = $this->getMasterKey();
        $isMoved = $this->isMoved();
        $order = !$isMoved ? $this->order() : false;
        if ($order !== false) {
            $order = (int)$order;
        }

        $parent = $this->parent();
        if (!$parent) {
            throw new RuntimeException('Cannot reorder a page which has no parent');
        }

        /** @var PageCollection $siblings */
        $siblings = $parent->children();
        $siblings = $siblings->getCollection()->withOrdered();

        // Handle special case where ordering isn't given.
        if ($ordering === []) {
            if ($order >= 999999) {
                // Set ordering to point to be the last item, ignoring the object itself.
                $order = 0;
                foreach ($siblings as $sibling) {
                    if ($sibling->getKey() !== $this->getKey()) {
                        $order = max($order, (int)$sibling->order());
                    }
                }
                $this->order($order + 1);
            }

View on GitHub (pinned to 6040efed04)

When it happens

Trigger: Thrown at system/src/Grav/Common/Flex/Types/Pages/PageObject.php:419 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17). Data as JSON: /api/errors/7447adab15bd55b7. Report an issue: GitHub.