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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T20449, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 18449 - CategoryPage.php miscalculates number of articles in a three-column list
CategoryPage.php miscalculates number of articles in a three-column list
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Categories (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
Blocks:
  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: ---


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

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

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):
http://www.mediawiki.org/wiki/Category:ArticleDelete_extensions 
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.

Thanks
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.


Navigation
Links