SectionProfiler: Do not attempt to use null values as arrays
authorMáté Szabó <mszabo@wikia-inc.com>
Mon, 16 Sep 2019 19:30:47 +0000 (21:30 +0200)
committerMáté Szabó <mszabo@wikia-inc.com>
Mon, 16 Sep 2019 19:30:47 +0000 (21:30 +0200)
commit278227608808c25242c87a7092da5fb9adc50cde
tree5632a060d55d4a962954947ac823a329935a950a
parent6ebfe8578c8a14913df2426583a68b2a0803e6d2
SectionProfiler: Do not attempt to use null values as arrays

When SectionProfiler::getFunctionStats() is called, the 'start'
and 'end' member variables may be null if no code called the
scopedProfileIn()/scopedProfileOut() methods on this profiler instance.
This can occur, for instance, when generating the parser limit report
for wikitext that did not include expensive parser functions.

In PHP 7.4, attemping to use a null value as an array generates
a PHP Notice.[1] This patch adds a check to SectionProfiler::getFunctionStats
to verify that the 'start' value is an array before attempting to
access its keys.

---
[1] https://github.com/php/php-src/blob/php-7.4.0RC1/UPGRADING#L25

Bug: T233012
Change-Id: I2d35bfddfcc4c194aa71265e40387f2f2914e3a5
includes/profiler/SectionProfiler.php