From b18c6bcaeebb0655fa2cd1c82c85218fe3db1af4 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 21 Feb 2017 20:27:17 -0500 Subject: [PATCH] API: Fix ApiMainTest::testExceptionErrors and use $wgShowDBErrorBacktrace Apparently Jenkins sets $wgShowExceptionDetails to true but travis doesn't. The test should make sure it's set since it depends on it. And apparently no one ever added $wgShowDBErrorBacktrace to the API. Let's do that too. Change-Id: I0793eda349426b265a47900cdeb87bb920b5c291 --- includes/api/ApiMain.php | 4 +++- tests/phpunit/includes/api/ApiMainTest.php | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 59227d91e9..9e00830490 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -1116,7 +1116,9 @@ class ApiMain extends ApiBase { ) ); } else { - if ( $config->get( 'ShowExceptionDetails' ) ) { + if ( $config->get( 'ShowExceptionDetails' ) && + ( !$e instanceof DBError || $config->get( 'ShowDBErrorBacktrace' ) ) + ) { $result->addContentValue( $path, 'trace', diff --git a/tests/phpunit/includes/api/ApiMainTest.php b/tests/phpunit/includes/api/ApiMainTest.php index eff41e3492..9060dfb787 100644 --- a/tests/phpunit/includes/api/ApiMainTest.php +++ b/tests/phpunit/includes/api/ApiMainTest.php @@ -451,7 +451,10 @@ class ApiMainTest extends ApiTestCase { $context->setRequest( new FauxRequest( [ 'errorformat' => 'plaintext' ] ) ); $context->setLanguage( 'en' ); $context->setConfig( new MultiConfig( [ - new HashConfig( [ 'ShowHostnames' => true, 'ShowSQLErrors' => false ] ), + new HashConfig( [ + 'ShowHostnames' => true, 'ShowSQLErrors' => false, + 'ShowExceptionDetails' => true, 'ShowDBErrorBacktrace' => true, + ] ), $context->getConfig() ] ) ); -- 2.20.1