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:
- Should I use spl_autoload_register() in my plugin?
- WP-CLI – Selecting PHP version
- error_log() output for print_r() appearing on page
- When to use Exceptions vs Error Objects vs just plain false/null
- cURL 28 error after switch from to brew php 7.2 on localhost
- Hide php Notices in Dashboard
- PHP Catchable fatal error: Object of class WP_Error could not be converted to string
- Upgrading PHP version results in “Use of undefined constant WP_CONTENT_DIR” warning?
- WSOD but WP_DEBUG not giving any errors
- How to loop through JSON data in wordpress WP REST API
- WordPress “Link has expired” error on updating posts
- Creating a post with the REST API, curl and oauth returning 401 error
- Does the REST API (official) support custom post types?
- 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
- Notice: Constant already defined in wp-config.php on (non-existent) line?
- Ajax call to my WordPress website from an external application [duplicate]
- How to resolve error “Cookies are blocked due to unexpected output.”?
- Problem with Woocommerce REST API Authentication
- error_log is not working as expected in functions.php file
- How Do I Add User Custom Field to REST API Response?
- 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
- Fatal error: Call to undefined function wpsc_cart_item_count()
- Why when I instantiate wp_error in a validation method my user registration method stops working?
- Error when requesting password reset email – wp authentication
- “Notice: Undefined variable: content” is showing [closed]
- After upgrading to PHP 7.0 my contact form outputs error
- Continue execution after WP REST API response
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [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?
- How to send logs to plugin owner for a plugin?
- WordPress 3.0 PHP Error – notice WordPress_product_Type was called incorrectly
- 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
- WordPress won’t display errors at all
- Troubleshooting “loopback requests that take too long”
- 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]
- Query Concatenation
- WP Debug enabled Undefined index error in a widget
- php 7.0 update to 7.1 and at least 7.2
- What does that mean: cannot use a scalar value as an array [closed]
- problem with php function error
- How to handle PHP parse errors?
- PHP warning Invalid argument supplied for foreach() on custom page template
- WordPress White Screen Error
- Please help! Parse error: syntax error, unexpected ‘
- 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]
- Headers already sent error with get_template_part in REST API call
- PHP warning: Undefined array key 2 in feed.php
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- PHP warning $post->ID is null
- How to pass and validate nonce in custom REST routes
- rest_cannot_create_user – Sorry, you are not allowed to create new users. CURL WORDPRESS REST API
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- Getting invalid user ID error when creating a new user with wp_insert_user
- Execute multiple PHP Snippets causes error?
- REST API custom endpoints for metaboxes
- Authenticate + Authorize WP REST API request before built-in WP JSON Schema Payload Validation?
- Use of undefined constant issue
- WordPress 6.1.1 shows deprecated errors with PHP 8.1 & 8.2
- Adding Microsoft Teams Incoming Webhook to WordPress, Problem with Rest Route?
- I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
- WordPress REST API – Custom field not added to pages
- Error when loading Dashboard
- WordPress @include( ‘template-config.php’ );
- “Unexpected response from server” error when trying to upload any .mp4 file over 100MB
- taxonomy pages returning “NULL” when running default WordPress function ‘get_queried_object()’
- What is different about using admin-ajax.php in an endpoint and just submitting a form from the front end?
- REST API Plugin Update call back not updating the plugin
- Undefined constant ABSPATH
- PHP Warning: Undefined array key “HTTP_REFERER”
- regsiter a new user through WordPress API with Google SSO doesn’t work properly
- PHP Warning: Undefined array key “VirtualHostSubMenu” in index.php
- Application password header not checked in REST API
- register_rest_route, Compare purchase codes and send a response
- Can external API content be added to Rest API in WordPress
- Authorization and execution of the link
- Headers already sent error
- Registered a REST Route but I’m Getting a 400 Bad Request
- Warning: Undefined variable $post_id
- WP_Error Object in wp_remote_post & wp_remote_get
- WP rest api and litespeed incompatibility
- Facing 503 error on PHP files after deleting hidden files from the root folder
- Custom rest fields not loaded in rest api cpt response
- REST API request between domain and subdomain