API: Fix ApiMainTest::testExceptionErrors and use $wgShowDBErrorBacktrace
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 22 Feb 2017 01:27:17 +0000 (20:27 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 22 Feb 2017 01:29:06 +0000 (20:29 -0500)
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
tests/phpunit/includes/api/ApiMainTest.php

index 59227d9..9e00830 100644 (file)
@@ -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',
index eff41e3..9060dfb 100644 (file)
@@ -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()
                ] ) );