Last modified: 2011-03-27 13:19:12 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30224, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 28224 - action=paraminfo gives empty default string for null
action=paraminfo gives empty default string for null
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.18.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Roan Kattouw
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-24 19:10 UTC by db [inactive,noenotif]
Modified: 2011-03-27 13:19 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description db [inactive,noenotif] 2011-03-24 19:10:11 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 );
Comment 1 Sam Reed (reedy) 2011-03-24 19:26:41 UTC
It's not wrong.

The default "null" is just literally anything, in most cases a string
Comment 2 db [inactive,noenotif] 2011-03-24 20:02:36 UTC
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.
Comment 3 Sam Reed (reedy) 2011-03-24 21:06:30 UTC
(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?
Comment 4 Roan Kattouw 2011-03-24 22:57:51 UTC
(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
Comment 5 db [inactive,noenotif] 2011-03-25 18:03:46 UTC
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.
Comment 6 db [inactive,noenotif] 2011-03-25 18:44:37 UTC
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:
Comment 7 Roan Kattouw 2011-03-27 13:19:12 UTC
(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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links