diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 4fc772e67b9..03c3962495e 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -29,6 +29,15 @@ use Luracast\Restler\Format\UploadFormat; +// API endpoints return JSON (or XML). A stray PHP warning or notice in the +// response body corrupts the parser on the caller side. Silence the display +// of PHP messages here while keeping them in the server log so that the +// problem is still observable to the operator (filefunc.inc.php only does +// this when dolibarr_main_prod is set, which leaves development setups +// emitting HTML into every API answer). +@ini_set('display_errors', '0'); +@ini_set('log_errors', '1'); + if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test }