Last modified: 2011-03-27 13:19:12 UTC
When the shortcut for type declaration inside the api documentation is used, then action=paraminfo adds wrongly a empty default attribute to the output, if the value is null. See ImageInfo: 'continue' => null gives: name="continue" type="string" *default=""* Looks like strval return an emtpy string for null input: $a['default'] = strval( $p );
It's not wrong. The default "null" is just literally anything, in most cases a string
But null is not an empty string. When the default is nothing, than action=paraminfo should say that as it does for the long form with ApiBase::PARAM_TYPE => 'string' action=protect and action=edit use 'reason' => '', that is useless than.
(In reply to comment #2) > But null is not an empty string. When the default is nothing, than > action=paraminfo should say that as it does for the long form with > ApiBase::PARAM_TYPE => 'string' > > action=protect and action=edit use 'reason' => '', that is useless than. action=undelete and action=protect you mean They pass the variables straight into something else, where the default parameter is $blah = '', so passing null isn't nice. 'foo' => '' in protect/undelete give <param name="reason" description="Reason for (un)protecting (optional)" type="string" default="" /> Which is correct. Would you rather I made those explicit? I can see some benefit switching => null to array( ApiBase::PARAM_TYPE => 'string' ), as it explicitally sets no default, and the default used is null. Is that what you were wanting originally?
(In reply to comment #2) > But null is not an empty string. When the default is nothing, than > action=paraminfo should say that as it does for the long form with > ApiBase::PARAM_TYPE => 'string' > > action=protect and action=edit use 'reason' => '', that is useless than. 'foo' => null is a shorthand for: 'foo' => array( ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_DFLT => '' ) So the output is perfectly correct
In my opinion is 'foo' => null a shorthand for 'foo' => array( ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_DFLT => null ) and 'foo' => '' is a shorthand for: 'foo' => array( ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_DFLT => '' ) because now is there no different between null and ''. But when you say, that is defined that way, that is ok. Thank you.
but action=help show a empty default, and ignore a default of null reason - Reason for (un)protecting (optional) Default: reason - Reason for restoring (optional) Default:
(In reply to comment #5) > In my opinion is > > 'foo' => null > > a shorthand for > > 'foo' => array( > ApiBase::PARAM_TYPE => 'string', > ApiBase::PARAM_DFLT => null > ) > Maybe that's your opinion, but it's not how things actually work.