From: Brad Jorsch Date: Wed, 22 Feb 2017 01:27:17 +0000 (-0500) Subject: API: Fix ApiMainTest::testExceptionErrors and use $wgShowDBErrorBacktrace X-Git-Tag: 1.31.0-rc.0~4032^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22brouteur%22%2C%28%24id_rubrique%20?a=commitdiff_plain;h=b18c6bcaeebb0655fa2cd1c82c85218fe3db1af4;p=lhc%2Fweb%2Fwiklou.git 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 --- 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() ] ) );