Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Versioned.php Problem


Go to End


656 Views

Avatar
tazzydemon

Community Member, 135 Posts

25 October 2012 at 9:42am

In my post yesterday entitled "Subsite Module SS3 "All Pages, Including Deleted" Broken" I hinted at a Versioned.php issue

I believe the augment sql code at line 242 to be in error. It does not even work when used in mysql directly as there appears to be a join missing.

The sql should be thus

	if($dataQuery->getQueryParam('Versioned.mode') == 'latest_versions') {
				$query->addWhere(
					"\"{$alias}_versions\".\"Version\" IN 
					(SELECT LatestVersion FROM 
						(SELECT 
							\"{$alias}_versions\".\"RecordID\", 
							MAX(\"{$alias}_versions\".\"Version\") AS LatestVersion
							FROM \"{$alias}_versions\"
							GROUP BY \"{$alias}_versions\".\"RecordID\"
						) AS \"{$alias}_versions_latest\" JOIN \"{$alias}_versions\"
						WHERE \"{$alias}_versions_latest\".\"RecordID\" = \"{$alias}_versions\".\"RecordID\"
					)");
			}

Note the join in the next to last line. I have not refined this further and there are still probable subsite issues. Feel free to test this by deleted all the pages in a site and then try viewing "All pages, including deleted" with and without this join.

I was unable to post this as an issue on github as it is not enabled for me.