Repository navigation
fix: find the first slice of an article with a single query - #6790
Merged
Merged
Conversation
`getFirstSliceForArticle()` queried the content sections 1 to 20 one by one, so it needed up to 20 queries and missed slices in sections above 20. It now relies on the ordering by content section and priority instead. Both `getFirstSliceForArticle()` and `getFirstSliceForContentSection()` required `priority = 1`, so with `$ignoreOfflines` they returned no slice (or skipped the whole section) if the first slice was offline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ArticleSlice::getFirstSliceForArticle()queried the content sections 1 to 20 one by one — up to 20 queries per call, and slices in content sections above 20 were never found. It now uses a single query and relies on the existingORDER BY content_section_id, priority LIMIT 1(covered by thefind_slicesindex).While at it,
$ignoreOfflinesis fixed in bothgetFirstSliceForArticle()andgetFirstSliceForContentSection(): they filtered bypriority = 1 AND status = 1, so an offline first slice made them returnnull(or skip the whole content section) even if online slices followed.getNextSlice()already handled this correctly.The docblock of
getFirstSliceForArticle()no longer claims thatgetNextSlice()iterates over all slices of the article — it stays within the content section.The new tests fail on the old implementation.