From: Roan Kattouw Date: Tue, 20 May 2008 19:43:50 +0000 (+0000) Subject: Handle multiple warnings correctly in ApiBase::setWarning(). Calling this function... X-Git-Tag: 1.31.0-rc.0~47505 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=000f346c1b541bd8643d901990a69b6a66847d1e;p=lhc%2Fweb%2Fwiklou.git Handle multiple warnings correctly in ApiBase::setWarning(). Calling this function twice from the same module used to throw a fatal error. --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 978e0565ef..f5b51b0659 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -155,6 +155,13 @@ abstract class ApiBase { * notice any changes in API. */ public function setWarning($warning) { + # If there is a warning already, append it to the existing one + $data =& $this->getResult()->getData(); + if(isset($data['warnings'][$this->getModuleName()])) + { + $warning = "{$data['warnings'][$this->getModuleName()]['*']}\n$warning"; + unset($data['warnings'][$this->getModuleName()]); + } $msg = array(); ApiResult :: setContent($msg, $warning); $this->getResult()->addValue('warnings', $this->getModuleName(), $msg);