tractorcow-farm / silverstripe-fluent

Multi-language translate module for Silverstripe, without having to manage separate site trees.
BSD 3-Clause "New" or "Revised" License
91 stars 109 forks source link

Middleware is causing extra queries #828

Closed lekoala closed 5 months ago

lekoala commented 5 months ago

Module version(s) affected

7.0.0

Description

Here is a debugbar screenshot

image

We see that we have two SHOW FULL FIELDS. One from the Domain class (even if you have a single domain and not using domain mode) and one for the Locale table (due to the databaseIsReady check).

In many cases, this should not be made PER REQUEST. It could be useful to avoid errors in case the database is not available, but it should not lead to extra queries being applied for every request.

Unused features should not cause extra queries either.

How to reproduce

Install the module Install the debugbar Check that indeed we have these queries

Possible Solution

Additional Context

No response

Validations

tractorcow commented 5 months ago

You could update the check for CacheableModel::databaseIsReady() to only run during dev/build, and return "true" hard coded otherwise. That's the only time it needs to know about the build status.

tractorcow commented 5 months ago

Fix at https://github.com/tractorcow-farm/silverstripe-fluent/pull/831

lekoala commented 5 months ago

even better :-)

tractorcow commented 5 months ago

There was a regression in my fix but those have been resolved now. 6 and 7 branches have the updated fix in them merged up.

lekoala commented 5 months ago

great thank you!

tractorcow commented 5 months ago

Sorry I didn't merge up into 7.0.0 branch, didn't make it into RC release, but it's not an urgent fix :)