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

Track whether filtering was applied #263

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Feb 26, 2024

Fix for #258

This PR introduces a CategoryFilteringNotAppliedException in the NewsCriteriaBuilder::setRegularListCriteria method which will allow you to return false if desired in a newsListFetchItems or newsListCountItems hook. For backwards compatibility NewsCriteriaBuilder::getCriteriaForListModule will not throw this exception by default.

@fritzmg
Copy link
Contributor Author

fritzmg commented Feb 26, 2024

CI failures are unrelated to the PR.

@aschempp
Copy link
Collaborator

Can't we just return true/false if filtering was applied in the respective methods?

@fritzmg
Copy link
Contributor Author

fritzmg commented Feb 27, 2024

You mean NewsCriteriaBuilder::getCriteriaForListModule should return NewsCriteria|null|false? That would be a BC break.

@aschempp
Copy link
Collaborator

I don't really understand the problem to be honest. What would be the difference between false and null?

@fritzmg
Copy link
Contributor Author

fritzmg commented Feb 27, 2024

  • null means: no news articles are found (i.e. show the "empty" message in the new list module)
  • false means: this hook should be skipped

@fritzmg
Copy link
Contributor Author

fritzmg commented May 2, 2024

/reminder @qzminski @aschempp

1 similar comment
@fritzmg
Copy link
Contributor Author

fritzmg commented Sep 18, 2024

/reminder @qzminski @aschempp

@qzminski
Copy link
Member

Looks good to me. @aschempp if you don't have any objections we can merge it.

@qzminski qzminski merged commit b0c24ca into codefog:main Oct 2, 2024
1 check failed
@qzminski
Copy link
Member

qzminski commented Oct 2, 2024

Sorry for the delay. Released as 4.0.8 :)

qzminski added a commit that referenced this pull request Oct 4, 2024
@qzminski
Copy link
Member

qzminski commented Oct 4, 2024

I have reverted this pull request changes due to #272.

@fritzmg did you test this pull request?

For example, this line https://github.com/codefog/contao-news_categories/pull/263/files#diff-d540d7da12a707b7694cc9f3135ee02a80f7a211c40b9a1fd90767dfb2a8a06aR56
returns false but the method return type does not allow that.

Similar to this line https://github.com/codefog/contao-news_categories/pull/263/files#diff-d540d7da12a707b7694cc9f3135ee02a80f7a211c40b9a1fd90767dfb2a8a06aR39 where false is returned, but the method type defines the int as the return type.

@fritzmg
Copy link
Contributor Author

fritzmg commented Oct 4, 2024

True, the return type of the hooks are wrong. These hooks expect Collection|null|false and int|false as the return value.

fritzmg added a commit to fritzmg/contao-news_categories that referenced this pull request Oct 4, 2024
@fritzmg
Copy link
Contributor Author

fritzmg commented Oct 4, 2024

See #273

@fritzmg fritzmg deleted the track-filtering-applied-4x branch October 4, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants