{"record":{"id":"74b837a63dbc09a7","repo":"getgrav/grav","slug":"changing-page-template-failed-oldfilepath","errorCode":null,"errorMessage":"Changing page template failed: {$oldFilepath} => {$newFilepath}","messagePattern":"Changing page template failed: (.+?) => (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php","lineNumber":433,"sourceCode":"                        $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}\";\n                    $file = $this->getFile($oldFilepath);\n\n                    // Rename the file if we aren't supposed to clone it.\n                    $isClone = $row['__META']['clone'] ?? false;\n                    if (!$isClone && $file->exists()) {\n                        /** @var UniformResourceLocator $locator */\n                        $locator = $grav['locator'];\n                        $toPath = $locator->isStream($newFilepath) ? $locator->findResource($newFilepath, true, true) : GRAV_ROOT . \"/{$newFilepath}\";\n                        $success = $file->rename($toPath);\n                        if (!$success) {\n                            throw new RuntimeException(\"Changing page template failed: {$oldFilepath} => {$newFilepath}\");\n                        }\n                        $debugger->addMessage(\"Page template changed: {$oldFilename} => {$newFilename}\", 'debug');\n                    } else {\n                        $file = null;\n                        $debugger->addMessage(\"Page template created: {$newFilename}\", 'debug');\n                    }\n                }\n            }\n\n            // Clean up the data to be saved.\n            $this->prepareRow($row);\n            unset($row['__META'], $row['__ERROR']);\n\n            if (!isset($file)) {\n                $file = $this->getFile($newFilepath);\n            }\n\n            // Compare existing file content to the new one and save the file only if content has been changed.","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php#L415-L451","documentation":"Error \"Changing page template failed: {$oldFilepath} => {$newFilepath}\" thrown in getgrav/grav.","triggerScenarios":"Thrown at system/src/Grav/Common/Flex/Types/Pages/Storage/PageStorage.php:433 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"}