Page MenuHomePhabricator

SecurePoll: allow STV elections to be tallied from the cli
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

I have not been able to tally STV elections via the CLI (using the tally.php script).

It might be a good idea to get this working now in case there are any problems when trying to tally elections after 17th August. T277222 should hopefully deal with these problems, but just in case.

So far, I have tried:

  1. php extensions/SecurePoll/cli/tally.php --name <name of election>
    • Produces no output except Script finished in 0 s
  2. php extensions/SecurePoll/cli/tally.php <name of dump>.securepoll (after downloading the dump from Special:SecurePoll)
    • Produces no output except Script finished in 0 s
  3. php extensions/SecurePoll/cli/tally.php --html=foo.html <name of dump>.securepoll
    • Error:
PHP Fatal error:  OOUI\Exception: OOUI\Theme::singleton was called with no singleton theme set. in /var/www/html/w/vendor/oojs/oojs-ui/php/Theme.php:31
Stack trace:
#0 /var/www/html/w/vendor/oojs/oojs-ui/php/Element.php(260): OOUI\Theme::singleton()
#1 /var/www/html/w/vendor/oojs/oojs-ui/php/Tag.php(494): OOUI\Element->toString()
#2 /var/www/html/w/extensions/SecurePoll/includes/Talliers/ElectionTallier.php(175): OOUI\Tag->__toString()
#3 /var/www/html/w/extensions/SecurePoll/cli/tally.php(61): MediaWiki\Extensions\SecurePoll\Talliers\ElectionTallier->getHtmlResult()
#4 /var/www/html/w/maintenance/doMaintenance.php(108): TallyElection->execute()
#5 /var/www/html/w/extensions/SecurePoll/cli/tally.php(74): require_once('/var/www/html/w...')
#6 {main} in /var/www/html/w/vendor/oojs/oojs-ui/php/Tag.php on line 496
Environment

Wiki(s): local docker SecurePoll 3.0.0 (fba66dd) 13:13, 2 August 2021

Event Timeline

STran added subscribers: Niharika, STran.

Do we need to come up with a unique text-based output for this? CLI defaults to getTextResult (which doesn't work for STV atm) and it looks like the html output might need some extra work to make it work. For more complex type (HistogramRangeTallier as an example), we've piped out the html before:

	public function getTextResult() {
		return $this->getHtmlResult();
	}

Not sure if anyone else needs to be pinged on this? @Niharika maybe? For now I'll pipe the html result in line w/what we've done elsewhere and if the ask is updated to have a unique text output I can revisit.

Change 709584 had a related patch set uploaded (by STran; author: STran):

[mediawiki/extensions/SecurePoll@master] Implement STVTallier->getTextResult()

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

Asked Joe and he said as long as it output displayable HTML it would be fine. I'm going to move this to code review where we can judge the weird OOUI set up I had to do. Feel free to update if there's a change to the ask (say if you wanted actual text and not html as text)

Change 709584 merged by jenkins-bot:

[mediawiki/extensions/SecurePoll@master] Implement STVTallier->getTextResult()

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

dom_walden added a subscriber: jrbs.

I have been able to tally elections from the CLI on beta, including encrypted elections with 1000 votes and (small) encrypted STV elections.

The output does not have all the styling as the respective Special:SecurePoll/tally/$id page. For example, it does not bold elected candidates nor does it grey out candidates who were elected in previous rounds. @STran maybe there is a way of including the CSS stylesheets after the admin has copy-pasted the output?

For example, compare:

tally_page.png (356×922 px, 94 KB)

With:

tally_dump.png (319×1 px, 99 KB)

I have tested:

  • mwscript extensions/SecurePoll/cli/tally.php --wiki votewiki <location of dump>.securepoll
  • mwscript extensions/SecurePoll/cli/tally.php --wiki votewiki --name <name of election> (if the election is unencrypted or if the decrypt key is already in the database)

and copy-pasted the output to a text file.

@jrbs when this is on production (on Wednesday I think) it would be great if you could test it out, especially on (encrypted) STV elections and other large encrypted elections.

@jrbs when this is on production (on Wednesday I think) it would be great if you could test it out, especially on (encrypted) STV elections and other large encrypted elections.

Thanks Dom, I'll be around to try that out.