本文整理汇总了PHP中ApiFormatBase::forceDefaultParams方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiFormatBase::forceDefaultParams方法的具体用法?PHP ApiFormatBase::forceDefaultParams怎么用?PHP ApiFormatBase::forceDefaultParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiFormatBase
的用法示例。
在下文中一共展示了ApiFormatBase::forceDefaultParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleException
/**
* Handle an exception as an API response
*
* @since 1.23
* @param Exception $e
*/
protected function handleException(Exception $e)
{
// Bug 63145: Rollback any open database transactions
if (!$e instanceof UsageException) {
// UsageExceptions are intentional, so don't rollback if that's the case
try {
MWExceptionHandler::rollbackMasterChangesAndLog($e);
} catch (DBError $e2) {
// Rollback threw an exception too. Log it, but don't interrupt
// our regularly scheduled exception handling.
MWExceptionHandler::logException($e2);
}
}
// Allow extra cleanup and logging
Hooks::run('ApiMain::onException', array($this, $e));
// Log it
if (!$e instanceof UsageException) {
MWExceptionHandler::logException($e);
}
// Handle any kind of exception by outputting properly formatted error message.
// If this fails, an unhandled exception should be thrown so that global error
// handler will process and log it.
$errCode = $this->substituteResultWithError($e);
// Error results should not be cached
$this->setCacheMode('private');
$response = $this->getRequest()->response();
$headerStr = 'MediaWiki-API-Error: ' . $errCode;
if ($e->getCode() === 0) {
$response->header($headerStr);
} else {
$response->header($headerStr, true, $e->getCode());
}
// Reset and print just the error message
ob_clean();
// Printer may not be initialized if the extractRequestParams() fails for the main module
$this->createErrorPrinter();
try {
$this->printResult(true);
} catch (UsageException $ex) {
// The error printer itself is failing. Try suppressing its request
// parameters and redo.
$this->setWarning('Error printer failed (will retry without params): ' . $ex->getMessage());
$this->mPrinter = null;
$this->createErrorPrinter();
$this->mPrinter->forceDefaultParams();
$this->printResult(true);
}
}