Merge "Clarify docs for wgCookieExpiration"
[lhc/web/wiklou.git] / includes / api / ApiMain.php
index ab7c0a6..554bfa6 100644 (file)
@@ -387,7 +387,10 @@ class ApiMain extends ApiBase {
         */
        protected function handleException( Exception $e ) {
                // Bug 63145: Rollback any open database transactions
-               MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+               if ( !( $e instanceof UsageException ) ) {
+                       // UsageExceptions are intentional, so don't rollback if that's the case
+                       MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+               }
 
                // Allow extra cleanup and logging
                wfRunHooks( 'ApiMain::onException', array( $this, $e ) );
@@ -986,7 +989,18 @@ class ApiMain extends ApiBase {
        public function getVal( $name, $default = null ) {
                $this->mParamsUsed[$name] = true;
 
-               return $this->getRequest()->getVal( $name, $default );
+               $ret = $this->getRequest()->getVal( $name );
+               if ( $ret === null ) {
+                       if ( $this->getRequest()->getArray( $name ) !== null ) {
+                               // See bug 10262 for why we don't just join( '|', ... ) the
+                               // array.
+                               $this->setWarning(
+                                       "Parameter '$name' uses unsupported PHP array syntax"
+                               );
+                       }
+                       $ret = $default;
+               }
+               return $ret;
        }
 
        /**
@@ -996,9 +1010,7 @@ class ApiMain extends ApiBase {
         * @return bool
         */
        public function getCheck( $name ) {
-               $this->mParamsUsed[$name] = true;
-
-               return $this->getRequest()->getCheck( $name );
+               return $this->getVal( $name, null ) !== null;
        }
 
        /**