Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error #110

Closed
lordlouckster opened this issue Nov 16, 2022 · 7 comments · Fixed by #111
Closed

PHP Fatal error #110

lordlouckster opened this issue Nov 16, 2022 · 7 comments · Fixed by #111
Assignees
Labels

Comments

@lordlouckster
Copy link

Q A
Type Bug
Condorcet version 4.2.0
PHP version 8.1.12
Installation Method Composer

I keep getting a fatal error whenever I run an election with the program:

PHP Fatal error: Uncaught TypeError: CondorcetPHP\Condorcet\Console\Commands\ElectionCommand::parseFromVotesArguments(): Argument #1 ($callBack) must be of type Closure, null given, called in C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\src\Console\Commands\ElectionCommand.php on line 358 and defined in C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\src\Console\Commands\ElectionCommand.php:716
Stack trace:
#0 C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\src\Console\Commands\ElectionCommand.php(358): CondorcetPHP\Condorcet\Console\Commands\ElectionCommand->parseFromVotesArguments()
#1 C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\src\Console\Commands\ElectionCommand.php(367): CondorcetPHP\Condorcet\Console\Commands\ElectionCommand->importInputsData()
#2 C:\Users\Admin\Documents\Condorcet\vendor\symfony\console\Command\Command.php(308): CondorcetPHP\Condorcet\Console\Commands\ElectionCommand->execute()
#3 C:\Users\Admin\Documents\Condorcet\vendor\symfony\console\Application.php(1014): Symfony\Component\Console\Command\Command->run()
#4 C:\Users\Admin\Documents\Condorcet\vendor\symfony\console\Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#5 C:\Users\Admin\Documents\Condorcet\vendor\symfony\console\Application.php(171): Symfony\Component\Console\Application->doRun()
#6 C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\src\Console\CondorcetApplication.php(29): Symfony\Component\Console\Application->run()
#7 C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\bin\condorcet.php(32): CondorcetPHP\Condorcet\Console\CondorcetApplication::run()
#8 C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\bin\condorcet(3): require('...')
#9 C:\Users\Admin\Documents\Condorcet\vendor\bin\condorcet(120): include('...')
#10 {main}
thrown in C:\Users\Admin\Documents\Condorcet\vendor\julien-boudry\condorcet\src\Console\Commands\ElectionCommand.php on line 716

I've tried different PHP versions with no luck, and the first Condorcet version where this error occurs is 3.3.0.

@julien-boudry
Copy link
Owner

julien-boudry commented Nov 16, 2022

Hi @anonymous7002,

Thanks for the report. After a first look, I don't reproduce the error, but I see something in the code that is a bit perilous and should be improved.

Can you provide the exact command arguments leading to this error? It's will help with reproduction and writing unit tests.

@julien-boudry
Copy link
Owner

julien-boudry commented Nov 16, 2022

Do you try to compute a huge election without PDO/Sqlite extension installed? And using the -w (or --votes) argument?

@lordlouckster
Copy link
Author

For clarification, I reproduced this issue in the command line program on two different Windows 10 64-bit PCs, and one Ubuntu WSL, by running this command:
condorcet election -c "A;B;C" -w "A>B;A>C;C>B" -r
I also reproduced it with different condorcet.phar files, and that's how I found out the earliest version with this bug was 3.3.0.

@julien-boudry
Copy link
Owner

Can you activate PDO + SQLite extension in your php.ini file (or package with Ubuntu) and try again ?
Or try with the docker image (it's including SQLite).

I have probably the perfect fix in a draft PR, but I want to be sure (and maybe do more refactoring).

julien-boudry added a commit that referenced this issue Nov 17, 2022
Fix #110 - Console Crash if file cache is deactivate (or Sqlite is not available)
@lordlouckster
Copy link
Author

I activated PDO + SQLite, and now it's working.

@julien-boudry
Copy link
Owner

Perfect. You will not need it (Sqlite) anymore in the next version (probably later this day).

@julien-boudry
Copy link
Owner

Version 4.2.1 published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants