Bug Report #4682

Minion_CLI::options is flawed.

Added by Deon George about 2 years ago. Updated about 2 years ago.

Status:NewStart date:12/21/2012
Priority:NormalDue date:
Assignee:-% Done:


Target version:-
Resolution: Points:1


In my implementation using KH, my tasks call

php index.php --option=value task:name

Within my scripts, I do a call to Minion_CLI::options('option') to retrieve the value assigned to "--option".

IF I execute my script as "php index.php task:name --option=value", then Minion_CLI::options('option') CORRECTLY returns "value"

HOWEVER, if I execute my scripts as "php index.php --option=value task:name" (options first, task name second), then Minion_CLI::options('option') INCORRECTLY returns "task:name".

This is because the PHP test of in_array(0,array(0=>task:name,'option'=>'value')) returns TRUE (which I dont know why) and as a result, the code:

                if ($options)
                        foreach ($values as $opt => $value)
                                if ( ! in_array($opt, $options))
                                        // Set the given value

                return count($options) == 1 ? array_pop($values) : $values;

results in an array of (0=>"task:name","option"=>"value) being left in the $values array, and thus the first value "pop"ed is incorrect.


#1 Updated by Deon George about 2 years ago

Forgot to add, this is KH 3.3.0

#2 Updated by Deon George about 2 years ago

I known why - the in_array test should use the 3rd argument "TRUE" to check data types.

Also available in: Atom PDF