-
Notifications
You must be signed in to change notification settings - Fork 822
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
NEW: Allow different search filters on TreeDropdownField #10735
NEW: Allow different search filters on TreeDropdownField #10735
Conversation
Thank you, this is great! Could you please write a test for this to avoid us breaking it in the future? It also seems like a good candidate for some documentation - other developers might not intuitively think to try this config setting in combination with indexes if they experience a similar problem. |
Nice! I'd probably name the config just |
Yeah was just thinking about tests, will see how best to do that |
3e4b27f
to
72f5f6d
Compare
I'm having a hard time running tests for Silverstripe 5, could either of you share a docker-compose.yml file I could use? Last error I got was My composer.json: {
"name": "silverstripe/installer",
"type": "silverstripe-recipe",
"description": "The SilverStripe Framework Installer",
"require": {
"php": "^7.4 || ^8.0",
"silverstripe/framework": "dev-feature/change-search-filter-treedropdownfield as 5.x-dev",
"silverstripe/assets" : "2.x-dev"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"repositories": [
{
"name": "silverstripe/framework",
"type": "vcs",
"url": "git@github.com:elliot-sawyer/silverstripe-framework.git"
}
],
"extra": {
"resources-dir": "_resources",
"project-files-installed": [
"app/.htaccess",
"app/_config.php",
"app/_config/mimevalidator.yml",
"app/_config/mysite.yml",
"app/src/Page.php",
"app/src/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"web.config"
]
},
"config": {
"process-timeout": 600,
"allow-plugins": {
"composer/installers": true,
"silverstripe/recipe-plugin": true,
"silverstripe/vendor-plugin": true
}
},
"prefer-stable": true,
"minimum-stability": "dev"
} |
That might just be a result of us not merging 5.0 up to 5 yet - try rebasing off 5.0 (for testing purposes - keep this pr targeting 5 for now) and setting your assets dependency to 2.0.x-dev |
72f5f6d
to
489e49a
Compare
I got it running somehow but still incredibly hard to write tests for the TreeDropdownField. Couldn't say specifically what I did, but it's something like this:
Now stuck with the following error:
That error is a bit strange, since table_name is defined on that object |
|
You may find it easiest to just do a new |
489e49a
to
40da2a5
Compare
@GuySartorelli @michalkleiner I have added a test. It counts TestObject records from the fixture before applying the filter, and after |
40da2a5
to
280354d
Compare
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.
One small change to make.
Also I've written up some documentation for this change - can you both please review it to make sure I understood this correctly?
silverstripe/developer-docs#208
Co-authored-by: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
@elliot-sawyer @michalkleiner can one or both of you please take a looks at my docs PR as per #10735 (review)? I just want to make sure I've understood these changes correctly before I click merge. |
Apologies, I had thumbs-up'ed it to indicate approval. I fixed the test too |
…searchfilters DOC Document the changes in silverstripe/silverstripe-framework#10735
This pull request comes about when encountering performance issues on the
tree
method when searching on a large dataset.I have a site with >20K SiteTree records. The client love the Insert Link feature on the WYSIWYG, and starts enthusiastically searching for Titles containing "tra". The offending link can be reproduced after logging into the CMS and visiting
admin/Modals/editorInternalLink/field/PageID/tree?search=tra&flatList=1&format=json
. Unfortunately, this kicks off some really inefficient queries to the backend, exacerbated by the following issues:To address this, I propose replacing the hardcoded PartialMatch filter with a configuration variable, to allow developers to modify the search behaviour. In my case, I added
indexes
on SiteTree for MenuTitle and Title. After changing the filter to StartsWith the query responds in ~6s vs the 30+ (usually an execution_limit error) it was taking previously, albeit at the expense of fewer results.