Merge pull request #51 from creative-commoners/pulls/2.0/Content-with-Contents

FIX allow allchanges to handle removed Page types
This commit is contained in:
Dylan Wagstaff 2018-02-14 10:10:20 +13:00 committed by GitHub
commit 7b3d282802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -39,7 +39,7 @@ abstract class ContentFilter
/**
* Gets the cache to use
*
* @return Zend_Cache_Frontend
* @return CacheInterface
*/
protected function getCache()
{

View File

@ -12,6 +12,7 @@ use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\Parsers\Diff;
use SilverStripe\CMS\Model\SiteTree;
class VersionFeed extends SiteTreeExtension
{
@ -114,7 +115,16 @@ class VersionFeed extends SiteTreeExtension
}
// Copy the link so it can be cached.
$version->GeneratedLink = $version->AbsoluteLink();
$oldPage = $version->getField('object');
if (!$oldPage instanceof SiteTree) {
// We only need enough info to generate the link...
$oldPage = SiteTree::create([
'ID' => $oldPage->ID,
'URLSegment' => $oldPage->URLSegment,
'ParentID' => $oldPage->ParentID
]);
}
$version->GeneratedLink = $oldPage->AbsoluteLink();
}
// Omit the versions that haven't been visibly changed (only takes the above fields into consideration).

View File

@ -77,7 +77,7 @@ class VersionFeedController extends Extension
// Cache the diffs to remove DOS possibility.
$target = $this->owner;
$key = implode('_', array('changes', $this->owner->ID, $this->owner->Version));
$key = implode('_', array('changes', $target->ID, $target->Version));
$entries = $this->filterContent($key, function () use ($target) {
return $target->getDiffList(null, Config::inst()->get(VersionFeed::class, 'changes_limit'));
});