mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
BUGFIX: Ensure that DataObject::get_one() cache knows which subsite you're on (from r93096)
This commit is contained in:
parent
e91ba528b6
commit
29dda5abdf
@ -102,5 +102,14 @@ class FileSubsites extends DataObjectDecorator {
|
||||
return $access;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a piece of text to keep DataObject cache keys appropriately specific
|
||||
*/
|
||||
function cacheKeyComponent() {
|
||||
return 'subsite-'.Subsite::currentSubsiteID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,4 +38,11 @@ class SiteConfigSubsites extends DataObjectDecorator {
|
||||
$this->owner->SubsiteID = Subsite::currentSubsiteID();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a piece of text to keep DataObject cache keys appropriately specific
|
||||
*/
|
||||
function cacheKeyComponent() {
|
||||
return 'subsite-'.Subsite::currentSubsiteID();
|
||||
}
|
||||
}
|
||||
|
@ -364,6 +364,13 @@ class SiteTreeSubsites extends SiteTreeDecorator {
|
||||
|
||||
$this->owner->CrossSubsiteLinkTracking()->setByIDList($linkedPages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a piece of text to keep DataObject cache keys appropriately specific
|
||||
*/
|
||||
function cacheKeyComponent() {
|
||||
return 'subsite-'.Subsite::currentSubsiteID();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -217,4 +217,31 @@ class SubsiteTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoPagesWithSameURLOnDifferentSubsites() {
|
||||
// Set up a couple of pages with the same URL on different subsites
|
||||
$s1 = $this->objFromFixture('Subsite','domaintest1');
|
||||
$s2 = $this->objFromFixture('Subsite','domaintest2');
|
||||
|
||||
$p1 = new SiteTree();
|
||||
$p1->Title = $p1->URLSegment = "test-page";
|
||||
$p1->SubsiteID = $s1->ID;
|
||||
$p1->write();
|
||||
|
||||
$p2 = new SiteTree();
|
||||
$p2->Title = $p1->URLSegment = "test-page";
|
||||
$p2->SubsiteID = $s2->ID;
|
||||
$p2->write();
|
||||
|
||||
// Check that the URLs weren't modified in our set-up
|
||||
$this->assertEquals($p1->URLSegment, 'test-page');
|
||||
$this->assertEquals($p2->URLSegment, 'test-page');
|
||||
|
||||
// Check that if we switch between the different subsites, we receive the correct pages
|
||||
Subsite::changeSubsite($s1);
|
||||
$this->assertEquals($p1->ID, SiteTree::get_by_url('test-page')->ID);
|
||||
|
||||
Subsite::changeSubsite($s2);
|
||||
$this->assertEquals($p2->ID, SiteTree::get_by_url('test-page')->ID);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user