getgrav/grav · error · RuntimeException

Page /%s cannot be copied to itself

Error message

Page /%s cannot be copied to itself

What it means

Error "Page /%s cannot be copied to itself" thrown in getgrav/grav.

Source

Thrown at system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php:404

            /** @var Debugger $debugger */
            $debugger = $grav['debugger'];
            $debugger->addMessage("Save page: {$newKey}", 'debug');

            // Check if the row already exists.
            $oldKey = $row['__META']['storage_key'] ?? null;
            if (is_string($oldKey)) {
                // Initialize all old key-related variables.
                $oldKeys = $this->extractKeysFromRow(['__META' => $row['__META']], false);
                $oldFolder = $this->buildFolder($oldKeys);
                $oldFilename = $this->buildFilename($oldKeys);

                // Check if folder has changed.
                if ($oldFolder !== $newFolder && file_exists($oldFolder)) {
                    $isCopy = $row['__META']['copy'] ?? false;
                    if ($isCopy) {
                        if (str_starts_with($newFolder, $oldFolder . '/')) {
                            throw new RuntimeException(sprintf('Page /%s cannot be copied to itself', $oldKey));
                        }

                        $this->copyRow($oldKey, $newKey);
                        $debugger->addMessage("Page copied: {$oldFolder} => {$newFolder}", 'debug');
                    } else {
                        if (str_starts_with($newFolder, $oldFolder . '/')) {
                            throw new RuntimeException(sprintf('Page /%s cannot be moved to itself', $oldKey));
                        }

                        $this->renameRow($oldKey, $newKey);
                        $debugger->addMessage("Page moved: {$oldFolder} => {$newFolder}", 'debug');
                    }
                }

                // Check if filename has changed.
                if ($oldFilename !== $newFilename) {
                    // Get instance of the old file (we have already copied/moved it).
                    $oldFilepath = "{$newFolder}/{$oldFilename}";

View on GitHub (pinned to 6040efed04)

When it happens

Trigger: Thrown at system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php:404 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/ff758f0651d3b099. Report an issue: GitHub.