Page MenuHomePhabricator

API blocking broken where $wgBlockAllowsUTEdit is true
Closed, ResolvedPublic

Description

API blocking is currently broken if $wgBlockAllowsUTEdit is set to true:

<?xml version="1.0"?>
<api>

<error code="internal_api_error_MWException" info="Exception Caught: Internal error in ApiBase::getParameterFromSettings: Boolean param allowusertalk&#039;s default is set to &#039;1&#039;">

#0 /usr/local/apache/common-local/php-1.5/includes/api/ApiBase.php(761): wfDebugDieBacktrace('Internal error ...')
#1 /usr/local/apache/common-local/php-1.5/includes/api/ApiBase.php(465): ApiBase::dieDebug('ApiBase::getPar...', 'Boolean param a...')
#2 /usr/local/apache/common-local/php-1.5/includes/api/ApiBase.php(381): ApiBase->getParameterFromSettings('allowusertalk', true, true)
#3 /usr/local/apache/common-local/php-1.5/includes/api/ApiBlock.php(54): ApiBase->extractRequestParams()
#4 /usr/local/apache/common-local/php-1.5/includes/api/ApiMain.php(425): ApiBlock->execute()
#5 /usr/local/apache/common-local/php-1.5/includes/api/ApiMain.php(258): ApiMain->executeAction()
#6 /usr/local/apache/common-local/php-1.5/includes/api/ApiMain.php(242): ApiMain->executeActionWithErrorHandling()
#7 /usr/local/apache/common-local/php-1.5/api.php(77): ApiMain->execute()
#8 /usr/local/apache/common-local/live-1.5/api.php(3): require('/usr/local/apac...')
#9 {main}

</error>
</api>


Version: 1.14.x
Severity: major

Details

Reference
bz16115

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:20 PM
bzimport set Reference to bz16115.

For some crazy reason, the wiki this error is occurring on seems to have $wgBlockAllowsUTEdit set to 1 rather than true. Of course this should be handled gracefully. Trivial fix applied in r42583.

No, that error is from en.wikipedia. I also get it on my local install, even after updating past r42583. Looking at it deeper, the problem seems to be that ApiBase::getParameterFromSettings() requires that default values for boolean parameters is set to false.

(In reply to comment #2)

No, that error is from en.wikipedia. I also get it on my local install, even
after updating past r42583. Looking at it deeper, the problem seems to be that
ApiBase::getParameterFromSettings() requires that default values for boolean
parameters is set to false.

Hmm, actually that seems like a very sane thing to do. Something I completely forgot about when writing comment #1 (and when reviewing r41536) is that whether a boolean parameter is considered true or false is determined by its presence. For this reason, a default value of true is very evil, because that makes setting the parameter to false impossible.

Bug as filed fixed in r42611 by setting the default value to false. This means the fatal error goes away, but it also means you'll have to set &allowusertalk yourself, even if $wgBlockAllowsUTEdit is true. Of course, if $wgBlockAllowsUTEdit is false, setting &allowusertalk does nothing.