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

FIX Do not cache current site config #165

Closed

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Jun 10, 2024

Issue silverstripe/.github#272

When running behat on siteconfig from a recipe-kitchen-sink context only, the following behat tests will fail

  • vendor/silverstripe/siteconfig/tests/behat/features/manage-page-permissions.feature:87
  • vendor/silverstripe/siteconfig/tests/behat/features/manage-page-permissions.feature:95

The fail because $this->CanEditType in SiteConfig::canEditPages() will incorrectly by 'LoggedInUsers' instead of 'OnlyTheseUsers' - not this is NOT run-over from another behat tests, it happens when the tests are run individually

Beucase SiteConfig::current_site_config() is used at some point, and it will use a cached version of SiteConfig::get_one(), which is getting set at some point in recipe-kitchen-sink (I wasn't able to work out exactly where) which it normally isn't during installer.

I've had a look to see if SiteConfig::current_site_config() is being used in loops anywhere and it isn't, so the performance loss on not using the cache should be basically irrelevant

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

I don't like this change at all. Siteconfig is used all over the place in projects which is why it uses a singleton in the first place.

Have you tried putting a breakpoint somewhere like __set() or setField() to see when CanEditType gets set?
You can make the breakpoint conditional, e.g.

if ($fieldName === 'CanEditType') {
    echo ''; // has no effect but you can put a breakpoint here
}

@emteknetnz
Copy link
Member Author

Replaced by silverstripe/silverstripe-cms#2959

@emteknetnz emteknetnz closed this Jun 10, 2024
@GuySartorelli GuySartorelli deleted the pulls/5.2/no-cache branch June 10, 2024 22:31
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.

2 participants