RefreshLinksJob: Check hastext before comparing HTML

Why:
- When comparing the newly generated HTML to the cached HTML, there
  might be cases when the new ParserOutput doesn't contain HTML.

What:
- If hasText() returns false, don't compare HTML and use the "unknown"
  value for the html_changed stats label.

Bug: T388406
Change-Id: Ibc3e79e79a6421d4780739104a949bac50a5b01f
(cherry picked from commit a275e02771bc2ed4243804d5294188f54e47f9fc)
This commit is contained in:
daniel 2025-06-24 16:58:09 +02:00 committed by Daniel Kinzler
parent 4b5e96928a
commit 7f1fa6f51f

View file

@ -458,8 +458,9 @@ class RefreshLinksJob extends Job {
// Collect stats on parses that don't actually change the page content.
// In that case, we could abort here, and perhaps we could also avoid
// triggering CDN purges (T369898).
if ( !$cachedOutput ) {
// There was no cached output
if ( !$cachedOutput || !$output->hasText() ) {
// There was no cached output, or no HTML was generated because
// shouldGenerateHTMLOnEdit returned false.
$htmlChanged = 'unknown';
} elseif ( $cachedOutput->getRawText() === $output->getRawText() ) {
// We have cached output, but we couldn't be sure that it was still good.