From 06b9d0af420604c30546916ba7082fbb52edfd7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 16 May 2016 20:12:12 +0200 Subject: [PATCH] CoreParserFunctions: Return 0 from {{PAGESIZE:}} when length is unknown Revision::getSize() might return null when the revision.rev_len field is null. That should never happen normally (the field should get backfilled as part of the update process), but we've also had a bug where rev_len was not being recorded for empty pages (see T135414 for details). It's saner to return a number here rather than empty string, and 0 should actually be correct for all pages affected by that issue. Bug: T20998 Change-Id: Ie12f0be24f00aaf8b90b25c4921a97df3b789369 --- includes/parser/CoreParserFunctions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 3b8b513dfd..d49c4e414d 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -774,6 +774,10 @@ class CoreParserFunctions { // fetch revision from cache/database and return the value $rev = self::getCachedRevisionObject( $parser, $title ); $length = $rev ? $rev->getSize() : 0; + if ( $length === null ) { + // We've had bugs where rev_len was not being recorded for empty pages, see T135414 + $length = 0; + } return self::formatRaw( $length, $raw ); } -- 2.20.1