PageMatch: Return fetched content in match_data#10143
Merged
MikeMcQuaid merged 3 commits intoHomebrew:masterfrom Dec 28, 2020
samford:pagematch-fix-caching
Merged
PageMatch: Return fetched content in match_data#10143MikeMcQuaid merged 3 commits intoHomebrew:masterfrom samford:pagematch-fix-caching
MikeMcQuaid merged 3 commits intoHomebrew:masterfrom
samford:pagematch-fix-caching
Conversation
If we want caching to work in the `Xorg` strategy, it's necessary to pass fetched content back in the `match_data` hash.
Contributor
|
Review period will end on 2020-12-28 at 03:22:57 UTC. |
Contributor
|
Review period ended. |
BrewTestBot
approved these changes
Dec 25, 2020
MikeMcQuaid
approved these changes
Dec 28, 2020
Member
|
Thanks @samford! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
brew stylewith your changes locally?brew typecheckwith your changes locally?brew testswith your changes locally?brew manlocally and committed any changes?This is a follow-up to #10113, which made modifications to
PageMatchto support working with cached content, as a way of being able to modify theXorgstrategy to usePageMatchinternally (like other strategies). With those changes,PageMatchproperly works with page content that's passed to#find_versions.However, the issue is that
Xorgisn't actually able to cache page content in the current state becausePageMatchisn't passing fetched content back to it in its return hash (match_data). Before #10113, I had been deleting the:contentfrommatch_data(as it wasn't necessary to keep it in the hash) and I simply forgot to modify that line when modifyingPageMatch#find_versionsto support cached content.In general, this PR makes the following changes:
PageMatch#find_versionsto return fetched page content in thematch_datahash (i.e., not actively deleting it like we have been doing).provided_contentinPageMatch#find_versionsto ensure thatprovided_contentis a string before using it.match_data[:cached] = truewhenPageMatch#find_versionsis usingprovided_content. In this case,Cached?: Yesis printed in the debug output and["meta"]["cached"]is set totruein the verbose JSON output. I missed this issue before because it's sometimes hard to tell when caching is actually working, so it's a good idea to surface this information.Though I know it's the holidays, I'm labeling this "critical" so this fix can be integrated if anyone happens to review it over the next few days.