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

Filter plugin #6082

Merged
merged 1 commit into from
Nov 17, 2015
Merged

Filter plugin #6082

merged 1 commit into from
Nov 17, 2015

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Nov 16, 2015

Note: I've left this unsquashed for now just to help it make sense, will squash later.

Following on from #6080, moving the filter behaviour into a plugin gives us a sensible location to keep all related code (rather than having a bunch of utils). Although there is still much room for improvement in terms of putting together a standard way of wiring i.e. access rules gets called on forge, this gets called explicitly inside of findPage.

In addition to moving the existing logic into a plugin, this PR adds a bunch of new logic around the concept of 'enforced', 'default' and 'custom' filters.

All of this is explained in detail here.

One key addition since that comment - I'm also reducing the custom filters against the enforced filters, in much the same way as default filters are reduced against custom filters... what this means is.

  • A default filter is removed if a filter for the same property appears in the custom filters, because it has been overridden. E.g. if page:false is the default, but the custom filter specifies page:true the default is no longer needed.
  • A custom filter is removed if a filter for the same property appears in the enforced filters, because custom filters cannot override the enforced filters. E.g. if status:published is enforced, and the custom filter specifies status:draft, the custom filter is removed as it is not permitted.

In time, it may be better to throw an error in this case.


Filter plugin with enforce/default logic

refs #5614, #5943

  • adds a new 'filter' bookshelf plugin which extends the model
  • the filter plugin provides handling for merging/combining various filters (enforced, defaults and custom/user-provided)
  • the filter plugin also handles the calls to gql
  • post processing is also moved to the plugin, to be further refactored/removed in future
  • adds tests showing how filter could be abused prior to this commit

...

Remove old style defaults

refs #5614, #5943

  • remove the old way of supplying defaults to the browse query

...

Add some debugging tools to filters

I have added these lines back in so many times in the past month or so so that I could
figure out what was happening, I figured everyone else might find them useful.

@ErisDS
Copy link
Member Author

ErisDS commented Nov 17, 2015

Moved debugging commit elsewhere for now & squashed the other two

refs TryGhost#5614, TryGhost#5943

- adds a new 'filter' bookshelf plugin which extends the model
- the filter plugin provides handling for merging/combining various filters (enforced, defaults and custom/user-provided)
- the filter plugin also handles the calls to gql
- post processing is also moved to the plugin, to be further refactored/removed in future
- adds tests showing how filter could be abused prior to this commit
sebgie added a commit that referenced this pull request Nov 17, 2015
@sebgie sebgie merged commit c53d31a into TryGhost:master Nov 17, 2015
@ErisDS ErisDS deleted the filter-plugin branch November 17, 2015 22:00
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