Created
July 15, 2014 02:15
-
-
Save ss23/e82475d95db2558cc332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function test() { | |
$page1 = new SiteTree(); | |
$page1->ID = mt_rand(); | |
$page1->ParentID = 0; | |
$page1->write(); | |
$page1->publish("Stage", "Live"); | |
$page2 = new SiteTree(); | |
$page2->ID = mt_rand(); | |
$page2->ParentID = $page1->ID; | |
$page2->write(); | |
$page2->publish("Stage", "Live"); | |
$page3 = new SiteTree(); | |
$page3->ID = mt_rand(); | |
$page3->ParentID = $page2->ID; | |
$page3->write(); | |
$page3->publish("Stage", "Live"); | |
// Current Heirachechy | |
// Page 1 -> Page 2 -> Page 3 | |
// Now lets re-arrange the state of staging to cause the loop | |
$page3->ParentID = $page1->ID; | |
$page3->write(); | |
// Note that we write page3 before page2, otherwise we would cause a 'normal' infinite loop | |
$page2->ParentID = $page3->ID; | |
$page2->write(); | |
// New Heirachy (of staging) | |
// Page1 -> Page 3 -> Page 2 | |
Versioned::set_reading_mode('Live'); | |
echo "While in Live mode: \r\n"; | |
echo "Page 3 parent: " . $page3->ParentID . "\r\n"; | |
echo "Page 2 parent: " . $page2->ParentID . " \r\n"; | |
Versioned::set_reading_mode('Stage'); | |
echo "While in Stage mode: \r\n"; | |
echo "Page 3 parent: " . $page3->ParentID . "\r\n"; | |
echo "Page 2 parent: " . $page2->ParentID . " \r\n"; |
Versioned::reading_stage("Live"); not Versioned::set_reading_mode('Live');
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While in Live mode:
Page 3 parent: 676509572
Page 2 parent: 2043093416
While in Stage mode:
Page 3 parent: 676509572
Page 2 parent: 2043093416