Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.0

Bug #9583 Console Args isDefined not working correctly
Submitted: 2006-12-08 15:54 UTC
From: erudd at netfor dot com Assigned: mansion
Status: Closed Package: Console_Getargs (version 1.3.4)
PHP Version: 5.1.6 OS: Fedora Core 6 x86_64
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 49 + 35 = ?

 
 [2006-12-08 15:54 UTC] erudd at netfor dot com (Edward Rudd)
Description: ------------ The fix for bug #9252 has now broken several of my applications. The scenario: I have this piece in my config array. 'export' => array( 'min'=>1, 'max'=>1, 'desc'=>"Export data for this company"), 'import' => array( 'min'=>1, 'max'=>1, 'desc'=>"Import data for this company"), But I only want to require import OR export (XOR) and I was doing a check in the PEAR::isError else to test that scenario. Now I changed my script to specify a default of '' for those two args and my "else" check is now hit, however doesn't work correctly as BOTH import and export are now "defined" even though I only specified one of them. Test script: --------------- require_once "PEAR.php"; require_once "Console/Getargs.php"; $args =& Console_Getargs::factory($config = array( 'export' => array( 'min'=>1, 'max'=>1, 'desc'=>"Export data for this company"), 'import' => array( 'min'=>1, 'max'=>1, 'desc'=>"Import data for this company"), )); if (PEAR::isError($args)) { if ($args->getCode() === CONSOLE_GETARGS_ERROR_USER) { echo Console_Getargs::getHelp($config, null, $args->getMessage())."\n"; } elseif ($args->getCode() === CONSOLE_GETARGS_HELP) { echo Console_Getargs::getHelp($config)."\n"; } exit; } elseif ((!$args->isDefined('export') && !$args->isDefined('import')) || ($args->isDefined('export') && $args->isDefined('import'))) { echo Console_Getargs::getHelp($config, null, "\nMust specify either --export OR --import")."\n\n"; echo "dump:".$args->isDefined('export')."\n"; echo "dump:".$args->isDefined('import')."\n"; exit; } Expected result: ---------------- only the variables specified on the command line should be "defined" Actual result: -------------- all variables are being treated as "defined"

Comments

 [2006-12-08 16:10 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-12-08 19:24 UTC] erudd at netfor dot com
I tried that. It gave the same result as if I didn't specify them. (I screwed up my test case, as both config items are supposed to have 'default'=>'', in them)
 [2008-04-05 20:05 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2010-10-11 19:15 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!