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

PageMatch: Return fetched content in match_data #10143

Merged
merged 3 commits into from Dec 28, 2020
Merged

PageMatch: Return fetched content in match_data #10143

merged 3 commits into from Dec 28, 2020

Conversation

samford
Copy link
Member

@samford samford commented Dec 25, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?
  • Have you successfully run brew man locally and committed any changes?

This is a follow-up to #10113, which made modifications to PageMatch to support working with cached content, as a way of being able to modify the Xorg strategy to use PageMatch internally (like other strategies). With those changes, PageMatch properly works with page content that's passed to #find_versions.

However, the issue is that Xorg isn't actually able to cache page content in the current state because PageMatch isn't passing fetched content back to it in its return hash (match_data). Before #10113, I had been deleting the :content from match_data (as it wasn't necessary to keep it in the hash) and I simply forgot to modify that line when modifying PageMatch#find_versions to support cached content.

In general, this PR makes the following changes:

  • Modify PageMatch#find_versions to return fetched page content in the match_data hash (i.e., not actively deleting it like we have been doing).
  • Modify the condition where we check for provided_content in PageMatch#find_versions to ensure that provided_content is a string before using it.
  • Set match_data[:cached] = true when PageMatch#find_versions is using provided_content. In this case, Cached?: Yes is printed in the debug output and ["meta"]["cached"] is set to true in 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.

If we want caching to work in the `Xorg` strategy, it's necessary to
pass fetched content back in the `match_data` hash.
@BrewTestBot
Copy link
Member

Review period will end on 2020-12-28 at 03:22:57 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 25, 2020
@samford samford added the critical Critical change which should be shipped as soon as possible. label Dec 25, 2020
@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 25, 2020
@BrewTestBot
Copy link
Member

BrewTestBot commented Dec 25, 2020

Review period ended.

@MikeMcQuaid
Copy link
Member

Thanks @samford!

@MikeMcQuaid MikeMcQuaid merged commit 55054a1 into Homebrew:master Dec 28, 2020
@samford samford deleted the pagematch-fix-caching branch December 31, 2020 15:50
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Jan 31, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Jan 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants