Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.1.0: History tab shows all versions for all Locales #414

Closed
4 tasks done
chrispenny opened this issue May 17, 2018 · 24 comments
Closed
4 tasks done

v4.1.0: History tab shows all versions for all Locales #414

chrispenny opened this issue May 17, 2018 · 24 comments

Comments

@chrispenny
Copy link

chrispenny commented May 17, 2018

Locales

  • International
    -Default
    -No fallback
  • United States
    -Fallback International
  • Australia
    -Fallback International
  • Japan
    -No fallback

Process

Created a new Page in International

screen shot 2018-05-18 at 8 26 51 am

Localised Page in Australia with new metadata

screen shot 2018-05-18 at 8 27 13 am

Localised Page in United States with new metadata

screen shot 2018-05-18 at 8 27 51 am

Localised Page in Japan with new metadata

screen shot 2018-05-18 at 8 31 37 am

Result

Each Locale that you view the "History" tab in will show all versions for all Locales.

Each "History" tab will also have the most recent version selected - even if that versioned belongs to another Locale.

(Japan pictured below, but it's the same result in the other 3 Locales)

screen shot 2018-05-18 at 8 32 07 am


Pull requests

@robbieaverill
Copy link
Contributor

@chrispenny
Copy link
Author

Ok, fair enough.

At the moment this is quite a confusing interface though - especially considering the top version is always selected, even when it's not the current version for the Locale you're in.

An indicator + the correct version (relative to your Locale) being selected when you load the page is probably reasonable. Bonus would be the ability to allow/disallow authors from reverting to a version from another Locale.

CC: @frankmullenger

@robbieaverill
Copy link
Contributor

Yeah I agree. I think the logic in the CMS for generating the DataList of those versions is not built in a way that allows Fluent to modify it. Perhaps using the history viewer with SilverStripe 4.2 onwards might help here

@chillu
Copy link
Contributor

chillu commented May 21, 2018

@robbieaverill Can you please classify this so it doesn't get lost? Are you using the impact/* labels to go through things on bug day? Ideally this gets looked at for your next bug day

@robbieaverill
Copy link
Contributor

We need to discuss with @tractorcow when he's back, he's previously classed this as a feature

@tractorcow
Copy link
Collaborator

The long and short of it is:

  • a version number may be saved in a locale, but it doesn't belong to that locale per se; It's a little ambiguous at times, but every time you save in any locale, it does write to the base record, and that base content (e.g. the "test 3" in the above screenshot) is what's being shown to the user.
  • We could just hide content saved in other locales, but there are cases where the user may need to see "all" versions despite. I would probably want a "show only this locale" option that you can turn on. However, that may be a pain to build.
  • Filtering the history may be challenging, since you could unintentionally affect other internal API. Versioned::allVersions() does NOT let fluent extend it; It happens via extremely low level custom filters and table renames. CMSPageHistoryController itself has issues; The VersionsForm() method is extremely un-extendable. You couldn't easily do it without subclassing it and replacing it with DI.

tl;dr it's hard and may require core changes to fix.

@tractorcow
Copy link
Collaborator

Oh look, 5.0 uses Versioned::all_versions() instead, which IS extendable.

That means we can do it in 5.0 without core changes. :)

@chillu
Copy link
Contributor

chillu commented Jun 11, 2018

Is this only an issue in 4.1 which doesn't have the new GraphQL-based history viewer yet (due to be released in 4.2)? In this case, it's not worth fixing.

@tractorcow What module version are you referring to with "5.0" here?

@robbieaverill
Copy link
Contributor

It might actually be susceptible to the same problem if it's using the same Versioned API. We've already found blocking problems with not being able to paginate or filter the versions that GraphQL gives you for versioned DataObjects (silverstripe/silverstripe-versioned#147). We might need to backport the functionality in order to move forward with this kind of thing in 4.x

@tractorcow
Copy link
Collaborator

@tractorcow What module version are you referring to with "5.0" here?

Recipe 5.x.

@tractorcow
Copy link
Collaborator

It might actually be susceptible to the same problem if it's using the same Versioned API. We've already found blocking problems with not being able to paginate or filter the versions that GraphQL gives you for versioned DataObjects (silverstripe/silverstripe-versioned#147). We might need to backport the functionality in order to move forward with this kind of thing in 4.x

It seems that the limitation on that versioned API is affecting both fluent and graphql. Maybe we do need to back port it?

@tractorcow
Copy link
Collaborator

For recipe 4.2 we may be able to build a custom "lazy" list, a subclass of DataList, that returns the same Versioned_Version object. That would let us include the new functionality without breaking API / SemVer.

@robbieaverill
Copy link
Contributor

Let's treat this as a bug I think

@robbieaverill
Copy link
Contributor

robbieaverill commented Sep 20, 2018

So I've re-read this issue again after a few months, and basically the problem is that Versioned::allVersions() doesn't return a DataList, so Fluent can't modify the underlying queries.

SS5 has had a (breaking) rewrite and does return a DataList (silverstripe/silverstripe-versioned#81). I think the fix here is to backport that change in a non-breaking way then use that from SilverStripe\Versioned\GraphQL\Operations\ReadVersions::resolve().

This would be only to allow Fluent to adjust the query for history viewer. From here we'd need to make sure that the returned list through Fluent is sensible.

PR at silverstripe/silverstripe-versioned#182 to backport the versioned DataList changes from 5.x to 4.x. I don't think I can justify suggesting it's a patch change unfortunately.

@robbieaverill
Copy link
Contributor

robbieaverill commented Sep 20, 2018

Yep so with that change in place we still get all versions in all locales. We may need to do as @tractorcow suggested an add a filter to history viewer for "Only show versions from this locale" or something like that. I'm looking into how we'd filter this list too - as @tractorcow also mentioned, it doesn't look like the locales actually own the versions

@chrispenny
Copy link
Author

chrispenny commented Sep 24, 2018

Hi team (@robbieaverill),

I'm not sure if this is entirely related or not. Please let me know and I'll open up a separate issue if need be.

Archive view shows the latest version (not Locale specific)

I have 2 Locales (neither fallback to anything):

  • International
  • Japan

I publish my Page in both Locales (International first, Japan second).

I then "Unpublish and archive" the Page in both Locales (International first, Japan second).

Result

When you view the record, you get (I assume) a view of the most recent version (not Locale specific). Using "Restore draft" will also restore the non-Locale specific version that you are viewing.

screen shot 2018-09-25 at 7 31 46 am

@robbieaverill robbieaverill self-assigned this Sep 25, 2018
@robbieaverill
Copy link
Contributor

@chrispenny I think it would be easier to track that issue separately - I've moved it to #471

@robbieaverill
Copy link
Contributor

Weeee this is going to be tricky. It looks like Versioned adds an inner join to the versions table in order to get version information, but FluentVersionedExtension isn't rewriting that join.

What Fluent is doing at the moment is replacing SiteTree_Localised to SiteTree_Localised_Versions, which is fine, but when the table is SiteTree_Versions it's not being replaced with SiteTree_Localised_Versions.

I quickly tried making this replacement, but many of the columns required are in the base _Versions table, so we get errors like "WasDeleted" column not existing.

I think we need to put an inner join on any SiteTree_Versions tables to SiteTree_Localised_Versions, and fallback for any columns that don't exist to the SiteTree_Versions table. This is pretty tricky because the original inner join that we need to modify is added by Versioned as raw SQL, e.g. in Versioned::augmentSQLVersionedLatest:

https://github.com/silverstripe/silverstripe-versioned/blob/1/src/Versioned.php#L672-L689

Perhaps one option is to replace this with a SQLSelect implementation, which Fluent might automatically be able to rewrite

@robbieaverill
Copy link
Contributor

Perhaps one option is to replace this with a SQLSelect implementation, which Fluent might automatically be able to rewrite

It doesn't look like our DB layer allows this to happen. I think this might be a "can't fix" issue...

@tractorcow any suggestions?

@robbieaverill
Copy link
Contributor

Hmm, the SQL query has a SourceLocale field added by FluentExtension::augmentSQL - if we can filter that by the current locale then it might work

@robbieaverill
Copy link
Contributor

robbieaverill commented Sep 25, 2018

Alright so I've made some PRs that should hopefully resolve this by adding a filter to the DataList that the GraphQL resolver for version lists now returns (see the issue description for the PRs).

This now filters the versions in the history viewer by the correct locale that created them.

Version numbers don't start from 1 - they're incremented from the latest global version number, so the third or fourth locale you publish a page in will get version 8 and 9 for example.

image

@robbieaverill robbieaverill removed their assignment Sep 25, 2018
@chillu
Copy link
Contributor

chillu commented Oct 4, 2018

Apart from a fix for descending versions (silverstripe/silverstripe-cms#2244) where the tests are still running, this has been merged.

@robbieaverill
Copy link
Contributor

All merged 🎉

@chrispenny
Copy link
Author

Massive! Awesome effort. Thanks, Robbie (and everyone)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants