Skip to content

Commit 006faf1

Browse files
authored
PageInfo: fix zero-division check (x-tools#609)
A division by zero happened today at https://xtools.wmcloud.org/pageinfo/pl.wikipedia.org/Mi%C4%99dzynarodowy%20Bank%20Inwestycyjny/2025-07-12/2025-07-12. it's a weird request to make (pageinfo for exactly two edits including one revdeleted and the rollback), but whatever. We were ensuring that the wrong thing was non-0.
1 parent 86fb642 commit 006faf1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Model/PageInfo.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,10 @@ private function getTopTenByAdded(): array {
10071007
return [
10081008
'label' => $editor,
10091009
'value' => $added,
1010-
'percentage' => $this->addedBytes === 0 ? 0 : 100 * ( $added / $topTenTotalAdded ),
1010+
'percentage' =>
1011+
$topTenTotalAdded === 0 ?
1012+
0 :
1013+
100 * ( $added / $topTenTotalAdded ),
10111014
];
10121015
}, $topTenEditorsByAdded );
10131016
}

0 commit comments

Comments
 (0)