From 000f346c1b541bd8643d901990a69b6a66847d1e Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 20 May 2008 19:43:50 +0000 Subject: [PATCH] Handle multiple warnings correctly in ApiBase::setWarning(). Calling this function twice from the same module used to throw a fatal error. --- includes/api/ApiBase.php | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.20.1