Page MenuHomePhabricator

SecurePoll: Tally page display issues when numbers are above 1000
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

If an election has numbers over 1000, it can lead to incorrect output in the tally page like: "1": 2,000 - 1 = 1,666.666668 (keep factor: 0.833333)

It also leads to errors in the logs like:

2021-08-26 12:48:55 [YSeNt-rwfjiz1jlhHBIJCAAAABQ] deployment-mediawiki11 votewiki 1.37.0-alpha error ERROR: [YSeNt-rwfjiz1jlhHBIJCAAAABQ] /wiki/Special:SecurePoll/tally/1954   PHP Notice: A non well formed numeric value encountered {"exception_url":"/wiki/Special:SecurePoll/tally/1954","reqId":"YSeNt-rwfjiz1jlhHBIJCAAAABQ","caught_by":"mwe_handler"} 
[Exception ErrorException] (/srv/mediawiki/php-master/extensions/SecurePoll/includes/Talliers/STVTallier.php:294) PHP Notice: A non well formed numeric value encountered
  #0 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Talliers/STVTallier.php(294): MWExceptionHandler::handleError(integer, string, string, integer, array)
  #1 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Talliers/ElectionTallier.php(185): MediaWiki\Extensions\SecurePoll\Talliers\STVTallier->getHtmlResult()
  #2 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Pages/TallyPage.php(208): MediaWiki\Extensions\SecurePoll\Talliers\ElectionTallier->getHtmlResult()
  #3 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Pages/TallyPage.php(92): MediaWiki\Extensions\SecurePoll\Pages\TallyPage->showTallyResult()
  #4 /srv/mediawiki/php-master/extensions/SecurePoll/includes/SpecialSecurePoll.php(70): MediaWiki\Extensions\SecurePoll\Pages\TallyPage->execute(array)
  #5 /srv/mediawiki/php-master/includes/specialpage/SpecialPage.php(646): MediaWiki\Extensions\SecurePoll\SpecialSecurePoll->execute(string)
  #6 /srv/mediawiki/php-master/includes/specialpage/SpecialPageFactory.php(1366): SpecialPage->run(string)
  #7 /srv/mediawiki/php-master/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
  #8 /srv/mediawiki/php-master/includes/MediaWiki.php(925): MediaWiki->performRequest()
  #9 /srv/mediawiki/php-master/includes/MediaWiki.php(559): MediaWiki->main()
  #10 /srv/mediawiki/php-master/index.php(53): MediaWiki->run()
  #11 /srv/mediawiki/php-master/index.php(46): wfIndexMain()
  #12 /srv/mediawiki/w/index.php(3): require(string)
  #13 {main}
2021-08-26 12:48:55 [YSeNt-rwfjiz1jlhHBIJCAAAABQ] deployment-mediawiki11 votewiki 1.37.0-alpha error ERROR: [YSeNt-rwfjiz1jlhHBIJCAAAABQ] /wiki/Special:SecurePoll/tally/1954   PHP Notice: A non well formed numeric value encountered {"exception_url":"/wiki/Special:SecurePoll/tally/1954","reqId":"YSeNt-rwfjiz1jlhHBIJCAAAABQ","caught_by":"mwe_handler"} 
[Exception ErrorException] (/srv/mediawiki/php-master/extensions/SecurePoll/includes/Talliers/STVTallier.php:317) PHP Notice: A non well formed numeric value encountered
  #0 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Talliers/STVTallier.php(317): MWExceptionHandler::handleError(integer, string, string, integer, array)
  #1 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Talliers/ElectionTallier.php(185): MediaWiki\Extensions\SecurePoll\Talliers\STVTallier->getHtmlResult()
  #2 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Pages/TallyPage.php(208): MediaWiki\Extensions\SecurePoll\Talliers\ElectionTallier->getHtmlResult()
  #3 /srv/mediawiki/php-master/extensions/SecurePoll/includes/Pages/TallyPage.php(92): MediaWiki\Extensions\SecurePoll\Pages\TallyPage->showTallyResult()
  #4 /srv/mediawiki/php-master/extensions/SecurePoll/includes/SpecialSecurePoll.php(70): MediaWiki\Extensions\SecurePoll\Pages\TallyPage->execute(array)
  #5 /srv/mediawiki/php-master/includes/specialpage/SpecialPage.php(646): MediaWiki\Extensions\SecurePoll\SpecialSecurePoll->execute(string)
  #6 /srv/mediawiki/php-master/includes/specialpage/SpecialPageFactory.php(1366): SpecialPage->run(string)
  #7 /srv/mediawiki/php-master/includes/MediaWiki.php(314): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, RequestContext)
  #8 /srv/mediawiki/php-master/includes/MediaWiki.php(925): MediaWiki->performRequest()
  #9 /srv/mediawiki/php-master/includes/MediaWiki.php(559): MediaWiki->main()
  #10 /srv/mediawiki/php-master/index.php(53): MediaWiki->run()
  #11 /srv/mediawiki/php-master/index.php(46): wfIndexMain()
  #12 /srv/mediawiki/w/index.php(3): require(string)
  #13 {main}

And also:

2021-08-26 12:48:56 [YSeNt-rwfjiz1jlhHBIJCAAAABQ] deployment-mediawiki11 votewiki 1.37.0-alpha formatnum WARNING: Language::formatNum with non-numeric string {"number":"1,666.666668"}
2021-08-26 12:48:56 [YSeNt-rwfjiz1jlhHBIJCAAAABQ] deployment-mediawiki11 votewiki 1.37.0-alpha formatnum WARNING: Language::formatNum with non-numeric string {"number":"1,555.555557"} 
2021-08-26 12:48:56 [YSeNt-rwfjiz1jlhHBIJCAAAABQ] deployment-mediawiki11 votewiki 1.37.0-alpha formatnum WARNING: Language::formatNum with non-numeric string {"number":"1,185.185187"}

Found while testing T288740.

Steps to reproduce problem

blt file to reproduce errors above.

Examples on beta:

Environment

Wiki(s): SecurePoll 3.0.0 (1c3236a) 06:20, 30 August 2021

Event Timeline

Congratulations on creating your 290,000th task.

This does not affect the way results appear when they are written to the database or dump file.

Here is an example of how it looks when you extract the results from the dump file and pretty print them: https://www.mediawiki.org/wiki/Anti-Harassment_Tools/SecurePoll_Improvements/Test_Results/5_2_5000_956342267/dump

This does not affect the way results appear when they are written to the database or dump file.

Here is an example of how it looks when you extract the results from the dump file and pretty print them: https://www.mediawiki.org/wiki/Anti-Harassment_Tools/SecurePoll_Improvements/Test_Results/5_2_5000_956342267/dump

@dom_walden does this happen when the result is written to the database and the Tally page reads it from the database? Ref T289186

Change 715799 had a related patch set uploaded (by TsepoThoabala; author: TsepoThoabala):

[mediawiki/extensions/SecurePoll@master] Tally page display issues when numbers are above 1000

https://gerrit.wikimedia.org/r/715799

This does not affect the way results appear when they are written to the database or dump file.

Here is an example of how it looks when you extract the results from the dump file and pretty print them: https://www.mediawiki.org/wiki/Anti-Harassment_Tools/SecurePoll_Improvements/Test_Results/5_2_5000_956342267/dump

@dom_walden does this happen when the result is written to the database and the Tally page reads it from the database? Ref T289186

Yes, the bug still happens in this case.

Change 715799 merged by jenkins-bot:

[mediawiki/extensions/SecurePoll@master] Fix display issues when numbers are above 1000 or small

https://gerrit.wikimedia.org/r/715799

I rechecked all the examples in the description, all the stackoverflow moderator elections on beta and the Irish general election locally, concentrating on the numbers over 1000.

I saw no display issues and the calculations that I checked appeared correct (when I did the arithmetic in my head).

I also saw no errors in the beta logs.

The numbers I tested with were between 1000 and 10000, including votes per candidate, votes transferred and quota. Maybe we will get numbers bigger than that one day, but probably not for some time.

Test environment: https://vote.wikimedia.beta.wmflabs.org SecurePoll 3.0.0 (cdd701e) 06:21, 6 September 2021.

Change 719166 had a related patch set uploaded (by Tim Starling; author: TsepoThoabala):

[mediawiki/extensions/SecurePoll@wmf/1.37.0-wmf.21] Fix display issues when numbers are above 1000 or small

https://gerrit.wikimedia.org/r/719166

Change 719166 merged by jenkins-bot:

[mediawiki/extensions/SecurePoll@wmf/1.37.0-wmf.21] Fix display issues when numbers are above 1000 or small

https://gerrit.wikimedia.org/r/719166

Mentioned in SAL (#wikimedia-operations) [2021-09-06T23:52:02Z] <tstarling@deploy1002> Synchronized php-1.37.0-wmf.21/extensions/SecurePoll/includes/Talliers/STVTallier.php: T290000 (duration: 00m 58s)