CoreParserFunctions: Return 0 from {{PAGESIZE:}} when length is unknown
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 16 May 2016 18:12:12 +0000 (20:12 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Sun, 22 May 2016 18:39:11 +0000 (18:39 +0000)
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

index 3b8b513..d49c4e4 100644 (file)
@@ -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 );
        }