getgrav/grav · error · RuntimeException

Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::raw(string

Error message

Grav\Framework\Flex\Pages\Traits\PageLegacyTrait::raw(string): Not Implemented

What it means

PageLegacyTrait::raw() supports reading the raw page content (it falls back to storage->readRaw() or re-encodes via MarkdownFormatter), but setting raw content — raw($var) with a non-null argument — is not implemented for Flex pages and throws this RuntimeException. Flex pages are edited through object properties and save(), not by writing the whole raw file at once.

Source

Thrown at system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php:74

     * @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());
        }

        $array = $this->prepareStorage();
        $formatter = new MarkdownFormatter();

        return $formatter->encode($array);
    }

    /**
     * Gets and Sets the page frontmatter
     *
     * @param string|null $var
     * @return string

View on GitHub (pinned to 6040efed04)

Solutions

  1. Write content through the property API: $page->setContent('# New content'); $page->save(); (or $page->setProperty('content', ...)).
  2. For full-file imports, create/update the object: $directory->createObject(['content' => $raw, ...], $key)->save().
  3. Branch on instanceof FlexPageObject in code that must serve both page types.

Example fix

// before
$page->raw("# Updated\n\nBody text");

// after
$page->setContent("# Updated\n\nBody text");
$page->save();
Defensive patterns

Strategy: fallback

Type guard

function isFlexPage(\Grav\Common\Page\Interfaces\PageInterface $page): bool
{
    return $page instanceof \Grav\Framework\Flex\Pages\FlexPageObject;
}

Prevention

When it happens

Trigger: Calling $page->raw('# New content') on a FlexPageObject (legacy sync/import code); CLI scripts that push external markdown into pages via raw(); admin plugins using raw() to overwrite page bodies.

Common situations: Porting legacy import pipelines to a site running the Flex Pages architecture; third-party plugins that update page content through raw() instead of the content property.

Related errors


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