PagesVersions::restorePageVersion() method

Restore a page version to be the live version

Note that the restored page is saved to the database, replacing the current live version. So consider whether you should backup the live version (by using addPageVersion) before restoring a version to it.

Example

// restore version 2 to live page
$page = $pages->get(1234);
$pagesVersions->restore($page, 2); // restore version 2

// this does the same as the above
$pageV2 = $pagesVersions->getPageVersion($page, 2);
$pagesVersions->restore($pageV2);

Usage

// basic usage
$page = $pagesVersions->restorePageVersion(Page $page);

// usage with all arguments
$page = $pagesVersions->restorePageVersion(Page $page, int $version = 0, array $options = []);

Arguments

NameType(s)Description
pagePage

Page to restore version to or a page that was loaded as a version.

version (optional)int

Version number to restore. Can be omitted if given $page is already a version.

options (optional)array
  • names (array): Names of fields/properties to restore or omit for all (default=[])
  • useTempVersion (bool): Create a temporary version and restore from that? (default=auto-detect). This is necessary for some Fieldtypes like nested repeaters. Use of it is auto-detected so it is not necessary to specify this when using the public API.

Return value

Page bool

Returns restored version page on success or false on fail

Exceptions

Method can throw exceptions on error:

  • WireException


$pagesVersions methods and properties

API reference based on ProcessWire core version 3.0.244

Latest news

  • ProcessWire Weekly #558
    In the 558th issue of ProcessWire Weekly we'll check out the blog post that introduces ProcessWire 3.0.244, share some recent ProcessWire highlights, and more. Read on!
    Weekly.pw / 18 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH