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
- Hide php Notices in Dashboard
- Upgrading PHP version results in “Use of undefined constant WP_CONTENT_DIR” warning?
- WordPress “Link has expired” error on updating posts
- Does the REST API (official) support custom post types?
- Notice: Constant already defined in wp-config.php on (non-existent) line?
- Ajax call to my WordPress website from an external application [duplicate]
- Problem with Woocommerce REST API Authentication
- How Do I Add User Custom Field to REST API Response?
- 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
- 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]
- Does WordPress have a built in reference to the PHP version its running under? [closed]
- How to filter posts by post format “standard” from wp-json api?
- Why is the post meta[] empty when I make a call to the wordpress rest api?
- How to find error in my code when the error message is pointing to WP core file?
- PHP Warning: Attempt to read property “term_id” on bool
- Woocommerce hook run after an Order been created through REST API
- Mute Debug Messages from Plugins
- How to show single category archive
- WordPress Script stops suddenly
- Woocommerce api: create product with images – bad request
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- A non-numeric value encountered in /wp-includes/functions.php on line 68
- Error on wp_default_style After upgrade to php 7
- Are nonces in WP REST API optional by default?
- Getting error when using wp_insert_post()
- Error: options page not found
- Which is the correct way to conditionally enqueue a CSS file?
- “Undefined index” error when saving empty array with checkboxes
- JSON REST API WordPress only showing first 10 categories
- Buddypress update user avatar image via REST
- Preg_Match(): compilation failed unknown property name
- customize wordpress database error page
- Building a REST API for your web app exposes primary keys of DB records?
- How can I spin up a new website for a registered user automatically?
- Cant register rest routs from class instance
- WordPress REST API register_rest_route give a 500 error
- How to end a while loop when used in a fetch assoc function [closed]
- After adding my website to a new server, I keep getting a unexpected end of file error, but the file is identitcal to it’s original source
- javascript variable to wordpress php variable
- Filter by field with array value in ACF on WP REST API
- Angular not defined [closed]
- Help with accessing wp-admin page and resolving error messages
- Blog suddenly shows Archive instead of index page
- no_rest_route error on custom routes
- Illegal string offset in PHP function in via Theme Customizer
- REST api returns 404 on some WordPress sites
- 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
- Fatal error login WordPress [duplicate]
- I am having errors with checkout on wordpress
- Force REST API Authentication for each request method
- Intermittent 503 Service Unavailable Error
- REST API custom endpoint to fetch pages and posts not working
- Trying to get property ‘ID’ and ‘post_author’ of non-object error
- HELP: cannot log into wordpress. PHP error
- get Woocommerce product format json for WP_Query
- PHP error on local server install
- WordPress files break if I edit them, but adding a closing PHP tag fixes it
- PHP Error in WordPress Theme
- WordPress database error only while loading page for 1st time
- Is there a way to search for a missing endif?
- style.min.css code issue
- PHP is_embed error showing up
- WordPress 3.0 PHP Error – notice WordPress_product_Type was called incorrectly
- Headers Already Sent
- Too few arguments for printf() [closed]
- syntax error unexpected ‘}’ at 364 line
- 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]
- What does that mean: cannot use a scalar value as an array [closed]
- problem with php function error
- PHP warning Invalid argument supplied for foreach() on custom page template
- Please help! Parse error: syntax error, unexpected ‘
- Not able to see the error [closed]
- Properly process a custom WP REST API request (Authenticate, Authorize + Validate)?
- PHP warning $post->ID is null
- 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?
- Execute multiple PHP Snippets causes error?
- WordPress 6.1.1 shows deprecated errors with PHP 8.1 & 8.2
- I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
- WordPress @include( ‘template-config.php’ );
- “Unexpected response from server” error when trying to upload any .mp4 file over 100MB
- 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
- Registered a REST Route but I’m Getting a 400 Bad Request
- WP_Error Object in wp_remote_post & wp_remote_get
- Custom rest fields not loaded in rest api cpt response
- There has been a critical error on this website – wordpress issue after upgrading PHP