Handle multiple warnings correctly in ApiBase::setWarning(). Calling this function...
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 20 May 2008 19:43:50 +0000 (19:43 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 20 May 2008 19:43:50 +0000 (19:43 +0000)
includes/api/ApiBase.php

index 978e056..f5b51b0 100644 (file)
@@ -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);