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

DOC Add upgrade guide for tractorcow/silverstripe-fluent #175

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Mar 7, 2023

Description from parent issue (since it's private):

Acceptance criteria

  • The Guide should explain how to upgrade from Fluent v4 to Fluent v6/v7.
  • The Guide should explain how to upgrade from Fluent v5 to Fluent v6/v7.

Notes

  • If you are on Fluent v4, we are not sure if the best course of action is to skip 5 and go straight to 6. The person who picks up this card should spend some time analysing what the best approach is on in this case and draft the guide accordingly.

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() and FluentExtension::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 and 5.0. On merge-up to 5.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

@GuySartorelli
Copy link
Member Author

@mfendeksilverstripe can you please give this a once-over and let me know if I've missed anything or got anything wrong?
CC also @chrispenny and @tractorcow


| | **Fluent 4** | **Fluent 5** | **Fluent 6** |
|--------------|--------------|--------------|--------------|
| Fluent state | Local | Global | Global |

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).

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link

@chrispenny chrispenny Mar 7, 2023

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.

Copy link
Member Author

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this section.

Copy link
Contributor

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.

Copy link
Contributor

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 :)

Copy link
Contributor

@tractorcow tractorcow Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@tractorcow tractorcow Mar 8, 2023

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. :)

en/03_Upgrading/07_Upgrading_Fluent.md Outdated Show resolved Hide resolved
Copy link
Contributor

@mfendeksilverstripe mfendeksilverstripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice guide 👍


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member Author

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".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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".

Copy link
Member Author

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@GuySartorelli GuySartorelli force-pushed the pulls/4.12/fluent-upgrade-guide branch from a4944e2 to 6189e52 Compare March 8, 2023 04:42
@emteknetnz emteknetnz merged commit 2b328a6 into silverstripe:4.12 Mar 8, 2023
@emteknetnz emteknetnz deleted the pulls/4.12/fluent-upgrade-guide branch March 8, 2023 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants