REST API should always return JSON, so it’s output can be parsed as such. If it’ll return something that is not correct JSON, then your JS scripts may stop working.
This is why there should be no errors printed in these requests – such messages break JSON response and make it hard to parse.
And there was some code that was trying to prevent such messages from occurring, but it wasn’t working properly.
This was fixed in 5.0 in bug #44534.
You can always add this code to your method, id you’re really (really really really) sure, what you’re doing:
if ( true === WP_DEBUG ) @ini_set( 'display_errors', 1 );
PS. You should never display errors on production server – it’s compromising security of your site. Always use files as logging method. (It’s also easier)
Related Posts:
- error_log() output for print_r() appearing on page
- Hide php Notices in Dashboard
- PHP Catchable fatal error: Object of class WP_Error could not be converted to string
- WSOD but WP_DEBUG not giving any errors
- How to loop through JSON data in wordpress WP REST API
- How to make an meta_query optional?
- Create a new user using WP REST API and declare meta object
- get_the_content if it contains multiple lines it results in SyntaxError
- How to resolve error “Cookies are blocked due to unexpected output.”?
- error_log is not working as expected in functions.php file
- wordpress custom endpoint multiple params
- Enable errors PHP WordPress 5.2
- register_rest_route regex option for base64 or alternate
- “Can’t use function return value in write context” error
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- “Notice: Undefined variable: content” is showing [closed]
- How to generate HMAC-SHA1 signature to use with WP REST API and OAuth1
- Does WordPress have a built in reference to the PHP version its running under? [closed]
- Can WordPress email the admin about PHP errors, while hiding them from the site?
- How do I fetch all comments per post via WP REST API?
- White Screen of Death – wp-admin
- Ajax return code 400
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- get_term_link() returns correct – But illogical error-messages disturb
- PHP Warning: Attempt to read property “term_id” on bool
- what is the best practice to add new field to an api route
- Mute Debug Messages from Plugins
- how to save selected option in variable for rest api category filter
- Error: options page not found
- Which is the correct way to conditionally enqueue a CSS file?
- JSON REST API WordPress only showing first 10 categories
- Delete taxonomy and delete all post related it
- Preg_Match(): compilation failed unknown property name
- How to set a template with wp_insert_post
- Permission callback to check if user has application password
- Multiple requests external data api dynamic block gutenberg
- Errors after upgrading PHP to 7.4 WordPress
- WordPress REST API register_rest_route give a 500 error
- WC_Customer delete function returns error
- How to end a while loop when used in a fetch assoc function [closed]
- javascript variable to wordpress php variable
- Filter by field with array value in ACF on WP REST API
- REST API works in browser and via AJAX but fails via cURL
- How to clone all WordPress Rest API end points
- What’s wrong with this piece of code? [closed]
- can’t get errors
- Angular not defined [closed]
- Cannot load media and I get “PHP Warning: Invalid argument supplied for foreach(“
- Fatal Error wp-settings.php on line 119
- How can I fix this code [duplicate]
- Too many errors on log
- no_rest_route error on custom routes
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- WordPress api post image raw data without being blank in media library
- REST api returns 404 on some WordPress sites
- Can’t log in to WordPress wp-admin after adding code to functions.php
- Integrate admin plugin into template. Very interesant (live search + autocomplete with wp rest api, in vanilla js)
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- White screen after migrating site, but wp-admin works fine. Disabling all plugins, applying default theme and enabling debug mode does nothing
- Fatal error login WordPress [duplicate]
- WordPress 5.6 Application Passwords
- Intermittent 503 Service Unavailable Error
- PHP Warning: mysqli_query(): after updating my websites php from 5.6 to 7.2
- Call WP Rest-Api to GET /users/me returned NOTHING in console
- WordPress Bad Request Error 400
- WooCommerce REST API AJAX Auth – 401 response
- Looping through and combining calls to Woocommerce REST API
- Why am I getting syntax error, unexpected ‘endwhile’ (T_ENDWHILE) on single.php
- The link you followed has expired. Please try again
- Modifying server’s response to API endpoint
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- WordPress files break if I edit them, but adding a closing PHP tag fixes it
- Getting an empty space in up sell items
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- Is there a way to search for a missing endif?
- style.min.css code issue
- PHP is_embed error showing up
- global $post inside plugin query messes up every new post page in wp-admin
- Headers Already Sent
- Functions are causing errors
- Too few arguments for printf() [closed]
- syntax error unexpected ‘}’ at 364 line
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- Data inserted in database, but ajax calls error function
- Parse error: syntax error, unexpected ‘}’ in C:\wamp64\www\Proiect\aplicatie\user_check.php on line 18 [closed]
- WP Debug enabled Undefined index error in a widget
- php 7.0 update to 7.1 and at least 7.2
- PHP warning Invalid argument supplied for foreach() on custom page template
- Not able to see the error [closed]
- Need help with Deprecated: Non-static error when update PHP 7.4 -> 8.1 with Dyad 2 theme
- kali php problem [closed]
- PHP warning: Undefined array key 2 in feed.php
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- How to pass and validate nonce in custom REST routes
- Execute multiple PHP Snippets causes error?
- REST API custom endpoints for metaboxes
- Use of undefined constant issue
- WordPress 6.1.1 shows deprecated errors with PHP 8.1 & 8.2
- WordPress REST API – Custom field not added to pages