-
Notifications
You must be signed in to change notification settings - Fork 67
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
DOC Add upgrade guide for tractorcow/silverstripe-fluent #175
DOC Add upgrade guide for tractorcow/silverstripe-fluent #175
Conversation
@mfendeksilverstripe can you please give this a once-over and let me know if I've missed anything or got anything wrong? |
|
||
| | **Fluent 4** | **Fluent 5** | **Fluent 6** | | ||
|--------------|--------------|--------------|--------------| | ||
| Fluent state | Local | Global | Global | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just like to double check: Was it version 5 where it switched to Global
? I remembered it being version 6 (but I could certainly be wrong).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was 5
as Fluent 6
was mostly focused on versioned history stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took this from a guide Mojmir created originally, but I decided to run the code examples to validate the results.
In fluent 6.x-dev with global state locale "en_US", with no explicit fallbacks defined and default config:
$result = FluentState::singleton()->withState(function (FluentState $state) {
$state->setLocale('en_NZ');
return [
'titles' => Page::get()->column('Title'),
'list' => Page::get(),
];
});
var_dump([
$result['titles'], // includes titles from the en_NZ locale
$result['list']->column('Title'), // includes titles from the en_NZ locale
Page::get()->column('Title') // includes titles from the en_US locale
]);
Did I do something wrong there? I would have expected only the top result to use en_NZ
and the bottom two to use en_US
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting... Yes, I think I would expect the bottom two to use en_US
if we're saying that there is no more local state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfendeksilverstripe do you have any insight here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$result['list']->column('Title'), // includes titles from the en_NZ locale
The query state was set to Fluent.locale = en_NZ
when the query was created (i.e. inside the callback). This state persists after the callback is returned. Read queries are always sticky to the locale when they were created, not when they are executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting... Yes, I think I would expect the bottom two to use en_US if we're saying that there is no more local state.
This should apply to fluent 7 on silverstripe 5; I'll leave this to you to figure out as I'm not using ss 5 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI write queries are NOT sticky, and are always in the global locale, and always have been. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice guide 👍
9b2f59f
to
a4944e2
Compare
|
||
Silverstripe only commercially supports version 4.x of [tractorcow/silverstripe-fluent](https://github.com/tractorcow-farm/silverstripe-fluent) with the 4.x major release line of Silverstripe CMS - however, the fluent module also has versions 5.x and 6.x which are compatible with Silverstripe CMS 4.x. | ||
|
||
This documents some of the breaking and functional changes across these three major release lines of the fluent module, as well as some some key things to look out for and general guidelines on how to adapt your code to be compatible with the latest version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documents some of the breaking and functional changes across these three major release lines of the fluent module, as well as some some key things to look out for and general guidelines on how to adapt your code to be compatible with the latest version. | |
This documents some of the breaking and functional changes across these three major release lines of the fluent module, as well as some key things to look out for and general guidelines on how to adapt your code to be compatible with the latest version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
### Enhanced CMS UI | ||
|
||
Fluent 5 introduced some new configurable UI actions, including a new `Localisation` tab in the edit form for localised models where you see and manage the localisation status of each record. The `Localisation` tab is referred in documentation as the "localisation manager". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fluent 5 introduced some new configurable UI actions, including a new `Localisation` tab in the edit form for localised models where you see and manage the localisation status of each record. The `Localisation` tab is referred in documentation as the "localisation manager". | |
Fluent 5 introduced some new configurable UI actions, including a new `Localisation` tab in the edit form for localised models where you see and manage the localisation status of each record. The `Localisation` tab is referred to in documentation as the "localisation manager". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| Default value | `true` | `true` | `true` | `true` | | ||
| Functionality | Enable localise actions for records which are not available in the current locale (copy to draft, copy & publish and Localise actions) | Enable "Localisation" actions in the edit form. More about this below. | Enable "copy from locale" action in the localisation manager | Enable "copy to locale" action in the localisation manager | | ||
|
||
As mentioned in the table above, the `batch_actions_enabled` configuration value controls whether a new "Localisation" action group appears in the edit form. This is not to be confused with "batch actions" menu in the site tree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the table above, the `batch_actions_enabled` configuration value controls whether a new "Localisation" action group appears in the edit form. This is not to be confused with "batch actions" menu in the site tree. | |
As mentioned in the table above, the `batch_actions_enabled` configuration value controls whether a new "Localisation" action group appears in the edit form. This is not to be confused with the "batch actions" menu in the site tree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
a4944e2
to
6189e52
Compare
Description from parent issue (since it's private):
I've opted to make a single upgrade guide that doesn't make assumptions about what version you're upgrading from nor to - though it does state the idea is to adapt your code to be compatible with the latest version.
This means we don't have to duplicate instructions or advice for scenarios where v4 and v5 behave the same way, and both need the same actions taken to upgrade to v6.
There is only one additional consideration for upgrading to v7, which I'll cover in a PR for the CMS 5 changelog. The change is just that
FluentExtension::getLinkingMode()
andFluentExtension::LocaleLink()
are removed in v7. The upgrade guide already notes that they're deprecated and what to use instead, so I think it's fine to not mention v7 here.I'm explicitly avoiding mention of v7 as that's a CMS 5 consideration, and this upgrade guide is for CMS 4.
After merging
After merging this PR, immediately merge it up to
4
and5.0
. On merge-up to5.0
, delete it, as it isn't applicable for CMS 5 projects (this is the same treatment given to the graphql v3->v4 and phpunit 5=>9 upgrade guides)Parent issue