{"record":{"id":"ff758f0651d3b099","repo":"getgrav/grav","slug":"page-s-cannot-be-copied-to-itself","errorCode":null,"errorMessage":"Page /%s cannot be copied to itself","messagePattern":"Page /(.+?) cannot be copied to itself","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php","lineNumber":404,"sourceCode":"\n            /** @var Debugger $debugger */\n            $debugger = $grav['debugger'];\n            $debugger->addMessage(\"Save page: {$newKey}\", 'debug');\n\n            // Check if the row already exists.\n            $oldKey = $row['__META']['storage_key'] ?? null;\n            if (is_string($oldKey)) {\n                // Initialize all old key-related variables.\n                $oldKeys = $this->extractKeysFromRow(['__META' => $row['__META']], false);\n                $oldFolder = $this->buildFolder($oldKeys);\n                $oldFilename = $this->buildFilename($oldKeys);\n\n                // Check if folder has changed.\n                if ($oldFolder !== $newFolder && file_exists($oldFolder)) {\n                    $isCopy = $row['__META']['copy'] ?? false;\n                    if ($isCopy) {\n                        if (str_starts_with($newFolder, $oldFolder . '/')) {\n                            throw new RuntimeException(sprintf('Page /%s cannot be copied to itself', $oldKey));\n                        }\n\n                        $this->copyRow($oldKey, $newKey);\n                        $debugger->addMessage(\"Page copied: {$oldFolder} => {$newFolder}\", 'debug');\n                    } else {\n                        if (str_starts_with($newFolder, $oldFolder . '/')) {\n                            throw new RuntimeException(sprintf('Page /%s cannot be moved to itself', $oldKey));\n                        }\n\n                        $this->renameRow($oldKey, $newKey);\n                        $debugger->addMessage(\"Page moved: {$oldFolder} => {$newFolder}\", 'debug');\n                    }\n                }\n\n                // Check if filename has changed.\n                if ($oldFilename !== $newFilename) {\n                    // Get instance of the old file (we have already copied/moved it).\n                    $oldFilepath = \"{$newFolder}/{$oldFilename}\";","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php#L386-L422","documentation":"Error \"Page /%s cannot be copied to itself\" thrown in getgrav/grav.","triggerScenarios":"Thrown at system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php:404 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}