getgrav/grav · error · RuntimeException
Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::init(): No
Error message
Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::init(): Not Implemented
What it means
Flex pages implement the legacy PageInterface only partially; PageLegacyTrait::init() (which initializes a page from an SplFileInfo for a .md file) is intentionally not implemented for Flex pages and throws this RuntimeException. The legacy Page lifecycle does not apply to FlexPageObject, which gets its data from Flex storage instead of a single markdown file.
Source
Thrown at system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php:61
*/
trait PageLegacyTrait
{
/** @var array|null */
private $_content_meta;
/** @var array|null */
private $_metadata;
/**
* Initializes the page instance variables based on a file
*
* @param SplFileInfo $file The file information for the .md file that the page represents
* @param string|null $extension
* @return $this
*/
public function init(SplFileInfo $file, $extension = null): never
{
// TODO:
throw new RuntimeException(__METHOD__ . '(): Not Implemented');
}
/**
* Gets and Sets the raw data
*
* @param string|null $var Raw content string
* @return string Raw content string
*/
public function raw($var = null): string
{
if (null !== $var) {
// TODO:
throw new RuntimeException(__METHOD__ . '(string): Not Implemented');
}
$storage = $this->getFlexDirectory()->getStorage();
if (method_exists($storage, 'readRaw')) {
return $storage->readRaw($this->getStorageKey());View on GitHub (pinned to 6040efed04)
Solutions
- Remove the init() call for Flex pages; they are already initialized when fetched via $book->getIndex()/getObject().
- Branch on type before using legacy APIs: if ($page instanceof FlexPageObject) { /* flex path */ } else { $page->init($file); }.
- Replace legacy file-based creation with flex storage: $directory->createObject($data, $key)->save().
- If the plugin is third-party, check for a Flex-compatible release or patch out the init() call.
Example fix
// before
$page->init($file);
// after
if ($page instanceof \Grav\Framework\Flex\Pages\FlexPageObject) {
// Flex page: already initialized from storage.
} else {
$page->init($file);
} Defensive patterns
Strategy: fallback
Validate before calling
// Only run the legacy init lifecycle on non-flex pages
if (!$page instanceof \Grav\Framework\Flex\Pages\FlexPageObject) {
$page->init($file);
} Type guard
use Grav\Framework\Flex\Pages\FlexPageObject;
function isFlexPage(\Grav\Common\Page\Interfaces\PageInterface $page): bool
{
return $page instanceof FlexPageObject;
} Prevention
- Treat Flex pages as pre-initialized: fetch via the flex directory, never init() them.
- Branch shared code on instanceof FlexPageObject before legacy lifecycle calls.
- Audit legacy Page plugins when enabling the Flex Pages architecture.
When it happens
Trigger: Plugin/theme code calling $page->init($file) on a page obtained from the Flex Pages directory; migrations that instantiate pages the legacy way while the flex-pages architecture is active; generic code that accepts PageInterface and calls init() unconditionally.
Common situations: Enabling the Flex Pages architecture while running legacy plugins built against Grav's classic Page class; scaffolding/import scripts reusing legacy page-bootstrapping code.
Related errors
- Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::raw(string
- Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::file(): No
- Failed: Cannot set page parent to self
- Failed: Cannot set page parent to a child of current page
- Not Implemented
AI-assisted analysis of getgrav/grav@6040efed04 (2026-08-17).
Data as JSON: /api/errors/e54524aebb8cf619.
Report an issue: GitHub.