Last modified: 2009-04-16 16:31:54 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 18449 - CategoryPage.php miscalculates number of articles in a three-column list
CategoryPage.php miscalculates number of articles in a three-column list
Product: MediaWiki
Classification: Unclassified
Categories (Other open bugs)
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
  Show dependency treegraph
Reported: 2009-04-13 19:25 UTC by Rocco
Modified: 2009-04-16 16:31 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---

Screenshot (14.25 KB, image/png)
2009-04-13 19:25 UTC, Rocco

Description Rocco 2009-04-13 19:25:29 UTC
Created attachment 6022 [details]

I noticed that the Category Page miscalculates the number of articles when creating a three-column list. Here is an example (By the time I got it there were 9 pages in this category): 
Attached is also a screenshot.
I noticed that this only happens when then number of articles divided by 3 has no remainder - like 9, 12, 27 and etc. I guess when we have 9 articles we expect to have 3 in each column. Instead in the example you can see that we have 3 in column 1, 4 in column 2 and 2 in column 3. 
When number of articles divided by 3 return a remainder the columns appears to be created proportionally.
I looked in to the code and will suggest the following code change:
Page - includes/CategoryPage.php, line 374: 

// loop through the chunks
for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0;
    $chunkIndex < 3;
    $chunkIndex++, $startChunk = $endChunk, $endChunk += $chunk + 1)

to be changed to (the last line only is different)
// loop through the chunks
for($startChunk = 0, $endChunk = $chunk, $chunkIndex = 0;
    $chunkIndex < 3;
    $chunkIndex++, $startChunk = $endChunk, $endChunk += count($articles) % 3 == 0 ? $chunk : $chunk + 1)

I've did some testing and the patch appears to be working. Not sure however if this code change can have other implications.

Rado Tsanev
Comment 1 Alexandre Emsenhuber [IAlex] 2009-04-16 16:31:54 UTC
fixed in r49561.

Note You need to log in before you can comment on or make changes to this bug.