Merge "filebackend: avoiding computing file SHA-1 hashes unless needed"
[lhc/web/wiklou.git] / includes / api / ApiFormatJson.php
index 1aa9e15..8cb22dd 100644 (file)
@@ -81,11 +81,20 @@ class ApiFormatJson extends ApiFormatBase {
 
                                default:
                                        // Should have been caught during parameter validation
+                                       // @codeCoverageIgnoreStart
                                        $this->dieDebug( __METHOD__, 'Unknown value for \'formatversion\'' );
+                                       // @codeCoverageIgnoreEnd
                        }
                }
                $data = $this->getResult()->getResultData( null, $transform );
                $json = FormatJson::encode( $data, $this->getIsHtml(), $opt );
+               if ( $json === false ) {
+                       // This should never happen, but it's a bug which could crop up
+                       // if you use ApiResult::NO_VALIDATE for instance.
+                       // @codeCoverageIgnoreStart
+                       $this->dieDebug( __METHOD__, 'Unable to encode API result as JSON' );
+                       // @codeCoverageIgnoreEnd
+               }
 
                // T68776: OutputHandler::mangleFlashPolicy() avoids a nasty bug in
                // Flash, but what it does isn't friendly for the API, so we need to
@@ -124,8 +133,8 @@ class ApiFormatJson extends ApiFormatBase {
                                ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-ascii',
                        ],
                        'formatversion' => [
-                               ApiBase::PARAM_TYPE => [ 1, 2, 'latest' ],
-                               ApiBase::PARAM_DFLT => 1,
+                               ApiBase::PARAM_TYPE => [ '1', '2', 'latest' ],
+                               ApiBase::PARAM_DFLT => '1',
                                ApiBase::PARAM_HELP_MSG => 'apihelp-json-param-formatversion',
                        ],
                ];